2017-06-10 15:30:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Unit;
|
|
|
|
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class ApplicationTest extends TestCase
|
|
|
|
{
|
2019-07-22 07:03:23 +00:00
|
|
|
public function setUp(): void
|
2017-06-10 15:30:54 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
@unlink(app()->publicPath().'/public/hot');
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
2019-07-22 07:03:23 +00:00
|
|
|
public function static_urls_without_cdn_are_constructed_correctly(): void
|
2017-06-10 15:30:54 +00:00
|
|
|
{
|
|
|
|
// 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
|
2020-09-06 18:21:39 +00:00
|
|
|
self::assertEquals('http://localhost/', $root);
|
|
|
|
self::assertEquals('http://localhost/foo.css', $assetURL);
|
2017-06-10 15:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
2019-07-22 07:03:23 +00:00
|
|
|
public function static_urls_with_cdn_are_constructed_correctly(): void
|
2017-06-10 15:30:54 +00:00
|
|
|
{
|
|
|
|
// 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
|
2020-09-06 18:21:39 +00:00
|
|
|
self::assertEquals('http://cdn.tld/', $root);
|
|
|
|
self::assertEquals('http://cdn.tld/foo.css', $assetURL);
|
2017-06-10 15:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
2019-07-22 07:03:23 +00:00
|
|
|
public function application_asset_revision_urls_are_constructed_correctly_when_not_using_cdn(): void
|
2017-06-10 15:30:54 +00:00
|
|
|
{
|
|
|
|
// 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
|
2020-09-06 18:21:39 +00:00
|
|
|
self::assertEquals('http://localhost/public/foo00.css', $assetURL);
|
2017-06-10 15:30:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
2019-07-22 07:03:23 +00:00
|
|
|
public function application_asset_revision_urls_are_constructed_correctly_when_using_cdn(): void
|
2017-06-10 15:30:54 +00:00
|
|
|
{
|
|
|
|
// 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
|
2020-09-06 18:21:39 +00:00
|
|
|
self::assertEquals('http://cdn.tld/public/foo00.css', $assetURL);
|
2017-06-10 15:30:54 +00:00
|
|
|
}
|
|
|
|
}
|