diff --git a/packages/framework/tests/Feature/AssetFacadeTest.php b/packages/framework/tests/Feature/AssetFacadeTest.php deleted file mode 100644 index 3e934eab38b..00000000000 --- a/packages/framework/tests/Feature/AssetFacadeTest.php +++ /dev/null @@ -1,46 +0,0 @@ -assertIsString($path = Asset::mediaLink('app.css')); - $this->assertSame('media/app.css?v='.md5_file(Hyde::path('_media/app.css')), $path); - } - - public function testMediaLinkReturnsMediaPathWithoutCacheKeyIfCacheBustingIsDisabled() - { - config(['hyde.enable_cache_busting' => false]); - - $path = Asset::mediaLink('app.css'); - - $this->assertIsString($path); - $this->assertSame('media/app.css', $path); - } - - public function testMediaLinkSupportsCustomMediaDirectories() - { - $this->directory('_assets'); - $this->file('_assets/app.css'); - - Hyde::setMediaDirectory('_assets'); - - $path = Asset::mediaLink('app.css'); - - $this->assertIsString($path); - $this->assertSame('assets/app.css?v='.md5_file(Hyde::path('_assets/app.css')), $path); - } -} diff --git a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php index 4c62090bbae..a004e805399 100644 --- a/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php +++ b/packages/framework/tests/Unit/Facades/AssetFacadeUnitTest.php @@ -4,20 +4,31 @@ namespace Hyde\Framework\Testing\Unit\Facades; +use Hyde\Hyde; use Hyde\Facades\Asset; use Hyde\Testing\UnitTestCase; +use Hyde\Support\Facades\Render; +use Hyde\Support\Models\RenderData; +use Hyde\Testing\CreatesTemporaryFiles; /** * @covers \Hyde\Facades\Asset - * - * @see \Hyde\Framework\Testing\Feature\AssetFacadeTest */ class AssetFacadeUnitTest extends UnitTestCase { + use CreatesTemporaryFiles; + protected function setUp(): void { self::needsKernel(); self::mockConfig(); + + Render::swap(new RenderData()); + } + + protected function tearDown(): void + { + $this->cleanUpFilesystem(); } public function testHasMediaFileHelper() @@ -29,4 +40,33 @@ public function testHasMediaFileHelperReturnsTrueForExistingFile() { $this->assertTrue(Asset::hasMediaFile('app.css')); } + + public function testMediaLinkReturnsMediaPathWithCacheKey() + { + $this->assertIsString($path = Asset::mediaLink('app.css')); + $this->assertSame('media/app.css?v='.md5_file(Hyde::path('_media/app.css')), $path); + } + + public function testMediaLinkReturnsMediaPathWithoutCacheKeyIfCacheBustingIsDisabled() + { + self::mockConfig(['hyde.enable_cache_busting' => false]); + + $path = Asset::mediaLink('app.css'); + + $this->assertIsString($path); + $this->assertSame('media/app.css', $path); + } + + public function testMediaLinkSupportsCustomMediaDirectories() + { + $this->directory('_assets'); + $this->file('_assets/app.css'); + + Hyde::setMediaDirectory('_assets'); + + $path = Asset::mediaLink('app.css'); + + $this->assertIsString($path); + $this->assertSame('assets/app.css?v='.md5_file(Hyde::path('_assets/app.css')), $path); + } }