diff --git a/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php b/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php index 195da02b..12660727 100644 --- a/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php +++ b/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php @@ -25,21 +25,22 @@ public function testDiscoveredShortcodesAreUsedToProcessInput() { $processor = new ShortcodeProcessor('>info foo'); - $this->assertEquals('
', - $processor->run()); + $this->assertSame('foo
', $processor->run()); } public function testStringWithoutShortcodeIsNotModified() { $processor = new ShortcodeProcessor('foo'); - $this->assertEquals('foo', $processor->run()); + $this->assertSame('foo', $processor->run()); } public function testProcessStaticShorthand() { - $this->assertEquals('foo
', - ShortcodeProcessor::preprocess('>info foo')); + $this->assertSame( + 'foo
', + ShortcodeProcessor::preprocess('>info foo') + ); } public function testShortcodesCanBeAddedToProcessor() @@ -60,7 +61,7 @@ public static function resolve(string $input): string }); $this->assertArrayHasKey('foo', $processor->getShortcodes()); - $this->assertEquals('bar', $processor->run()); + $this->assertSame('bar', $processor->run()); } public function testShortcodesCanBeAddedToProcessorUsingArray() @@ -81,6 +82,6 @@ public static function resolve(string $input): string }]); $this->assertArrayHasKey('foo', $processor->getShortcodes()); - $this->assertEquals('bar', $processor->run()); + $this->assertSame('bar', $processor->run()); } } diff --git a/tests/Feature/Services/RssFeedServiceTest.php b/tests/Feature/Services/RssFeedServiceTest.php index 832f9d2f..3dec761d 100644 --- a/tests/Feature/Services/RssFeedServiceTest.php +++ b/tests/Feature/Services/RssFeedServiceTest.php @@ -28,7 +28,7 @@ public function testServiceInstantiatesXmlElement() public function testXmlRootElementIsSetToRss20() { $service = new RssFeedGenerator(); - $this->assertEquals('rss', $service->getXmlElement()->getName()); + $this->assertSame('rss', $service->getXmlElement()->getName()); $this->assertEquals('2.0', $service->getXmlElement()->attributes()->version); } diff --git a/tests/Feature/Support/ProjectFileTest.php b/tests/Feature/Support/ProjectFileTest.php index a33c0b73..892ae7ff 100644 --- a/tests/Feature/Support/ProjectFileTest.php +++ b/tests/Feature/Support/ProjectFileTest.php @@ -21,19 +21,19 @@ public function testCanConstruct() $this->assertSame('foo', $file->path); } - public function can_make() + public function testCanMake() { $this->assertEquals(new ProjectFileTestClass('foo'), ProjectFileTestClass::make('foo')); } public function testCanConstructWithNestedPaths() { - $this->assertEquals('path/to/file.txt', ProjectFileTestClass::make('path/to/file.txt')->path); + $this->assertSame('path/to/file.txt', ProjectFileTestClass::make('path/to/file.txt')->path); } public function testAbsolutePathIsNormalizedToRelative() { - $this->assertEquals('foo', ProjectFileTestClass::make(Hyde::path('foo'))->path); + $this->assertSame('foo', ProjectFileTestClass::make(Hyde::path('foo'))->path); } public function testGetNameReturnsNameOfFile() diff --git a/tests/Unit/Foundation/HyperlinkFileHelperRelativeLinkTest.php b/tests/Unit/Foundation/HyperlinkFileHelperRelativeLinkTest.php index 7eabdeeb..5d684061 100644 --- a/tests/Unit/Foundation/HyperlinkFileHelperRelativeLinkTest.php +++ b/tests/Unit/Foundation/HyperlinkFileHelperRelativeLinkTest.php @@ -31,126 +31,126 @@ protected function setUp(): void public function testHelperReturnsStringAsIsIfCurrentIsNotSet() { - $this->assertEquals('foo/bar.html', Hyde::relativeLink('foo/bar.html')); + $this->assertSame('foo/bar.html', Hyde::relativeLink('foo/bar.html')); } public function testHelperInjectsProperNumberOfDoublesSlash() { $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../foo.html', Hyde::relativeLink('foo.html')); + $this->assertSame('../foo.html', Hyde::relativeLink('foo.html')); } public function testHelperInjectsProperNumberOfDoublesSlashForDeeplyNestedPaths() { $this->mockCurrentPage('foo/bar/baz/qux.html'); - $this->assertEquals('../../../foo.html', Hyde::relativeLink('foo.html')); + $this->assertSame('../../../foo.html', Hyde::relativeLink('foo.html')); } public function testHelperHandlesDestinationWithoutFileExtension() { $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../foo', Hyde::relativeLink('foo')); + $this->assertSame('../foo', Hyde::relativeLink('foo')); } public function testHelperHandlesCurrentWithoutFileExtension() { $this->mockCurrentPage('foo/bar'); - $this->assertEquals('../foo.html', Hyde::relativeLink('foo.html')); + $this->assertSame('../foo.html', Hyde::relativeLink('foo.html')); } public function testHelperHandlesCaseWithoutAnyFileExtensions() { $this->mockCurrentPage('foo/bar'); - $this->assertEquals('../foo', Hyde::relativeLink('foo')); + $this->assertSame('../foo', Hyde::relativeLink('foo')); } public function testHelperHandlesCaseWithMixedFileExtensions() { $this->mockCurrentPage('foo/bar.md'); - $this->assertEquals('../foo.md', Hyde::relativeLink('foo.md')); + $this->assertSame('../foo.md', Hyde::relativeLink('foo.md')); $this->mockCurrentPage('foo/bar.txt'); - $this->assertEquals('../foo.txt', Hyde::relativeLink('foo.txt')); + $this->assertSame('../foo.txt', Hyde::relativeLink('foo.txt')); } public function testHelperHandlesDifferentFileExtensions() { $this->mockCurrentPage('foo/bar'); - $this->assertEquals('../foo.png', Hyde::relativeLink('foo.png')); - $this->assertEquals('../foo.css', Hyde::relativeLink('foo.css')); - $this->assertEquals('../foo.js', Hyde::relativeLink('foo.js')); + $this->assertSame('../foo.png', Hyde::relativeLink('foo.png')); + $this->assertSame('../foo.css', Hyde::relativeLink('foo.css')); + $this->assertSame('../foo.js', Hyde::relativeLink('foo.js')); } public function testHelperReturnsPrettyUrlIfEnabledAndDestinationIsAHtmlFile() { self::mockConfig(['hyde.pretty_urls' => true]); $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../foo', Hyde::relativeLink('foo.html')); + $this->assertSame('../foo', Hyde::relativeLink('foo.html')); } public function testHelperMethodDoesNotRequireCurrentPathToBeHtmlToUsePrettyUrls() { self::mockConfig(['hyde.pretty_urls' => true]); $this->mockCurrentPage('foo/bar'); - $this->assertEquals('../foo', Hyde::relativeLink('foo.html')); + $this->assertSame('../foo', Hyde::relativeLink('foo.html')); } public function testHelperReturnsDoesNotReturnPrettyUrlIfWhenEnabledButAndDestinationIsNotAHtmlFile() { self::mockConfig(['hyde.pretty_urls' => true]); $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../foo.png', Hyde::relativeLink('foo.png')); + $this->assertSame('../foo.png', Hyde::relativeLink('foo.png')); } public function testHelperRewritesIndexWhenUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => true]); $this->mockCurrentPage('foo.html'); - $this->assertEquals('./', Hyde::relativeLink('index.html')); + $this->assertSame('./', Hyde::relativeLink('index.html')); $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../', Hyde::relativeLink('index.html')); + $this->assertSame('../', Hyde::relativeLink('index.html')); $this->mockCurrentPage('foo/bar/baz.html'); - $this->assertEquals('../../', Hyde::relativeLink('index.html')); + $this->assertSame('../../', Hyde::relativeLink('index.html')); } public function testHelperDoesNotRewriteIndexWhenNotUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => false]); $this->mockCurrentPage('foo.html'); - $this->assertEquals('index.html', Hyde::relativeLink('index.html')); + $this->assertSame('index.html', Hyde::relativeLink('index.html')); $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../index.html', Hyde::relativeLink('index.html')); + $this->assertSame('../index.html', Hyde::relativeLink('index.html')); $this->mockCurrentPage('foo/bar/baz.html'); - $this->assertEquals('../../index.html', Hyde::relativeLink('index.html')); + $this->assertSame('../../index.html', Hyde::relativeLink('index.html')); } public function testHelperRewritesDocumentationPageIndexWhenUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => true]); $this->mockCurrentPage('foo.html'); - $this->assertEquals('docs/', Hyde::relativeLink('docs/index.html')); + $this->assertSame('docs/', Hyde::relativeLink('docs/index.html')); $this->mockCurrentPage('docs.html'); - $this->assertEquals('docs/', Hyde::relativeLink('docs/index.html')); + $this->assertSame('docs/', Hyde::relativeLink('docs/index.html')); $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../docs/', Hyde::relativeLink('docs/index.html')); + $this->assertSame('../docs/', Hyde::relativeLink('docs/index.html')); $this->mockCurrentPage('docs/foo.html'); - $this->assertEquals('../docs/', Hyde::relativeLink('docs/index.html')); + $this->assertSame('../docs/', Hyde::relativeLink('docs/index.html')); } public function testHelperDoesNotRewriteDocumentationPageIndexWhenNotUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => false]); $this->mockCurrentPage('foo.html'); - $this->assertEquals('docs/index.html', Hyde::relativeLink('docs/index.html')); + $this->assertSame('docs/index.html', Hyde::relativeLink('docs/index.html')); $this->mockCurrentPage('docs.html'); - $this->assertEquals('docs/index.html', Hyde::relativeLink('docs/index.html')); + $this->assertSame('docs/index.html', Hyde::relativeLink('docs/index.html')); $this->mockCurrentPage('foo/bar.html'); - $this->assertEquals('../docs/index.html', Hyde::relativeLink('docs/index.html')); + $this->assertSame('../docs/index.html', Hyde::relativeLink('docs/index.html')); $this->mockCurrentPage('docs/foo.html'); - $this->assertEquals('../docs/index.html', Hyde::relativeLink('docs/index.html')); + $this->assertSame('../docs/index.html', Hyde::relativeLink('docs/index.html')); } public function testHelperDoesNotRewriteAlreadyProcessedLinks() { - $this->assertEquals('../foo', Hyde::relativeLink('../foo')); + $this->assertSame('../foo', Hyde::relativeLink('../foo')); } } diff --git a/tests/Unit/Foundation/HyperlinkFormatHtmlPathTest.php b/tests/Unit/Foundation/HyperlinkFormatHtmlPathTest.php index b92c4b13..3151a977 100644 --- a/tests/Unit/Foundation/HyperlinkFormatHtmlPathTest.php +++ b/tests/Unit/Foundation/HyperlinkFormatHtmlPathTest.php @@ -19,85 +19,85 @@ public function testHelperReturnsStringAsIsIfPrettyUrlsIsNotTrue() { self::mockConfig(['hyde.pretty_urls' => false]); - $this->assertEquals('foo/bar.html', Hyde::formatLink('foo/bar.html')); + $this->assertSame('foo/bar.html', Hyde::formatLink('foo/bar.html')); } public function testHelperReturnsPrettyUrlIfPrettyUrlsIsTrue() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('foo/bar', Hyde::formatLink('foo/bar.html')); + $this->assertSame('foo/bar', Hyde::formatLink('foo/bar.html')); } public function testHelperRespectsAbsoluteUrls() { self::mockConfig(['hyde.pretty_urls' => false]); - $this->assertEquals('/foo/bar.html', Hyde::formatLink('/foo/bar.html')); + $this->assertSame('/foo/bar.html', Hyde::formatLink('/foo/bar.html')); } public function testHelperRespectsPrettyAbsoluteUrls() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('/foo/bar', Hyde::formatLink('/foo/bar.html')); + $this->assertSame('/foo/bar', Hyde::formatLink('/foo/bar.html')); } public function testHelperRespectsRelativeUrls() { self::mockConfig(['hyde.pretty_urls' => false]); - $this->assertEquals('../foo/bar.html', Hyde::formatLink('../foo/bar.html')); + $this->assertSame('../foo/bar.html', Hyde::formatLink('../foo/bar.html')); } public function testHelperRespectsPrettyRelativeUrls() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('../foo/bar', Hyde::formatLink('../foo/bar.html')); + $this->assertSame('../foo/bar', Hyde::formatLink('../foo/bar.html')); } public function testNonHtmlLinksAreNotModified() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('/foo/bar.jpg', Hyde::formatLink('/foo/bar.jpg')); + $this->assertSame('/foo/bar.jpg', Hyde::formatLink('/foo/bar.jpg')); } public function testHelperRespectsAbsoluteUrlsWithPrettyUrlsEnabled() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('/foo/bar.jpg', Hyde::formatLink('/foo/bar.jpg')); + $this->assertSame('/foo/bar.jpg', Hyde::formatLink('/foo/bar.jpg')); } public function testHelperRewritesIndexWhenUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('/', Hyde::formatLink('index.html')); + $this->assertSame('/', Hyde::formatLink('index.html')); } public function testHelperDoesNotRewriteIndexWhenNotUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => false]); - $this->assertEquals('index.html', Hyde::formatLink('index.html')); + $this->assertSame('index.html', Hyde::formatLink('index.html')); } public function testHelperRewritesDocumentationPageIndexWhenUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('docs/', Hyde::formatLink('docs/index.html')); + $this->assertSame('docs/', Hyde::formatLink('docs/index.html')); } public function testHelperDoesNotRewriteDocumentationPageIndexWhenNotUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => false]); - $this->assertEquals('docs/index.html', Hyde::formatLink('docs/index.html')); + $this->assertSame('docs/index.html', Hyde::formatLink('docs/index.html')); } public function testHelpersRewritesArbitraryNestedIndexPagesWhenUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => true]); - $this->assertEquals('foo/bar/', Hyde::formatLink('foo/bar/index.html')); + $this->assertSame('foo/bar/', Hyde::formatLink('foo/bar/index.html')); } public function testHelpersDoesNotRewriteArbitraryNestedIndexPagesWhenNotUsingPrettyUrls() { self::mockConfig(['hyde.pretty_urls' => false]); - $this->assertEquals('foo/bar/index.html', Hyde::formatLink('foo/bar/index.html')); + $this->assertSame('foo/bar/index.html', Hyde::formatLink('foo/bar/index.html')); } } diff --git a/tests/Unit/Pages/HtmlPageTest.php b/tests/Unit/Pages/HtmlPageTest.php index 1551b7d2..f976cb44 100644 --- a/tests/Unit/Pages/HtmlPageTest.php +++ b/tests/Unit/Pages/HtmlPageTest.php @@ -18,7 +18,7 @@ public function testHtmlPageCanBeCompiled() $page = new HtmlPage('foo'); - $this->assertEquals('bar', $page->compile()); + $this->assertSame('bar', $page->compile()); } public function testCompileMethodUsesContents() diff --git a/tests/Unit/Pages/MarkdownPageTest.php b/tests/Unit/Pages/MarkdownPageTest.php index 712ccdb8..ba28e199 100644 --- a/tests/Unit/Pages/MarkdownPageTest.php +++ b/tests/Unit/Pages/MarkdownPageTest.php @@ -27,9 +27,10 @@ public function testCreatedModelContainsExpectedData() $this->file('_pages/test-page.md', "# Test Page \n Hello World!"); $page = MarkdownPage::parse('test-page'); - $this->assertEquals('Test Page', $page->title); + $this->assertSame('Test Page', $page->title); + $this->assertSame('test-page', $page->identifier); + $this->assertSame("# Test Page \n Hello World!", $page->markdown->body()); $this->assertEquals("# Test Page \n Hello World!", $page->markdown); - $this->assertEquals('test-page', $page->identifier); } public function testCanRenderMarkdownPage() diff --git a/tests/Unit/Pages/MarkdownPostParserTest.php b/tests/Unit/Pages/MarkdownPostParserTest.php index c6b0d4f7..8c933156 100644 --- a/tests/Unit/Pages/MarkdownPostParserTest.php +++ b/tests/Unit/Pages/MarkdownPostParserTest.php @@ -4,12 +4,11 @@ namespace Hyde\Framework\Testing\Unit\Pages; -use Hyde\Facades\Filesystem; -use Hyde\Hyde; use Hyde\Markdown\Models\FrontMatter; use Hyde\Markdown\Models\Markdown; use Hyde\Pages\MarkdownPost; use Hyde\Testing\TestCase; +use Hyde\Framework\Features\Blogging\Models\PostAuthor; /** * @see \Hyde\Framework\Testing\Feature\StaticSiteBuilderPostModuleTest for the compiler test. @@ -20,28 +19,25 @@ protected function setUp(): void { parent::setUp(); - file_put_contents(Hyde::path('_posts/test-post.md'), '--- -title: My New Post -category: blog -author: Mr. Hyde ---- + $this->file('_posts/test-post.md', <<<'MD' + --- + title: My New Post + category: blog + author: Mr. Hyde + --- -# My New Post + # My New Post -This is a post stub used in the automated tests -'); - } - - protected function tearDown(): void - { - Filesystem::unlink('_posts/test-post.md'); + This is a post stub used in the automated tests - parent::tearDown(); + MD + ); } public function testCanParseMarkdownFile() { $post = MarkdownPost::parse('test-post'); + $this->assertInstanceOf(MarkdownPost::class, $post); $this->assertCount(3, $post->matter->toArray()); $this->assertInstanceOf(FrontMatter::class, $post->matter); @@ -55,8 +51,10 @@ public function testCanParseMarkdownFile() public function testParsedMarkdownPostContainsValidFrontMatter() { $post = MarkdownPost::parse('test-post'); - $this->assertEquals('My New Post', $post->data('title')); + + $this->assertSame('My New Post', $post->data('title')); + $this->assertSame('blog', $post->data('category')); $this->assertEquals('Mr. Hyde', $post->data('author')); - $this->assertEquals('blog', $post->data('category')); + $this->assertInstanceOf(PostAuthor::class, $post->data('author')); } } diff --git a/tests/Unit/PostAuthorTest.php b/tests/Unit/PostAuthorTest.php index 503c59f5..4544ff6c 100644 --- a/tests/Unit/PostAuthorTest.php +++ b/tests/Unit/PostAuthorTest.php @@ -29,9 +29,9 @@ public function testCreateMethodAcceptsAllParameters() { $author = Author::create('foo', 'bar', 'https://example.com'); - $this->assertEquals('foo', $author->username); - $this->assertEquals('bar', $author->name); - $this->assertEquals('https://example.com', $author->website); + $this->assertSame('foo', $author->username); + $this->assertSame('bar', $author->name); + $this->assertSame('https://example.com', $author->website); } public function testGetOrCreateMethodCreatesNewAuthorModelFromString() @@ -107,8 +107,8 @@ public function testGetMethodReturnsConfigDefinedAuthorByUsername() $author = PostAuthor::get('foo'); $this->assertInstanceOf(PostAuthor::class, $author); - $this->assertEquals('foo', $author->username); - $this->assertEquals('bar', $author->name); + $this->assertSame('foo', $author->username); + $this->assertSame('bar', $author->name); } public function testGetMethodReturnsNewAuthorIfUsernameNotFoundInConfig() @@ -117,34 +117,34 @@ public function testGetMethodReturnsNewAuthorIfUsernameNotFoundInConfig() $author = PostAuthor::get('foo'); $this->assertInstanceOf(PostAuthor::class, $author); - $this->assertEquals('foo', $author->username); + $this->assertSame('foo', $author->username); } public function testGetNameHelperReturnsNameIfSet() { $author = new PostAuthor('username', 'John Doe'); - $this->assertEquals('John Doe', $author->getName()); + $this->assertSame('John Doe', $author->getName()); } public function testGetNameHelperReturnsUsernameIfNameIsNotSet() { $author = new PostAuthor('username'); - $this->assertEquals('username', $author->getName()); + $this->assertSame('username', $author->getName()); } public function testNameIsSetToUsernameIfNameIsNotSet() { $author = new PostAuthor('username'); - $this->assertEquals('username', $author->name); + $this->assertSame('username', $author->name); } public function testToStringHelperReturnsTheName() { $author = new PostAuthor('username', 'John Doe'); - $this->assertEquals('John Doe', (string) $author); + $this->assertSame('John Doe', (string) $author); } } diff --git a/tests/Unit/Views/LinkComponentTest.php b/tests/Unit/Views/LinkComponentTest.php index edcb4c15..30b2b016 100644 --- a/tests/Unit/Views/LinkComponentTest.php +++ b/tests/Unit/Views/LinkComponentTest.php @@ -16,21 +16,30 @@ class LinkComponentTest extends TestCase { public function testLinkComponentCanBeRendered() { - $this->assertEquals('bar', rtrim(Blade::render('foo