From 9edfe944225a12e696f99183e305a98b0cb633cc Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:12:38 +0200 Subject: [PATCH 01/20] Refactor test to be a unit test --- .../{Feature => Unit}/Support/MediaFileTest.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) rename packages/framework/tests/{Feature => Unit}/Support/MediaFileTest.php (93%) diff --git a/packages/framework/tests/Feature/Support/MediaFileTest.php b/packages/framework/tests/Unit/Support/MediaFileTest.php similarity index 93% rename from packages/framework/tests/Feature/Support/MediaFileTest.php rename to packages/framework/tests/Unit/Support/MediaFileTest.php index 0782bfaf3bc..a4798f0db52 100644 --- a/packages/framework/tests/Feature/Support/MediaFileTest.php +++ b/packages/framework/tests/Unit/Support/MediaFileTest.php @@ -2,19 +2,30 @@ declare(strict_types=1); -namespace Hyde\Framework\Testing\Feature\Support; +namespace Hyde\Framework\Testing\Unit\Support; use Hyde\Facades\Filesystem; use Hyde\Framework\Exceptions\FileNotFoundException; use Hyde\Hyde; use Hyde\Support\Filesystem\MediaFile; -use Hyde\Testing\TestCase; +use Hyde\Testing\UnitTestCase; +use Hyde\Testing\CreatesTemporaryFiles; /** * @covers \Hyde\Support\Filesystem\MediaFile */ -class MediaFileTest extends TestCase +class MediaFileTest extends UnitTestCase { + use CreatesTemporaryFiles; + + protected static bool $needsKernel = true; + protected static bool $needsConfig = true; + + protected function tearDown(): void + { + $this->cleanUpFilesystem(); + } + public function testCanConstruct() { $file = new MediaFile('foo'); From b6eed88c1161093f44daee2b30a4c0474a113212 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:19:28 +0200 Subject: [PATCH 02/20] Draft new mediaPath helper --- packages/framework/src/Support/Filesystem/MediaFile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 45298a50694..e5f0fba95bf 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -41,6 +41,14 @@ public static function files(): array return array_keys(static::all()); } + /** + * Get the absolute path to the media source directory, or a file within it. + */ + public static function mediaPath(string $path = ''): string + { + return Hyde::mediaPath($path); + } + public function getIdentifier(): string { return Str::after($this->getPath(), Hyde::getMediaDirectory().'/'); From ccca1d773052be4e37f5204b774b1104983a3a76 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:20:01 +0200 Subject: [PATCH 03/20] Draft new siteMediaPath helper --- packages/framework/src/Support/Filesystem/MediaFile.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index e5f0fba95bf..418ea84e73c 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -49,6 +49,14 @@ public static function mediaPath(string $path = ''): string return Hyde::mediaPath($path); } + /** + * Get the absolute path to the compiled site's media directory, or a file within it. + */ + public static function siteMediaPath(string $path = ''): string + { + return Hyde::siteMediaPath($path); + } + public function getIdentifier(): string { return Str::after($this->getPath(), Hyde::getMediaDirectory().'/'); From b6a1269272b9f9391f0ceb7a08539b426b3e1dfd Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:21:31 +0200 Subject: [PATCH 04/20] Inline kernel access --- packages/framework/src/Support/Filesystem/MediaFile.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 418ea84e73c..539ac68f3fe 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -6,6 +6,7 @@ use Hyde\Hyde; use Hyde\Facades\Config; +use Hyde\Foundation\HydeKernel; use Hyde\Framework\Exceptions\FileNotFoundException; use Illuminate\Support\Str; @@ -46,7 +47,7 @@ public static function files(): array */ public static function mediaPath(string $path = ''): string { - return Hyde::mediaPath($path); + return HydeKernel::getInstance()->mediaPath($path); } /** @@ -54,7 +55,7 @@ public static function mediaPath(string $path = ''): string */ public static function siteMediaPath(string $path = ''): string { - return Hyde::siteMediaPath($path); + return HydeKernel::getInstance()->siteMediaPath($path); } public function getIdentifier(): string From ecd98dbd436cc29663d956fbb9b0ab94ab89c768 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:22:14 +0200 Subject: [PATCH 05/20] Rename added methods to match HydePage siblings --- packages/framework/src/Support/Filesystem/MediaFile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 539ac68f3fe..3b514361caf 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -45,7 +45,7 @@ public static function files(): array /** * Get the absolute path to the media source directory, or a file within it. */ - public static function mediaPath(string $path = ''): string + public static function sourcePath(string $path = ''): string { return HydeKernel::getInstance()->mediaPath($path); } @@ -53,7 +53,7 @@ public static function mediaPath(string $path = ''): string /** * Get the absolute path to the compiled site's media directory, or a file within it. */ - public static function siteMediaPath(string $path = ''): string + public static function outputPath(string $path = ''): string { return HydeKernel::getInstance()->siteMediaPath($path); } From beaf5114a3c086274430db9c2961a598c603062d Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:23:27 +0200 Subject: [PATCH 06/20] Refactor base implementations to be class independent --- packages/framework/src/Foundation/Kernel/Filesystem.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index a8f36a32df1..cdd1685b295 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -97,10 +97,10 @@ public function pathToRelative(string $path): string public function mediaPath(string $path = ''): string { if (empty($path)) { - return $this->path(Hyde::getMediaDirectory()); + return Hyde::path(Hyde::getMediaDirectory()); } - return $this->path(path_join(Hyde::getMediaDirectory(), unslash($path))); + return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path))); } /** @@ -121,12 +121,12 @@ public function sitePath(string $path = ''): string public function siteMediaPath(string $path = ''): string { if (empty($path)) { - return $this->sitePath(Hyde::getMediaOutputDirectory()); + return Hyde::sitePath(Hyde::getMediaOutputDirectory()); } $path = unslash($path); - return $this->sitePath(Hyde::getMediaOutputDirectory()."/$path"); + return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path"); } /** From 9aa1f66db9d946cf41e7f1b16f0e5f04f8a0ceba Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:24:53 +0200 Subject: [PATCH 07/20] Move method logic to new code location --- .../src/Foundation/Kernel/Filesystem.php | 15 +++------------ .../src/Support/Filesystem/MediaFile.php | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index cdd1685b295..c637ed271b9 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -7,6 +7,7 @@ use Hyde\Hyde; use Hyde\Foundation\HydeKernel; use Hyde\Foundation\PharSupport; +use Hyde\Support\Filesystem\MediaFile; use Illuminate\Support\Collection; use function collect; @@ -96,11 +97,7 @@ public function pathToRelative(string $path): string */ public function mediaPath(string $path = ''): string { - if (empty($path)) { - return Hyde::path(Hyde::getMediaDirectory()); - } - - return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path))); + return MediaFile::sourcePath($path); } /** @@ -120,13 +117,7 @@ public function sitePath(string $path = ''): string */ public function siteMediaPath(string $path = ''): string { - if (empty($path)) { - return Hyde::sitePath(Hyde::getMediaOutputDirectory()); - } - - $path = unslash($path); - - return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path"); + return MediaFile::outputPath($path); } /** diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index 3b514361caf..fbf6f04ea9b 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -6,10 +6,11 @@ use Hyde\Hyde; use Hyde\Facades\Config; -use Hyde\Foundation\HydeKernel; use Hyde\Framework\Exceptions\FileNotFoundException; use Illuminate\Support\Str; +use function Hyde\unslash; +use function Hyde\path_join; use function extension_loaded; use function file_exists; use function array_merge; @@ -47,7 +48,11 @@ public static function files(): array */ public static function sourcePath(string $path = ''): string { - return HydeKernel::getInstance()->mediaPath($path); + if (empty($path)) { + return Hyde::path(Hyde::getMediaDirectory()); + } + + return Hyde::path(path_join(Hyde::getMediaDirectory(), unslash($path))); } /** @@ -55,7 +60,13 @@ public static function sourcePath(string $path = ''): string */ public static function outputPath(string $path = ''): string { - return HydeKernel::getInstance()->siteMediaPath($path); + if (empty($path)) { + return Hyde::sitePath(Hyde::getMediaOutputDirectory()); + } + + $path = unslash($path); + + return Hyde::sitePath(Hyde::getMediaOutputDirectory()."/$path"); } public function getIdentifier(): string From 5863d03613db465499d3f26e6344f66480c01b9b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:27:20 +0200 Subject: [PATCH 08/20] Reorder methods to match sibling order --- .../hyde-kernel-filesystem-methods.md | 10 +++++----- .../Foundation/Concerns/ForwardsFilesystem.php | 8 ++++---- .../src/Foundation/Kernel/Filesystem.php | 16 ++++++++-------- spec.md | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md index bdbe12dd34d..204bb419328 100644 --- a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md +++ b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md @@ -1,7 +1,7 @@
- + #### `filesystem()` @@ -35,20 +35,20 @@ No description provided. Hyde::mediaPath(string $path): string ``` -#### `sitePath()` +#### `siteMediaPath()` No description provided. ```php -Hyde::sitePath(string $path): string +Hyde::siteMediaPath(string $path): string ``` -#### `siteMediaPath()` +#### `sitePath()` No description provided. ```php -Hyde::siteMediaPath(string $path): string +Hyde::sitePath(string $path): string ``` #### `pathToAbsolute()` diff --git a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php index 88e8aba452b..c0ac1518277 100644 --- a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php +++ b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php @@ -33,14 +33,14 @@ public function mediaPath(string $path = ''): string return $this->filesystem->mediaPath($path); } - public function sitePath(string $path = ''): string + public function siteMediaPath(string $path = ''): string { - return $this->filesystem->sitePath($path); + return $this->filesystem->siteMediaPath($path); } - public function siteMediaPath(string $path = ''): string + public function sitePath(string $path = ''): string { - return $this->filesystem->siteMediaPath($path); + return $this->filesystem->sitePath($path); } public function pathToAbsolute(string|array $path): string|array diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index c637ed271b9..f254440d3e8 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -100,6 +100,14 @@ public function mediaPath(string $path = ''): string return MediaFile::sourcePath($path); } + /** + * Get the absolute path to the compiled site's media directory, or a file within it. + */ + public function siteMediaPath(string $path = ''): string + { + return MediaFile::outputPath($path); + } + /** * Get the absolute path to the compiled site directory, or a file within it. */ @@ -112,14 +120,6 @@ public function sitePath(string $path = ''): string return $this->path(path_join(Hyde::getOutputDirectory(), unslash($path))); } - /** - * Get the absolute path to the compiled site's media directory, or a file within it. - */ - public function siteMediaPath(string $path = ''): string - { - return MediaFile::outputPath($path); - } - /** * Works similarly to the path() function, but returns a file in the Framework package. * diff --git a/spec.md b/spec.md index a1ca493ac41..cb78e76674c 100644 --- a/spec.md +++ b/spec.md @@ -78,17 +78,17 @@ Asset::hasMediaFile(string $file) // Returns file_exists(Hyde::mediaPath($file)) ```php Hyde::mediaPath() // Get the absolute path to the media source directory, or a file within it. (Intended as a sibling to Hyde::path and Hyde::sitePath helpers, and the HydePage::path methods) +Hyde::siteMediaPath() // Get the absolute path to the compiled site's media directory, or a file within it. (Intended as a sibling to Hyde::sitePath) Hyde::mediaLink() // Gets a relative web link to the given file stored in the _site/media folder. (Intended as a sibling to Hyde::relativeLink, which is called by this) (A second $validate parameter will return throw an exception if the file does not exist) Hyde::asset() // Gets a relative web link to the given image stored in the _site/media folder. (But leaves remote URLs alone) (A second $preferQualifiedUrl parameter will return a fully qualified URL if a site URL is set) -Hyde::siteMediaPath() // Get the absolute path to the compiled site's media directory, or a file within it. (Intended as a sibling to Hyde::sitePath) /** * Real implementations of the facade methods: * * @see \Hyde\Foundation\HydeKernel::mediaPath {@see \Hyde\Foundation\Kernel\Filesystem::mediaPath} + * @see \Hyde\Foundation\HydeKernel::siteMediaPath {@see \Hyde\Foundation\Kernel\Filesystem::siteMediaPath} * @see \Hyde\Foundation\HydeKernel::mediaLink {@see \Hyde\Foundation\Kernel\Hyperlinks::mediaLink} * @see \Hyde\Foundation\HydeKernel::asset {@see \Hyde\Foundation\Kernel\Hyperlinks::asset} - * @see \Hyde\Foundation\HydeKernel::siteMediaPath {@see \Hyde\Foundation\Kernel\Filesystem::siteMediaPath} */ ``` From a60e91b61659925ed17a370e37c5c69fc293bf5a Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:37:07 +0200 Subject: [PATCH 09/20] Move tests to match new code locations --- .../Feature/Foundation/FilesystemTest.php | 25 +++++----------- .../tests/Unit/Support/MediaFileTest.php | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/packages/framework/tests/Feature/Foundation/FilesystemTest.php b/packages/framework/tests/Feature/Foundation/FilesystemTest.php index 6c2c2811cd8..0be01b45c22 100644 --- a/packages/framework/tests/Feature/Foundation/FilesystemTest.php +++ b/packages/framework/tests/Feature/Foundation/FilesystemTest.php @@ -13,6 +13,7 @@ use Hyde\Pages\HtmlPage; use Hyde\Pages\MarkdownPage; use Hyde\Pages\MarkdownPost; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Testing\UnitTestCase; use function Hyde\normalize_slashes; @@ -263,31 +264,19 @@ public function testHelperForDocumentationPages() public function testHelperForMediaPath() { $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); - } - - public function testHelperForMediaPathReturnsPathToFileWithinTheDirectory() - { - $this->assertSame(Hyde::path('_media/foo.css'), Hyde::mediaPath('foo.css')); - } + $this->assertSame(MediaFile::sourcePath(), Hyde::mediaPath()); - public function testGetMediaPathReturnsAbsolutePath() - { - $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); + $this->assertSame(Hyde::path('_media/foo.png'), Hyde::mediaPath('foo.png')); + $this->assertSame(MediaFile::sourcePath('foo.png'), Hyde::mediaPath('foo.png')); } public function testHelperForMediaOutputPath() { $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); - } - - public function testHelperForMediaOutputPathReturnsPathToFileWithinTheDirectory() - { - $this->assertSame(Hyde::path('_site/media/foo.css'), Hyde::siteMediaPath('foo.css')); - } + $this->assertSame(MediaFile::outputPath(), Hyde::siteMediaPath()); - public function testGetMediaOutputPathReturnsAbsolutePath() - { - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/media/foo.png'), Hyde::siteMediaPath('foo.png')); + $this->assertSame(MediaFile::outputPath('foo.png'), Hyde::siteMediaPath('foo.png')); } public function testHelperForSiteOutputPath() diff --git a/packages/framework/tests/Unit/Support/MediaFileTest.php b/packages/framework/tests/Unit/Support/MediaFileTest.php index a4798f0db52..86969b4d3ab 100644 --- a/packages/framework/tests/Unit/Support/MediaFileTest.php +++ b/packages/framework/tests/Unit/Support/MediaFileTest.php @@ -211,4 +211,34 @@ public function testGetIdentifierWithSubdirectory() { $this->assertSame('foo/bar', MediaFile::make('foo/bar')->getIdentifier()); } + + public function testHelperForMediaPath() + { + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + } + + public function testHelperForMediaPathReturnsPathToFileWithinTheDirectory() + { + $this->assertSame(Hyde::path('_media/foo.css'), MediaFile::sourcePath('foo.css')); + } + + public function testGetMediaPathReturnsAbsolutePath() + { + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + } + + public function testHelperForMediaOutputPath() + { + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + } + + public function testHelperForMediaOutputPathReturnsPathToFileWithinTheDirectory() + { + $this->assertSame(Hyde::path('_site/media/foo.css'), MediaFile::outputPath('foo.css')); + } + + public function testGetMediaOutputPathReturnsAbsolutePath() + { + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + } } From 8cfe0cd6d471f8c81bf259e0d1bc5066a57765f6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:38:13 +0200 Subject: [PATCH 10/20] Add todos to move more tests to match new code locations --- packages/framework/tests/Feature/HydeKernelTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/framework/tests/Feature/HydeKernelTest.php b/packages/framework/tests/Feature/HydeKernelTest.php index 8c1470b4206..bd22206502d 100644 --- a/packages/framework/tests/Feature/HydeKernelTest.php +++ b/packages/framework/tests/Feature/HydeKernelTest.php @@ -393,17 +393,23 @@ public function testGetMediaOutputDirectoryNameUsesTrimmedVersionOfMediaSourceDi public function testCanGetSiteMediaOutputDirectory() { + // Todo: Move to MediaFileTest + $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); } public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() { + // Todo: Move to MediaFileTest + Hyde::setMediaDirectory('_foo'); $this->assertSame(Hyde::path('_site/foo'), Hyde::siteMediaPath()); } public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() { + // Todo: Move to MediaFileTest + Hyde::setOutputDirectory(Hyde::path('foo')); Hyde::setMediaDirectory('bar'); From 89d0e52d4693ced01185fb7766c2d96208b47828 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:44:01 +0200 Subject: [PATCH 11/20] Create new internal trait for transitioning to v2 --- packages/framework/src/Hyde.php | 3 +++ .../framework/src/Support/V1Compatibility.php | 15 +++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 packages/framework/src/Support/V1Compatibility.php diff --git a/packages/framework/src/Hyde.php b/packages/framework/src/Hyde.php index cc309a3b21c..105b42de812 100644 --- a/packages/framework/src/Hyde.php +++ b/packages/framework/src/Hyde.php @@ -7,6 +7,7 @@ use Hyde\Enums\Feature; use Hyde\Facades\Features; use Hyde\Foundation\HydeKernel; +use Hyde\Support\V1Compatibility; use Illuminate\Support\Collection; use Hyde\Foundation\Kernel\FileCollection; use Hyde\Foundation\Kernel\Filesystem; @@ -79,6 +80,8 @@ */ class Hyde extends Facade { + use V1Compatibility; + public static function version(): string { return HydeKernel::version(); diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php new file mode 100644 index 00000000000..ed03754713d --- /dev/null +++ b/packages/framework/src/Support/V1Compatibility.php @@ -0,0 +1,15 @@ + Date: Fri, 26 Jul 2024 16:46:05 +0200 Subject: [PATCH 12/20] Ignore class from code coverage --- packages/framework/src/Support/V1Compatibility.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index ed03754713d..d26d62cd504 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -8,6 +8,8 @@ * @internal Hyde Facade support to aid in the v1 to v2 transition. * * @deprecated All code here is deprecated, and exists to help you transition. + * + * @codeCoverageIgnore This class is ignored from code coverage. */ trait V1Compatibility { From 2004a4e67e8fd80b20ffb4f96d6dd177bf26b773 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:59:19 +0200 Subject: [PATCH 13/20] Revert "Ignore class from code coverage" This reverts commit 4091051785fcc5cba66b6b4eb76abe0c23008655. --- packages/framework/src/Support/V1Compatibility.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index d26d62cd504..ed03754713d 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -8,8 +8,6 @@ * @internal Hyde Facade support to aid in the v1 to v2 transition. * * @deprecated All code here is deprecated, and exists to help you transition. - * - * @codeCoverageIgnore This class is ignored from code coverage. */ trait V1Compatibility { From 650d5a7e815033bdbdc60c6eb0e6c4a7899883b2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 16:54:58 +0200 Subject: [PATCH 14/20] Manually proxy and deprecate legacy facade methods This is so we can get an overview of the outdated methods that are inconsistently named This means they are lost from the HydeKernel which could be a problem to review before merge. --- .../hyde-kernel-filesystem-methods.md | 18 +-------------- .../Concerns/ForwardsFilesystem.php | 10 -------- .../src/Foundation/Kernel/Filesystem.php | 17 -------------- packages/framework/src/Hyde.php | 2 -- .../framework/src/Support/V1Compatibility.php | 23 ++++++++++++++++++- 5 files changed, 23 insertions(+), 47 deletions(-) diff --git a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md index 204bb419328..eb5983597e6 100644 --- a/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md +++ b/docs/_data/partials/hyde-pages-api/hyde-kernel-filesystem-methods.md @@ -1,7 +1,7 @@
- + #### `filesystem()` @@ -27,22 +27,6 @@ No description provided. Hyde::vendorPath(string $path, string $package): string ``` -#### `mediaPath()` - -No description provided. - -```php -Hyde::mediaPath(string $path): string -``` - -#### `siteMediaPath()` - -No description provided. - -```php -Hyde::siteMediaPath(string $path): string -``` - #### `sitePath()` No description provided. diff --git a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php index c0ac1518277..cea06f5bbc2 100644 --- a/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php +++ b/packages/framework/src/Foundation/Concerns/ForwardsFilesystem.php @@ -28,16 +28,6 @@ public function vendorPath(string $path = '', string $package = 'framework'): st return $this->filesystem->vendorPath($path, $package); } - public function mediaPath(string $path = ''): string - { - return $this->filesystem->mediaPath($path); - } - - public function siteMediaPath(string $path = ''): string - { - return $this->filesystem->siteMediaPath($path); - } - public function sitePath(string $path = ''): string { return $this->filesystem->sitePath($path); diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index f254440d3e8..8f3bb2fd2aa 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -7,7 +7,6 @@ use Hyde\Hyde; use Hyde\Foundation\HydeKernel; use Hyde\Foundation\PharSupport; -use Hyde\Support\Filesystem\MediaFile; use Illuminate\Support\Collection; use function collect; @@ -92,22 +91,6 @@ public function pathToRelative(string $path): string : $path); } - /** - * Get the absolute path to the media source directory, or a file within it. - */ - public function mediaPath(string $path = ''): string - { - return MediaFile::sourcePath($path); - } - - /** - * Get the absolute path to the compiled site's media directory, or a file within it. - */ - public function siteMediaPath(string $path = ''): string - { - return MediaFile::outputPath($path); - } - /** * Get the absolute path to the compiled site directory, or a file within it. */ diff --git a/packages/framework/src/Hyde.php b/packages/framework/src/Hyde.php index 105b42de812..9590fb6133a 100644 --- a/packages/framework/src/Hyde.php +++ b/packages/framework/src/Hyde.php @@ -34,8 +34,6 @@ * @method static string pathToAbsolute(string $path) * @method static string pathToRelative(string $path) * @method static string sitePath(string $path = '') - * @method static string mediaPath(string $path = '') - * @method static string siteMediaPath(string $path = '') * @method static string formatLink(string $destination) * @method static string relativeLink(string $destination) * @method static string mediaLink(string $destination, bool $validate = false) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index ed03754713d..f6bd2de40c7 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -4,6 +4,9 @@ namespace Hyde\Support; +use JetBrains\PhpStorm\Deprecated; +use Hyde\Support\Filesystem\MediaFile; + /** * @internal Hyde Facade support to aid in the v1 to v2 transition. * @@ -11,5 +14,23 @@ */ trait V1Compatibility { - // + /** + * @deprecated Use MediaFile::sourcePath() instead. + * @see \Hyde\Support\Filesystem\MediaFile::sourcePath() + */ + #[Deprecated(reason: 'Use MediaFile::sourcePath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::sourcePath()')] + public static function mediaPath(string $path = ''): string + { + return MediaFile::sourcePath($path); + } + + /** + * @deprecated Use MediaFile::outputPath() instead. + * @see \Hyde\Support\Filesystem\MediaFile::outputPath() + */ + #[Deprecated(reason: 'Use MediaFile::outputPath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::outputPath()')] + public static function siteMediaPath(string $path = ''): string + { + return MediaFile::outputPath($path); + } } From 8228d7a474666aeaf63b9d6d072f48e63305782f Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:04:58 +0200 Subject: [PATCH 15/20] Set the parameters list --- packages/framework/src/Support/V1Compatibility.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index f6bd2de40c7..863734b99cd 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -18,7 +18,7 @@ trait V1Compatibility * @deprecated Use MediaFile::sourcePath() instead. * @see \Hyde\Support\Filesystem\MediaFile::sourcePath() */ - #[Deprecated(reason: 'Use MediaFile::sourcePath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::sourcePath()')] + #[Deprecated(reason: 'Use MediaFile::sourcePath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::sourcePath(%parametersList%)')] public static function mediaPath(string $path = ''): string { return MediaFile::sourcePath($path); @@ -28,7 +28,7 @@ public static function mediaPath(string $path = ''): string * @deprecated Use MediaFile::outputPath() instead. * @see \Hyde\Support\Filesystem\MediaFile::outputPath() */ - #[Deprecated(reason: 'Use MediaFile::outputPath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::outputPath()')] + #[Deprecated(reason: 'Use MediaFile::outputPath() instead', replacement: '\Hyde\Support\Filesystem\MediaFile::outputPath(%parametersList%)')] public static function siteMediaPath(string $path = ''): string { return MediaFile::outputPath($path); From 2e96631d81859d470251c4e86706971ea969eb46 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:05:43 +0200 Subject: [PATCH 16/20] Alias the MediaFile class --- app/config.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/config.php b/app/config.php index 009c0f586b7..aed2519bbce 100644 --- a/app/config.php +++ b/app/config.php @@ -105,6 +105,7 @@ 'MarkdownPage' => \Hyde\Pages\MarkdownPage::class, 'MarkdownPost' => \Hyde\Pages\MarkdownPost::class, 'DocumentationPage' => \Hyde\Pages\DocumentationPage::class, + 'MediaFile' => \Hyde\Support\Filesystem\MediaFile::class, 'DataCollection' => \Hyde\Support\DataCollection::class, 'Includes' => \Hyde\Support\Includes::class, 'Feature' => \Hyde\Enums\Feature::class, From bbe66f46095bb275661de093239aa2acf9fbd824 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:09:33 +0200 Subject: [PATCH 17/20] Update deprecated method usages with new helpers --- .../resources/views/layouts/head.blade.php | 2 +- packages/framework/src/Facades/Asset.php | 5 +++-- .../Actions/PreBuildTasks/CleanSiteDirectory.php | 3 ++- .../PreBuildTasks/TransferMediaAssets.php | 7 +++---- .../Features/Blogging/Models/FeaturedImage.php | 3 ++- .../src/Framework/Services/ValidationService.php | 5 +++-- .../tests/Feature/Foundation/FilesystemTest.php | 16 ++++++++-------- .../framework/tests/Feature/HydeKernelTest.php | 11 ++++++----- 8 files changed, 28 insertions(+), 24 deletions(-) diff --git a/packages/framework/resources/views/layouts/head.blade.php b/packages/framework/resources/views/layouts/head.blade.php index 32ed4390d8b..111aced665b 100644 --- a/packages/framework/resources/views/layouts/head.blade.php +++ b/packages/framework/resources/views/layouts/head.blade.php @@ -2,7 +2,7 @@ {{ $page->title() }} -@if (file_exists(Hyde::mediaPath('favicon.ico'))) +@if (file_exists(MediaFile::sourcePath('favicon.ico'))) @endif diff --git a/packages/framework/src/Facades/Asset.php b/packages/framework/src/Facades/Asset.php index 9691a43c211..45e16a0a881 100644 --- a/packages/framework/src/Facades/Asset.php +++ b/packages/framework/src/Facades/Asset.php @@ -5,6 +5,7 @@ namespace Hyde\Facades; use Hyde\Hyde; +use Hyde\Support\Filesystem\MediaFile; use function md5_file; use function file_exists; @@ -24,13 +25,13 @@ public static function mediaLink(string $file): string public static function hasMediaFile(string $file): bool { - return file_exists(Hyde::mediaPath($file)); + return file_exists(MediaFile::sourcePath($file)); } protected static function getCacheBustKey(string $file): string { return Config::getBool('hyde.enable_cache_busting', true) - ? '?v='.md5_file(Hyde::mediaPath("$file")) + ? '?v='.md5_file(MediaFile::sourcePath("$file")) : ''; } } diff --git a/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php b/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php index 849f077b7cb..ba64f24ee76 100644 --- a/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php +++ b/packages/framework/src/Framework/Actions/PreBuildTasks/CleanSiteDirectory.php @@ -7,6 +7,7 @@ use Hyde\Hyde; use Hyde\Facades\Config; use Hyde\Facades\Filesystem; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\Features\BuildTasks\PreBuildTask; use function basename; @@ -22,7 +23,7 @@ public function handle(): void { if ($this->isItSafeToCleanOutputDirectory()) { Filesystem::unlink(glob(Hyde::sitePath('*.{html,json}'), GLOB_BRACE)); - Filesystem::cleanDirectory(Hyde::siteMediaPath()); + Filesystem::cleanDirectory(MediaFile::outputPath()); } } diff --git a/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php b/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php index fdec03a75ff..3acb112ea9d 100644 --- a/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php +++ b/packages/framework/src/Framework/Actions/PreBuildTasks/TransferMediaAssets.php @@ -4,7 +4,6 @@ namespace Hyde\Framework\Actions\PreBuildTasks; -use Hyde\Hyde; use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\Features\BuildTasks\PreBuildTask; use Hyde\Framework\Concerns\InteractsWithDirectories; @@ -17,14 +16,14 @@ class TransferMediaAssets extends PreBuildTask public function handle(): void { - $this->needsDirectory(Hyde::siteMediaPath()); + $this->needsDirectory(MediaFile::outputPath()); $this->newLine(); $this->withProgressBar(MediaFile::files(), function (string $identifier): void { - $sitePath = Hyde::siteMediaPath($identifier); + $sitePath = MediaFile::outputPath($identifier); $this->needsParentDirectory($sitePath); - copy(Hyde::mediaPath($identifier), $sitePath); + copy(MediaFile::sourcePath($identifier), $sitePath); }); $this->newLine(); diff --git a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php index 0f42f961c87..5c4acef1996 100644 --- a/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php +++ b/packages/framework/src/Framework/Features/Blogging/Models/FeaturedImage.php @@ -11,6 +11,7 @@ use Hyde\Support\BuildWarnings; use Illuminate\Support\Facades\Http; use Hyde\Foundation\Kernel\Hyperlinks; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\Exceptions\FileNotFoundException; use Hyde\Markdown\Contracts\FrontMatter\SubSchemas\FeaturedImageSchema; @@ -213,7 +214,7 @@ protected function has(string $property): bool protected function getContentLengthForLocalImage(): int { - $storagePath = Hyde::mediaPath($this->source); + $storagePath = MediaFile::sourcePath($this->source); if (! file_exists($storagePath)) { throw new FileNotFoundException(customMessage: sprintf('Featured image [%s] not found.', Hyde::pathToRelative($storagePath))); diff --git a/packages/framework/src/Framework/Services/ValidationService.php b/packages/framework/src/Framework/Services/ValidationService.php index 88deee3496b..052486d4041 100644 --- a/packages/framework/src/Framework/Services/ValidationService.php +++ b/packages/framework/src/Framework/Services/ValidationService.php @@ -11,6 +11,7 @@ use Hyde\Pages\MarkdownPage; use Hyde\Pages\DocumentationPage; use Hyde\Enums\Feature; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Support\Models\ValidationResult as Result; use function count; @@ -102,12 +103,12 @@ public function check_documentation_site_has_an_index_page(Result $result): Resu public function check_site_has_an_app_css_stylesheet(Result $result): Result { - if (file_exists(Hyde::siteMediaPath('/app.css')) || file_exists(Hyde::mediaPath('app.css'))) { + if (file_exists(MediaFile::outputPath('/app.css')) || file_exists(MediaFile::sourcePath('app.css'))) { return $result->pass('Your site has an app.css stylesheet'); } return $result->fail(sprintf('Could not find an app.css file in the %s or %s directory!', - Hyde::pathToRelative(Hyde::siteMediaPath()), Hyde::getMediaDirectory() + Hyde::pathToRelative(MediaFile::outputPath()), Hyde::getMediaDirectory() ))->withTip('You may need to run `npm run dev`.`'); } diff --git a/packages/framework/tests/Feature/Foundation/FilesystemTest.php b/packages/framework/tests/Feature/Foundation/FilesystemTest.php index 0be01b45c22..86bc2c76479 100644 --- a/packages/framework/tests/Feature/Foundation/FilesystemTest.php +++ b/packages/framework/tests/Feature/Foundation/FilesystemTest.php @@ -263,20 +263,20 @@ public function testHelperForDocumentationPages() public function testHelperForMediaPath() { - $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); - $this->assertSame(MediaFile::sourcePath(), Hyde::mediaPath()); + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + $this->assertSame(MediaFile::sourcePath(), MediaFile::sourcePath()); - $this->assertSame(Hyde::path('_media/foo.png'), Hyde::mediaPath('foo.png')); - $this->assertSame(MediaFile::sourcePath('foo.png'), Hyde::mediaPath('foo.png')); + $this->assertSame(Hyde::path('_media/foo.png'), MediaFile::sourcePath('foo.png')); + $this->assertSame(MediaFile::sourcePath('foo.png'), MediaFile::sourcePath('foo.png')); } public function testHelperForMediaOutputPath() { - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); - $this->assertSame(MediaFile::outputPath(), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + $this->assertSame(MediaFile::outputPath(), MediaFile::outputPath()); - $this->assertSame(Hyde::path('_site/media/foo.png'), Hyde::siteMediaPath('foo.png')); - $this->assertSame(MediaFile::outputPath('foo.png'), Hyde::siteMediaPath('foo.png')); + $this->assertSame(Hyde::path('_site/media/foo.png'), MediaFile::outputPath('foo.png')); + $this->assertSame(MediaFile::outputPath('foo.png'), MediaFile::outputPath('foo.png')); } public function testHelperForSiteOutputPath() diff --git a/packages/framework/tests/Feature/HydeKernelTest.php b/packages/framework/tests/Feature/HydeKernelTest.php index bd22206502d..9ff8799dd06 100644 --- a/packages/framework/tests/Feature/HydeKernelTest.php +++ b/packages/framework/tests/Feature/HydeKernelTest.php @@ -13,6 +13,7 @@ use Hyde\Foundation\HydeKernel; use Hyde\Enums\Feature; use Hyde\Foundation\Kernel\Filesystem; +use Hyde\Support\Filesystem\MediaFile; use Hyde\Framework\HydeServiceProvider; use Hyde\Hyde; use Hyde\Pages\BladePage; @@ -262,9 +263,9 @@ public function testFluentModelSourcePathHelpers() $this->assertSame(Hyde::path('_pages'), MarkdownPage::path()); $this->assertSame(Hyde::path('_docs'), DocumentationPage::path()); - $this->assertSame(Hyde::path('_media'), Hyde::mediaPath()); + $this->assertSame(Hyde::path('_media'), MediaFile::sourcePath()); + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); $this->assertSame(Hyde::path('_site'), Hyde::sitePath()); - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); } public function testPathToRelativeHelperReturnsRelativePathForGivenPath() @@ -395,7 +396,7 @@ public function testCanGetSiteMediaOutputDirectory() { // Todo: Move to MediaFileTest - $this->assertSame(Hyde::path('_site/media'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); } public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() @@ -403,7 +404,7 @@ public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDi // Todo: Move to MediaFileTest Hyde::setMediaDirectory('_foo'); - $this->assertSame(Hyde::path('_site/foo'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('_site/foo'), MediaFile::outputPath()); } public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() @@ -413,7 +414,7 @@ public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory Hyde::setOutputDirectory(Hyde::path('foo')); Hyde::setMediaDirectory('bar'); - $this->assertSame(Hyde::path('foo/bar'), Hyde::siteMediaPath()); + $this->assertSame(Hyde::path('foo/bar'), MediaFile::outputPath()); } public function testMediaOutputDirectoryCanBeChangedInConfiguration() From 74059a5cd81546649f58859c38ed9d0d28e521a6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:10:58 +0200 Subject: [PATCH 18/20] Remove inconsistent infix from internal helper methods --- packages/framework/src/Support/Filesystem/MediaFile.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/framework/src/Support/Filesystem/MediaFile.php b/packages/framework/src/Support/Filesystem/MediaFile.php index fbf6f04ea9b..3ed834e7562 100644 --- a/packages/framework/src/Support/Filesystem/MediaFile.php +++ b/packages/framework/src/Support/Filesystem/MediaFile.php @@ -34,7 +34,7 @@ class MediaFile extends ProjectFile /** @return array The array keys are the filenames relative to the _media/ directory */ public static function all(): array { - return static::discoverMediaAssetFiles(); + return static::discoverMediaFiles(); } /** @return array Array of filenames relative to the _media/ directory */ @@ -123,16 +123,16 @@ public function getMimeType(): string return 'text/plain'; } - protected static function discoverMediaAssetFiles(): array + protected static function discoverMediaFiles(): array { - return collect(static::getMediaAssetFiles())->mapWithKeys(function (string $path): array { + return collect(static::getMediaFiles())->mapWithKeys(function (string $path): array { $file = static::make($path); return [$file->getIdentifier() => $file]; })->all(); } - protected static function getMediaAssetFiles(): array + protected static function getMediaFiles(): array { return glob(Hyde::path(static::getMediaGlobPattern()), GLOB_BRACE) ?: []; } From 678b6f75c1c4fd60d989d2642e4f34aecae97d07 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 17:12:30 +0200 Subject: [PATCH 19/20] Reapply "Ignore class from code coverage" This reverts commit 2004a4e67e8fd80b20ffb4f96d6dd177bf26b773. --- packages/framework/src/Support/V1Compatibility.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/framework/src/Support/V1Compatibility.php b/packages/framework/src/Support/V1Compatibility.php index 863734b99cd..3d8f5b5cd0c 100644 --- a/packages/framework/src/Support/V1Compatibility.php +++ b/packages/framework/src/Support/V1Compatibility.php @@ -11,6 +11,8 @@ * @internal Hyde Facade support to aid in the v1 to v2 transition. * * @deprecated All code here is deprecated, and exists to help you transition. + * + * @codeCoverageIgnore This class is ignored from code coverage. */ trait V1Compatibility { From 46473331102f32baf8d6b5d0b374c084c1b6dda5 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 26 Jul 2024 18:32:38 +0200 Subject: [PATCH 20/20] Move the tests to the new code location --- .../tests/Feature/HydeKernelTest.php | 25 ------------------- .../tests/Unit/Support/MediaFileTest.php | 19 ++++++++++++++ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/packages/framework/tests/Feature/HydeKernelTest.php b/packages/framework/tests/Feature/HydeKernelTest.php index 9ff8799dd06..b12a5ea19bb 100644 --- a/packages/framework/tests/Feature/HydeKernelTest.php +++ b/packages/framework/tests/Feature/HydeKernelTest.php @@ -392,31 +392,6 @@ public function testGetMediaOutputDirectoryNameUsesTrimmedVersionOfMediaSourceDi $this->assertSame('foo', Hyde::getMediaOutputDirectory()); } - public function testCanGetSiteMediaOutputDirectory() - { - // Todo: Move to MediaFileTest - - $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); - } - - public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() - { - // Todo: Move to MediaFileTest - - Hyde::setMediaDirectory('_foo'); - $this->assertSame(Hyde::path('_site/foo'), MediaFile::outputPath()); - } - - public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() - { - // Todo: Move to MediaFileTest - - Hyde::setOutputDirectory(Hyde::path('foo')); - Hyde::setMediaDirectory('bar'); - - $this->assertSame(Hyde::path('foo/bar'), MediaFile::outputPath()); - } - public function testMediaOutputDirectoryCanBeChangedInConfiguration() { $this->assertSame('_media', Hyde::getMediaDirectory()); diff --git a/packages/framework/tests/Unit/Support/MediaFileTest.php b/packages/framework/tests/Unit/Support/MediaFileTest.php index 86969b4d3ab..44ded0474c5 100644 --- a/packages/framework/tests/Unit/Support/MediaFileTest.php +++ b/packages/framework/tests/Unit/Support/MediaFileTest.php @@ -241,4 +241,23 @@ public function testGetMediaOutputPathReturnsAbsolutePath() { $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); } + + public function testCanGetSiteMediaOutputDirectory() + { + $this->assertSame(Hyde::path('_site/media'), MediaFile::outputPath()); + } + + public function testGetSiteMediaOutputDirectoryUsesTrimmedVersionOfMediaSourceDirectory() + { + Hyde::setMediaDirectory('_foo'); + $this->assertSame(Hyde::path('_site/foo'), MediaFile::outputPath()); + } + + public function testGetSiteMediaOutputDirectoryUsesConfiguredSiteOutputDirectory() + { + Hyde::setOutputDirectory(Hyde::path('foo')); + Hyde::setMediaDirectory('bar'); + + $this->assertSame(Hyde::path('foo/bar'), MediaFile::outputPath()); + } }