Skip to content

Commit

Permalink
Merge pull request #1556 from hydephp/test-code-cleanup
Browse files Browse the repository at this point in the history
Rename snake case test methods to be camel case hydephp/develop@e35bad0
  • Loading branch information
github-actions committed Feb 12, 2024
1 parent 23b1e0a commit 04b56f8
Show file tree
Hide file tree
Showing 125 changed files with 1,149 additions and 1,149 deletions.
30 changes: 15 additions & 15 deletions tests/Feature/Actions/CreatesNewPageSourceFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
*/
class CreatesNewPageSourceFileTest extends TestCase
{
public function test_class_can_be_instantiated()
public function testClassCanBeInstantiated()
{
$this->assertInstanceOf(
CreatesNewPageSourceFile::class,
new CreatesNewPageSourceFile('Test Page')
);
}

public function test_that_an_exception_is_thrown_for_invalid_page_type()
public function testThatAnExceptionIsThrownForInvalidPageType()
{
$this->expectException(UnsupportedPageTypeException::class);
$this->expectExceptionMessage('The page type must be either "markdown", "blade", or "documentation"');

(new CreatesNewPageSourceFile('Test Page', 'invalid'))->save();
}

public function test_that_an_exception_is_thrown_if_file_already_exists_and_overwrite_is_false()
public function testThatAnExceptionIsThrownIfFileAlreadyExistsAndOverwriteIsFalse()
{
$this->file('_pages/foo.md', 'foo');

Expand All @@ -47,7 +47,7 @@ public function test_that_an_exception_is_thrown_if_file_already_exists_and_over
Filesystem::unlink('_pages/foo.md');
}

public function test_that_can_save_file_returns_true_if_file_already_exists_and_overwrite_is_true()
public function testThatCanSaveFileReturnsTrueIfFileAlreadyExistsAndOverwriteIsTrue()
{
$this->file('_pages/foo.md', 'foo');

Expand All @@ -56,7 +56,7 @@ public function test_that_can_save_file_returns_true_if_file_already_exists_and_
Filesystem::unlink('_pages/foo.md');
}

public function test_exception_is_thrown_for_conflicting_blade_pages()
public function testExceptionIsThrownForConflictingBladePages()
{
$this->file('_pages/foo.blade.php', 'foo');

Expand All @@ -69,7 +69,7 @@ public function test_exception_is_thrown_for_conflicting_blade_pages()
Filesystem::unlink('_pages/foo.blade.php');
}

public function test_exception_is_thrown_for_conflicting_documentation_pages()
public function testExceptionIsThrownForConflictingDocumentationPages()
{
$this->file('_docs/foo.md', 'foo');

Expand All @@ -82,7 +82,7 @@ public function test_exception_is_thrown_for_conflicting_documentation_pages()
Filesystem::unlink('_docs/foo.md');
}

public function test_that_a_markdown_file_can_be_created_and_contains_expected_content()
public function testThatAMarkdownFileCanBeCreatedAndContainsExpectedContent()
{
(new CreatesNewPageSourceFile('Test Page'))->save();

Expand All @@ -95,7 +95,7 @@ public function test_that_a_markdown_file_can_be_created_and_contains_expected_c
Filesystem::unlink('_pages/test-page.md');
}

public function test_that_a_blade_file_can_be_created_and_contains_expected_content()
public function testThatABladeFileCanBeCreatedAndContainsExpectedContent()
{
(new CreatesNewPageSourceFile('Test Page', BladePage::class))->save();

Expand All @@ -119,7 +119,7 @@ public function test_that_a_blade_file_can_be_created_and_contains_expected_cont
Filesystem::unlink('_pages/test-page.blade.php');
}

public function test_that_a_documentation_file_can_be_created_and_contains_expected_content()
public function testThatADocumentationFileCanBeCreatedAndContainsExpectedContent()
{
(new CreatesNewPageSourceFile('Test Page', DocumentationPage::class))->save();

Expand All @@ -133,7 +133,7 @@ public function test_that_a_documentation_file_can_be_created_and_contains_expec
Filesystem::unlink('_docs/test-page.md');
}

public function test_that_a_markdown_file_can_be_created_with_custom_content()
public function testThatAMarkdownFileCanBeCreatedWithCustomContent()
{
(new CreatesNewPageSourceFile('Test Page', customContent: 'Hello World!'))->save();

Expand All @@ -156,7 +156,7 @@ public function test_that_a_markdown_file_can_be_created_with_custom_content()
Filesystem::unlink('_pages/test-page.md');
}

public function test_that_a_blade_file_can_be_created_with_custom_content()
public function testThatABladeFileCanBeCreatedWithCustomContent()
{
(new CreatesNewPageSourceFile('Test Page', BladePage::class, customContent: 'Hello World!'))->save();

Expand Down Expand Up @@ -184,7 +184,7 @@ public function test_that_a_blade_file_can_be_created_with_custom_content()
Filesystem::unlink('_pages/test-page.blade.php');
}

public function test_that_the_file_path_can_be_returned()
public function testThatTheFilePathCanBeReturned()
{
$this->assertSame(
Hyde::path('_pages/test-page.md'),
Expand All @@ -200,21 +200,21 @@ public function test_that_the_file_path_can_be_returned()
Filesystem::unlink('_pages/test-page.blade.php');
}

public function test_file_is_created_using_slug_generated_from_title()
public function testFileIsCreatedUsingSlugGeneratedFromTitle()
{
(new CreatesNewPageSourceFile('Foo Bar'))->save();
$this->assertFileExists(Hyde::path('_pages/foo-bar.md'));
Filesystem::unlink('_pages/foo-bar.md');
}

public function test_action_can_generate_nested_pages()
public function testActionCanGenerateNestedPages()
{
(new CreatesNewPageSourceFile('foo/bar'))->save();
$this->assertFileExists(Hyde::path('_pages/foo/bar.md'));
Filesystem::deleteDirectory('_pages/foo');
}

public function test_can_create_deeply_nested_pages()
public function testCanCreateDeeplyNestedPages()
{
(new CreatesNewPageSourceFile('/foo/bar/Foo Bar'))->save();
$this->assertFileExists(Hyde::path('_pages/foo/bar/foo-bar.md'));
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/AssetServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
*/
class AssetServiceTest extends TestCase
{
public function test_media_link_returns_media_path_with_cache_key()
public function testMediaLinkReturnsMediaPathWithCacheKey()
{
$service = new AssetService();
$this->assertIsString($path = $service->mediaLink('app.css'));
$this->assertEquals('media/app.css?v='.md5_file(Hyde::path('_media/app.css')), $path);
}

public function test_media_link_returns_media_path_without_cache_key_if_cache_busting_is_disabled()
public function testMediaLinkReturnsMediaPathWithoutCacheKeyIfCacheBustingIsDisabled()
{
config(['hyde.enable_cache_busting' => false]);
$service = new AssetService();
$this->assertIsString($path = $service->mediaLink('app.css'));
$this->assertEquals('media/app.css', $path);
}

public function test_media_link_supports_custom_media_directories()
public function testMediaLinkSupportsCustomMediaDirectories()
{
$this->directory('_assets');
$this->file('_assets/app.css');
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/AuthorPostsIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected function setUp(): void
* Check that the author was not defined.
* We do this by building the static site and inspecting the DOM.
*/
public function test_create_post_with_undefined_author()
public function testCreatePostWithUndefinedAuthor()
{
// Create a new post
(new CreatesNewMarkdownPostFile(
Expand Down Expand Up @@ -66,7 +66,7 @@ public function test_create_post_with_undefined_author()
/**
* Test that a defined author has its name injected into the DOM.
*/
public function test_create_post_with_defined_author_with_name()
public function testCreatePostWithDefinedAuthorWithName()
{
// Create a new post
(new CreatesNewMarkdownPostFile(
Expand Down Expand Up @@ -104,7 +104,7 @@ public function test_create_post_with_defined_author_with_name()
/**
* Test that a defined author with website has its site linked.
*/
public function test_create_post_with_defined_author_with_website()
public function testCreatePostWithDefinedAuthorWithWebsite()
{
// Create a new post
(new CreatesNewMarkdownPostFile(
Expand Down
30 changes: 15 additions & 15 deletions tests/Feature/BladeMatterParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
*/
class BladeMatterParserTest extends TestCase
{
public function test_can_parse_front_matter()
public function testCanParseFrontMatter()
{
$parser = new BladeMatterParser('@php($foo = "bar")');
$parser->parse();
$this->assertEquals(['foo' => 'bar'], $parser->get());
}

public function test_parse_string_helper_method()
public function testParseStringHelperMethod()
{
$this->assertSame(
(new BladeMatterParser('foo'))->parse()->get(),
BladeMatterParser::parseString('foo')
);
}

public function test_parse_file_helper_method()
public function testParseFileHelperMethod()
{
$this->file('foo', 'foo');
$this->assertSame(
Expand All @@ -37,7 +37,7 @@ public function test_parse_file_helper_method()
);
}

public function test_can_parse_multiple_front_matter_lines()
public function testCanParseMultipleFrontMatterLines()
{
$document = <<<'BLADE'
@php($foo = 'bar')
Expand All @@ -47,7 +47,7 @@ public function test_can_parse_multiple_front_matter_lines()
$this->assertEquals(['foo' => 'bar', 'bar' => 'baz', 'baz' => 'qux'], BladeMatterParser::parseString($document));
}

public function test_can_parse_front_matter_with_various_formats()
public function testCanParseFrontMatterWithVariousFormats()
{
$matrix = [
'@php($foo = "bar")' => ['foo' => 'bar'],
Expand All @@ -61,41 +61,41 @@ public function test_can_parse_front_matter_with_various_formats()
}
}

public function test_can_parse_front_matter_with_array()
public function testCanParseFrontMatterWithArray()
{
$document = "@php(\$foo = ['bar' => 'baz'])";
$this->assertEquals(['foo' => ['bar' => 'baz']], BladeMatterParser::parseString($document));
}

public function test_line_matches_front_matter()
public function testLineMatchesFrontMatter()
{
$this->assertTrue(ParserTestClass::lineMatchesFrontMatter('@php($foo = "bar")'));
$this->assertFalse(ParserTestClass::lineMatchesFrontMatter('foo bar'));
}

public function test_directive_cannot_have_leading_whitespace()
public function testDirectiveCannotHaveLeadingWhitespace()
{
$this->assertFalse(ParserTestClass::lineMatchesFrontMatter(' @php($foo = "bar")'));
}

public function test_directive_signature_cannot_contain_whitespace()
public function testDirectiveSignatureCannotContainWhitespace()
{
$this->assertFalse(ParserTestClass::lineMatchesFrontMatter('@php( $foo = "bar")'));
$this->assertFalse(ParserTestClass::lineMatchesFrontMatter('@ php($foo = "bar")'));
$this->assertFalse(ParserTestClass::lineMatchesFrontMatter('@ php ($foo = "bar")'));
}

public function test_extract_key()
public function testExtractKey()
{
$this->assertSame('foo', ParserTestClass::extractKey('@php($foo = "bar")'));
}

public function test_extract_value()
public function testExtractValue()
{
$this->assertSame('bar', ParserTestClass::extractValue('@php($foo = "bar")'));
}

public function test_get_value_with_type()
public function testGetValueWithType()
{
$this->assertSame('string', ParserTestClass::getValueWithType('string'));
$this->assertSame('string', ParserTestClass::getValueWithType('string'));
Expand All @@ -110,7 +110,7 @@ public function test_get_value_with_type()
$this->assertSame(['foo' => 'bar'], ParserTestClass::getValueWithType("['foo' => 'bar']"));
}

public function test_parse_array_string()
public function testParseArrayString()
{
$this->assertSame(['foo' => 'bar'], ParserTestClass::parseArrayString('["foo" => "bar"]'));
$this->assertSame(['foo' => 'bar'], ParserTestClass::parseArrayString('["foo" => "bar"]'));
Expand All @@ -123,13 +123,13 @@ public function test_parse_array_string()
$this->assertSame(['foo' => 1], ParserTestClass::parseArrayString('["foo" => 1]'));
}

public function test_parse_invalid_array_string()
public function testParseInvalidArrayString()
{
$this->expectException(RuntimeException::class);
ParserTestClass::parseArrayString('foo');
}

public function test_parse_multidimensional_array_string()
public function testParseMultidimensionalArrayString()
{
$this->expectException(RuntimeException::class);
ParserTestClass::parseArrayString('["foo" => ["bar" => "baz"]]');
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/Commands/BuildRssFeedCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
class BuildRssFeedCommandTest extends TestCase
{
public function test_rss_feed_is_generated_when_conditions_are_met()
public function testRssFeedIsGeneratedWhenConditionsAreMet()
{
config(['hyde.url' => 'https://example.com']);
config(['hyde.rss.enabled' => true]);
Expand All @@ -27,7 +27,7 @@ public function test_rss_feed_is_generated_when_conditions_are_met()
Filesystem::unlink('_site/feed.xml');
}

public function test_rss_filename_can_be_changed()
public function testRssFilenameCanBeChanged()
{
config(['hyde.url' => 'https://example.com']);
config(['hyde.rss.enabled' => true]);
Expand Down
16 changes: 8 additions & 8 deletions tests/Feature/Commands/BuildSearchCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class BuildSearchCommandTest extends TestCase
{
public function test_it_creates_the_search_json_file()
public function testItCreatesTheSearchJsonFile()
{
$this->assertFileDoesNotExist(Hyde::path('_site/docs/search.json'));

Expand All @@ -27,7 +27,7 @@ public function test_it_creates_the_search_json_file()
Filesystem::unlink('_site/docs/search.html');
}

public function test_it_creates_the_search_page()
public function testItCreatesTheSearchPage()
{
$this->assertFileDoesNotExist(Hyde::path('_site/docs/search.html'));

Expand All @@ -38,7 +38,7 @@ public function test_it_creates_the_search_page()
Filesystem::unlink('_site/docs/search.html');
}

public function test_it_does_not_create_the_search_page_if_disabled()
public function testItDoesNotCreateTheSearchPageIfDisabled()
{
config(['docs.create_search_page' => false]);

Expand All @@ -48,7 +48,7 @@ public function test_it_does_not_create_the_search_page_if_disabled()
Filesystem::unlink('_site/docs/search.json');
}

public function test_it_does_not_display_the_estimation_message_when_it_is_less_than_1_second()
public function testItDoesNotDisplayTheEstimationMessageWhenItIsLessThan1Second()
{
$this->artisan('build:search')
->doesntExpectOutputToContain('> This will take an estimated')
Expand All @@ -58,7 +58,7 @@ public function test_it_does_not_display_the_estimation_message_when_it_is_less_
Filesystem::unlink('_site/docs/search.html');
}

public function test_search_files_can_be_generated_for_custom_docs_output_directory()
public function testSearchFilesCanBeGeneratedForCustomDocsOutputDirectory()
{
DocumentationPage::setOutputDirectory('foo');

Expand All @@ -69,7 +69,7 @@ public function test_search_files_can_be_generated_for_custom_docs_output_direct
Filesystem::deleteDirectory('_site/foo');
}

public function test_search_files_can_be_generated_for_custom_site_output_directory()
public function testSearchFilesCanBeGeneratedForCustomSiteOutputDirectory()
{
Hyde::setOutputDirectory('foo');

Expand All @@ -80,7 +80,7 @@ public function test_search_files_can_be_generated_for_custom_site_output_direct
Filesystem::deleteDirectory('foo');
}

public function test_search_files_can_be_generated_for_custom_site_and_docs_output_directories()
public function testSearchFilesCanBeGeneratedForCustomSiteAndDocsOutputDirectories()
{
Hyde::setOutputDirectory('foo');
DocumentationPage::setOutputDirectory('bar');
Expand All @@ -92,7 +92,7 @@ public function test_search_files_can_be_generated_for_custom_site_and_docs_outp
Filesystem::deleteDirectory('foo');
}

public function test_search_files_can_be_generated_for_custom_site_and_nested_docs_output_directories()
public function testSearchFilesCanBeGeneratedForCustomSiteAndNestedDocsOutputDirectories()
{
Hyde::setOutputDirectory('foo/bar');
DocumentationPage::setOutputDirectory('baz');
Expand Down
Loading

0 comments on commit 04b56f8

Please sign in to comment.