forked from koel/koel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationTest.php
More file actions
76 lines (59 loc) · 2.32 KB
/
Copy pathApplicationTest.php
File metadata and controls
76 lines (59 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
namespace Tests\Unit;
use Tests\TestCase;
class ApplicationTest extends TestCase
{
public function setUp()
{
parent::setUp();
@unlink(app()->publicPath().'/public/hot');
}
/** @test */
public function static_urls_without_cdn_are_constructed_correctly()
{
// Given we are not using a CDN
config(['koel.cdn.url' => '']);
// When I get the static URLs for the assets
$root = app()->staticUrl();
$assetURL = app()->staticUrl('/foo.css ');
// Then I see they're constructed correctly
$this->assertEquals('http://localhost/', $root);
$this->assertEquals('http://localhost/foo.css', $assetURL);
}
/** @test */
public function static_urls_with_cdn_are_constructed_correctly()
{
// Given we're using a CDN
config(['koel.cdn.url' => 'http://cdn.tld']);
// When I get the static URLs for the assets
$root = app()->staticUrl();
$assetURL = app()->staticUrl('/foo.css ');
// Then I see they're constructed correctly
$this->assertEquals('http://cdn.tld/', $root);
$this->assertEquals('http://cdn.tld/foo.css', $assetURL);
}
/** @test */
public function application_asset_revision_urls_are_constructed_correctly_when_not_using_cdn()
{
// Given we have revisioned assets in the manifest file
$manifestFile = __DIR__.'../../blobs/rev-manifest.json';
// and we're not using a CDN
config(['koel.cdn.url' => '']);
// When I get the static URLs for the assets
$assetURL = app()->rev('/foo.css', $manifestFile);
// Then I see they're constructed correctly
$this->assertEquals('http://localhost/public/foo00.css', $assetURL);
}
/** @test */
public function application_asset_revision_urls_are_constructed_correctly_when_using_cdn()
{
// Given we have revisioned assets in the manifest file
$manifestFile = __DIR__.'../../blobs/rev-manifest.json';
// and we're using a CDN
config(['koel.cdn.url' => 'http://cdn.tld']);
// When I get the static URLs for the assets
$assetURL = app()->rev('/foo.css', $manifestFile);
// Then I see they're constructed correctly
$this->assertEquals('http://cdn.tld/public/foo00.css', $assetURL);
}
}