-
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #546 from hydephp/develop
Merge upcoming minor release
- Loading branch information
Showing
104 changed files
with
7,246 additions
and
31 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Hyde\Testing\Framework\Feature\Actions; | ||
|
||
use Hyde\Framework\Actions\ChecksIfConfigIsUpToDate; | ||
use Hyde\Testing\TestCase; | ||
|
||
/** | ||
* @covers \Hyde\Framework\Actions\ChecksIfConfigIsUpToDate | ||
*/ | ||
class ChecksIfConfigIsUpToDateTest extends TestCase | ||
{ | ||
public function test_it_returns_true_if_config_is_up_to_date() | ||
{ | ||
$action = new ChecksIfConfigIsUpToDate(); | ||
|
||
$action->hydeConfig = $this->makeConfig(); | ||
$action->frameworkConfig = $this->makeConfig(); | ||
|
||
$this->assertTrue($action->execute()); | ||
} | ||
|
||
public function test_it_returns_false_if_config_is_not_up_to_date() | ||
{ | ||
$action = new ChecksIfConfigIsUpToDate(); | ||
|
||
$action->hydeConfig = $this->makeConfig(); | ||
$action->frameworkConfig = 'foo'; | ||
|
||
$this->assertFalse($action->execute()); | ||
} | ||
|
||
protected function makeConfig(): string | ||
{ | ||
return <<<'EOF' | ||
<?php return [ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Foo Bar | ||
|-------------------------------------------------------------------------- | ||
| | ||
*/ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Second Option | ||
|-------------------------------------------------------------------------- | ||
| | ||
*/ | ||
]; | ||
EOF; | ||
} | ||
} |
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,143 @@ | ||
<?php | ||
|
||
namespace Hyde\Testing\Framework\Feature\Actions; | ||
|
||
use Hyde\Framework\Actions\CreatesNewPageSourceFile; | ||
use Hyde\Framework\Exceptions\FileConflictException; | ||
use Hyde\Framework\Exceptions\UnsupportedPageTypeException; | ||
use Hyde\Framework\Hyde; | ||
use Hyde\Framework\Models\BladePage; | ||
use Hyde\Framework\Models\DocumentationPage; | ||
use Hyde\Testing\TestCase; | ||
|
||
/** | ||
* @covers \Hyde\Framework\Actions\CreatesNewPageSourceFile | ||
*/ | ||
class CreatesNewPageSourceFileTest extends TestCase | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
if (file_exists(Hyde::path('_pages/682072b-test-page.md'))) { | ||
unlink(Hyde::path('_pages/682072b-test-page.md')); | ||
} | ||
|
||
if (file_exists(Hyde::path('_pages/682072b-test-page.blade.php'))) { | ||
unlink(Hyde::path('_pages/682072b-test-page.blade.php')); | ||
} | ||
|
||
parent::tearDown(); | ||
} | ||
|
||
public function test_class_can_be_instantiated() | ||
{ | ||
$this->assertInstanceOf( | ||
CreatesNewPageSourceFile::class, | ||
new CreatesNewPageSourceFile('682072b Test Page') | ||
); | ||
} | ||
|
||
public function test_that_a_slug_is_generated_from_the_title() | ||
{ | ||
$this->assertEquals( | ||
'682072b-test-page', | ||
(new CreatesNewPageSourceFile('682072b Test Page'))->slug | ||
); | ||
} | ||
|
||
public function test_that_an_exception_is_thrown_for_invalid_page_type() | ||
{ | ||
$this->expectException(UnsupportedPageTypeException::class); | ||
$this->expectExceptionMessage('The page type must be either "markdown", "blade", or "documentation"'); | ||
|
||
(new CreatesNewPageSourceFile('682072b Test Page', 'invalid')); | ||
} | ||
|
||
public function test_that_an_exception_is_thrown_if_file_already_exists_and_overwrite_is_false() | ||
{ | ||
$path = Hyde::path('_pages/foo.md'); | ||
file_put_contents($path, 'foo'); | ||
|
||
$this->expectException(FileConflictException::class); | ||
$this->expectExceptionMessage("File already exists: $path"); | ||
$this->expectExceptionCode(409); | ||
|
||
new CreatesNewPageSourceFile('foo'); | ||
|
||
unlink($path); | ||
} | ||
|
||
public function test_that_can_save_file_returns_true_if_file_already_exists_and_overwrite_is_true() | ||
{ | ||
$path = Hyde::path('_pages/foo.md'); | ||
file_put_contents($path, 'foo'); | ||
|
||
new CreatesNewPageSourceFile('foo', force: true); | ||
|
||
$this->assertTrue(true); | ||
unlink($path); | ||
} | ||
|
||
public function test_that_a_markdown_file_can_be_created_and_contains_expected_content() | ||
{ | ||
(new CreatesNewPageSourceFile('682072b Test Page')); | ||
|
||
$this->assertFileExists( | ||
Hyde::path('_pages/682072b-test-page.md') | ||
); | ||
|
||
$this->assertEquals( | ||
"---\ntitle: 682072b Test Page\n---\n\n# 682072b Test Page\n", | ||
file_get_contents(Hyde::path('_pages/682072b-test-page.md')) | ||
); | ||
} | ||
|
||
public function test_that_a_blade_file_can_be_created_and_contains_expected_content() | ||
{ | ||
(new CreatesNewPageSourceFile('682072b Test Page', BladePage::class)); | ||
|
||
$this->assertFileExists( | ||
Hyde::path('_pages/682072b-test-page.blade.php') | ||
); | ||
|
||
$fileContent = file_get_contents(Hyde::path('_pages/682072b-test-page.blade.php')); | ||
$this->assertStringContainsString( | ||
'@extends(\'hyde::layouts.app\')', | ||
$fileContent | ||
); | ||
$this->assertStringContainsString( | ||
'@php($title = "682072b Test Page")', | ||
$fileContent | ||
); | ||
$this->assertStringContainsString( | ||
'<h1 class="text-center text-3xl font-bold">682072b Test Page</h1>', | ||
$fileContent | ||
); | ||
} | ||
|
||
public function test_that_a_documentation_file_can_be_created_and_contains_expected_content() | ||
{ | ||
(new CreatesNewPageSourceFile('682072b Test Page', DocumentationPage::class)); | ||
|
||
$this->assertFileExists( | ||
Hyde::path('_docs/682072b-test-page.md') | ||
); | ||
|
||
$this->assertEquals( | ||
"# 682072b Test Page\n", | ||
file_get_contents(Hyde::path('_docs/682072b-test-page.md')) | ||
); | ||
} | ||
|
||
public function test_that_the_file_path_can_be_returned() | ||
{ | ||
$this->assertEquals( | ||
Hyde::path('_pages/682072b-test-page.md'), | ||
(new CreatesNewPageSourceFile('682072b Test Page'))->outputPath | ||
); | ||
|
||
$this->assertEquals( | ||
Hyde::path('_pages/682072b-test-page.blade.php'), | ||
(new CreatesNewPageSourceFile('682072b Test Page', BladePage::class))->outputPath | ||
); | ||
} | ||
} |
Oops, something went wrong.