-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #660 from hydephp/customizable-source-roots
Add an easy configuration option to store all source directories in a subfolder
- Loading branch information
Showing
15 changed files
with
302 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/framework/tests/ConfigurableSourceRootsFeatureTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hyde\Framework\Testing; | ||
|
||
use function app; | ||
use function config; | ||
use function file_put_contents; | ||
use Hyde\Framework\HydeServiceProvider; | ||
use Hyde\Hyde; | ||
use Hyde\Pages\MarkdownPage; | ||
use Hyde\Testing\TestCase; | ||
use Illuminate\Support\Facades\File; | ||
use function mkdir; | ||
|
||
/** | ||
* Test the overall functionality of the configurable source roots feature. | ||
* | ||
* Also see these tests which cover specific implementation details: | ||
* | ||
* @see \Hyde\Framework\Testing\Feature\HydeKernelTest | ||
* @see \Hyde\Framework\Testing\Unit\HydeServiceProviderTest | ||
*/ | ||
class ConfigurableSourceRootsFeatureTest extends TestCase | ||
{ | ||
public function test_default_config_value_is_empty_string() | ||
{ | ||
$this->assertSame('', config('hyde.source_root')); | ||
} | ||
|
||
public function test_files_in_custom_source_root_can_be_discovered() | ||
{ | ||
$this->setupCustomSourceRoot(); | ||
|
||
$this->assertCount(1, MarkdownPage::files()); | ||
$this->assertCount(1, MarkdownPage::all()); | ||
|
||
File::deleteDirectory(Hyde::path('custom')); | ||
} | ||
|
||
public function test_files_in_custom_source_root_can_be_compiled() | ||
{ | ||
$this->setupCustomSourceRoot(); | ||
|
||
$this->artisan('build'); | ||
|
||
$this->assertFileExists(Hyde::path('_site/markdown.html')); | ||
|
||
File::deleteDirectory(Hyde::path('custom')); | ||
File::deleteDirectory(Hyde::path('_site')); | ||
} | ||
|
||
public function test_hyde_page_path_method_supports_custom_source_roots() | ||
{ | ||
config(['hyde.source_root' => 'custom']); | ||
(new HydeServiceProvider(app()))->register(); | ||
|
||
$this->assertSame( | ||
Hyde::path('custom/_pages/foo.md'), MarkdownPage::path('foo.md') | ||
); | ||
} | ||
|
||
protected function setupCustomSourceRoot(): void | ||
{ | ||
mkdir(Hyde::path('custom')); | ||
mkdir(Hyde::path('custom/_pages')); | ||
|
||
config(['hyde.source_root' => 'custom']); | ||
(new HydeServiceProvider(app()))->register(); | ||
|
||
file_put_contents(Hyde::path('custom/_pages/markdown.md'), 'Hello, world!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.