From 430783fb6be46858cbfa7e7cc290d9ef2f1d2e76 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 6 Jul 2024 21:01:41 +0200 Subject: [PATCH 01/22] Begin setting up framework for running static analysis on test files --- monorepo/HydeStan/HydeStan.php | 64 +++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index 4dd8c0731e5..32c8456c55b 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -12,6 +12,7 @@ final class HydeStan const VERSION = '0.0.0-dev'; private array $files; + private array $testFiles; private array $errors = []; private int $scannedLines = 0; private int $aggregateLines = 0; @@ -40,7 +41,7 @@ public function __destruct() $this->console->info(sprintf('HydeStan has exited after scanning %s total (and %s aggregate) lines in %s files. Total expressions analysed: %s', number_format($this->scannedLines), number_format($this->aggregateLines), - number_format(count($this->files)), + number_format(count($this->files) + count($this->testFiles)), number_format(AnalysisStatisticsContainer::getExpressionsAnalysed()), )); @@ -64,6 +65,8 @@ public function run(): void $this->analyseFile($file, $this->getFileContents($file)); } + $this->runTestStan(); + $endTime = microtime(true) - $time; $this->console->info(sprintf('HydeStan has finished in %s seconds (%sms) using %s KB RAM', number_format($endTime, 2), @@ -112,6 +115,21 @@ private function getFiles(): array return $files; } + private function getTestFiles(): array + { + $files = []; + + $directory = new RecursiveDirectoryIterator(BASE_PATH.'/tests'); + $iterator = new RecursiveIteratorIterator($directory); + $regex = new RegexIterator($iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH); + + foreach ($regex as $file) { + $files[] = substr($file[0], strlen(BASE_PATH) + 1); + } + + return $files; + } + private function analyseFile(string $file, string $contents): void { $fileAnalysers = [ @@ -160,6 +178,50 @@ public static function addActionsMessage(string $level, string $file, int $lineN // $template = '::warning file={name},line={line},endLine={endLine},title={title}::{message}'; self::$warnings[] = sprintf("::$level file=%s,line=%s,endLine=%s,title=%s::%s", 'packages/framework/'.str_replace('\\', '/', $file), $lineNumber, $lineNumber, $title, $message); } + + protected function runTestStan(): void + { + $this->console->info('TestStan: Analyzing test files...'); + + $this->testFiles = $this->getTestFiles(); + + foreach ($this->testFiles as $file) { + $this->analyseTestFile($file, $this->getFileContents($file)); + } + + $this->console->info('TestStan: Finished analyzing test files!'); + } + + private function analyseTestFile(string $file, string $contents): void + { + $fileAnalysers = [ + new NoFixMeAnalyser($file, $contents), + ]; + + foreach ($fileAnalysers as $analyser) { + if ($this->debug) { + $this->console->debugComment('Running '.$analyser::class); + } + + $analyser->run($file, $contents); + AnalysisStatisticsContainer::countedLines(substr_count($contents, "\n")); + + foreach (explode("\n", $contents) as $lineNumber => $line) { + $lineAnalysers = [ + // + ]; + + foreach ($lineAnalysers as $analyser) { + AnalysisStatisticsContainer::countedLine(); + $analyser->run($file, $lineNumber, $line); + $this->aggregateLines++; + } + } + } + + $this->scannedLines += substr_count($contents, "\n"); + $this->aggregateLines += (substr_count($contents, "\n") * count($fileAnalysers)); + } } abstract class Analyser From f7e8482ba6524216f84d58c16121715d9a89e6c2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sat, 6 Jul 2024 21:05:09 +0200 Subject: [PATCH 02/22] Split out expression count to new line --- monorepo/HydeStan/HydeStan.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index 32c8456c55b..5bbdb22b220 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -38,10 +38,13 @@ public function __construct(private readonly bool $debug = false) public function __destruct() { $this->console->newline(); - $this->console->info(sprintf('HydeStan has exited after scanning %s total (and %s aggregate) lines in %s files. Total expressions analysed: %s', + $this->console->info(sprintf('HydeStan has exited after scanning %s total (and %s aggregate) lines in %s files.', number_format($this->scannedLines), number_format($this->aggregateLines), number_format(count($this->files) + count($this->testFiles)), + )); + + $this->console->info(sprintf('Total expressions analysed: %s', number_format(AnalysisStatisticsContainer::getExpressionsAnalysed()), )); From 2bf57c08b5f65405503ca25f7491191dc3f2fabf Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:40:35 +0200 Subject: [PATCH 03/22] Add analyser to check for less specific assertions --- monorepo/HydeStan/HydeStan.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index 5bbdb22b220..fa292e19294 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -199,6 +199,7 @@ private function analyseTestFile(string $file, string $contents): void { $fileAnalysers = [ new NoFixMeAnalyser($file, $contents), + new NoUsingAssertEqualsForScalarTypesTestAnalyser($file, $contents), ]; foreach ($fileAnalysers as $analyser) { @@ -280,6 +281,28 @@ public function run(string $file, string $contents): void } } +class NoUsingAssertEqualsForScalarTypesTestAnalyser extends FileAnalyser +{ + public function run(string $file, string $contents): void + { + $searches = [ + "assertEquals('", + ]; + + foreach ($searches as $search) { + AnalysisStatisticsContainer::analysedExpression(); + + if (str_contains($contents, $search)) { + // Get line number of marker by counting new \n tags before it + $stringBeforeMarker = substr($contents, 0, strpos($contents, $search)); + $lineNumber = substr_count($stringBeforeMarker, "\n") + 1; + + $this->fail(sprintf('Found %s instead assertSame for scalar type in %s on line %s', trim($search, "()'"), $file, $lineNumber)); + } + } + } +} + class UnImportedFunctionAnalyser extends FileAnalyser { public function run(string $file, string $contents): void From 811f972f84a5bef4401ad27475eaccdd6214d1a3 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:40:39 +0200 Subject: [PATCH 04/22] Add todo --- monorepo/HydeStan/HydeStan.php | 1 + 1 file changed, 1 insertion(+) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index fa292e19294..e6daa03aa8f 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -297,6 +297,7 @@ public function run(string $file, string $contents): void $stringBeforeMarker = substr($contents, 0, strpos($contents, $search)); $lineNumber = substr_count($stringBeforeMarker, "\n") + 1; + // Todo: Does not work when using objects to string cast, false positive, maybe use warning instead of fail $this->fail(sprintf('Found %s instead assertSame for scalar type in %s on line %s', trim($search, "()'"), $file, $lineNumber)); } } From 11d9ed471f505a8c4b14d32cfac6c2002d5fc7c0 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:45:50 +0200 Subject: [PATCH 05/22] Use assert same for scalar types --- .../Services/Markdown/ShortcodeProcessorTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php b/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php index 195da02b12a..df749c860da 100644 --- a/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php +++ b/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php @@ -25,7 +25,7 @@ public function testDiscoveredShortcodesAreUsedToProcessInput() { $processor = new ShortcodeProcessor('>info foo'); - $this->assertEquals('

foo

', + $this->assertSame('

foo

', $processor->run()); } @@ -33,12 +33,12 @@ public function testStringWithoutShortcodeIsNotModified() { $processor = new ShortcodeProcessor('foo'); - $this->assertEquals('foo', $processor->run()); + $this->assertSame('foo', $processor->run()); } public function testProcessStaticShorthand() { - $this->assertEquals('

foo

', + $this->assertSame('

foo

', ShortcodeProcessor::preprocess('>info foo')); } @@ -60,7 +60,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 +81,6 @@ public static function resolve(string $input): string }]); $this->assertArrayHasKey('foo', $processor->getShortcodes()); - $this->assertEquals('bar', $processor->run()); + $this->assertSame('bar', $processor->run()); } } From 24969ed01c710828f9ca06bf9c2fd272076bb6ef Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:46:13 +0200 Subject: [PATCH 06/22] Fix formatting --- .../Feature/Services/Markdown/ShortcodeProcessorTest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php b/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php index df749c860da..12660727644 100644 --- a/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php +++ b/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php @@ -25,8 +25,7 @@ public function testDiscoveredShortcodesAreUsedToProcessInput() { $processor = new ShortcodeProcessor('>info foo'); - $this->assertSame('

foo

', - $processor->run()); + $this->assertSame('

foo

', $processor->run()); } public function testStringWithoutShortcodeIsNotModified() @@ -38,8 +37,10 @@ public function testStringWithoutShortcodeIsNotModified() public function testProcessStaticShorthand() { - $this->assertSame('

foo

', - ShortcodeProcessor::preprocess('>info foo')); + $this->assertSame( + '

foo

', + ShortcodeProcessor::preprocess('>info foo') + ); } public function testShortcodesCanBeAddedToProcessor() From f6621b90671b5ca0ee5bb70c09c523dfbf73b63e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:49:56 +0200 Subject: [PATCH 07/22] Check for false positives --- monorepo/HydeStan/HydeStan.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index e6daa03aa8f..b8bf7717193 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -297,6 +297,23 @@ public function run(string $file, string $contents): void $stringBeforeMarker = substr($contents, 0, strpos($contents, $search)); $lineNumber = substr_count($stringBeforeMarker, "\n") + 1; + // Get the line contents + $line = explode("\n", $contents)[$lineNumber - 1]; + + // Check for false positives + $commonlyStringCastables = ['$article', '$document', 'getXmlElement()', '$url->loc', '$page->markdown']; + + $strContainsAny = false; + foreach ($commonlyStringCastables as $commonlyStringCastable) { + AnalysisStatisticsContainer::analysedExpression(); + if (str_contains($line, $commonlyStringCastable)) { + $strContainsAny = true; + } + } + if ($strContainsAny) { + continue; + } + // Todo: Does not work when using objects to string cast, false positive, maybe use warning instead of fail $this->fail(sprintf('Found %s instead assertSame for scalar type in %s on line %s', trim($search, "()'"), $file, $lineNumber)); } From 113ac9e38b6cf247d3d6b955c6b8dfe07ff82b72 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:50:04 +0200 Subject: [PATCH 08/22] Use assert same for scalar types --- .../framework/tests/Feature/Services/RssFeedServiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/tests/Feature/Services/RssFeedServiceTest.php b/packages/framework/tests/Feature/Services/RssFeedServiceTest.php index 832f9d2f028..3dec761d585 100644 --- a/packages/framework/tests/Feature/Services/RssFeedServiceTest.php +++ b/packages/framework/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); } From be65a4194d0078ba460af61636ac7bcde800c467 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:50:08 +0200 Subject: [PATCH 09/22] Use assert same for scalar types --- packages/framework/tests/Feature/Support/ProjectFileTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/framework/tests/Feature/Support/ProjectFileTest.php b/packages/framework/tests/Feature/Support/ProjectFileTest.php index a33c0b73bc4..66c49dd2308 100644 --- a/packages/framework/tests/Feature/Support/ProjectFileTest.php +++ b/packages/framework/tests/Feature/Support/ProjectFileTest.php @@ -28,12 +28,12 @@ public function can_make() 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() From fc935eeb9941d8002a9735a1e5b91d4454ffda82 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:50:20 +0200 Subject: [PATCH 10/22] Fix wrong test name --- packages/framework/tests/Feature/Support/ProjectFileTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/framework/tests/Feature/Support/ProjectFileTest.php b/packages/framework/tests/Feature/Support/ProjectFileTest.php index 66c49dd2308..892ae7ff4f6 100644 --- a/packages/framework/tests/Feature/Support/ProjectFileTest.php +++ b/packages/framework/tests/Feature/Support/ProjectFileTest.php @@ -21,7 +21,7 @@ public function testCanConstruct() $this->assertSame('foo', $file->path); } - public function can_make() + public function testCanMake() { $this->assertEquals(new ProjectFileTestClass('foo'), ProjectFileTestClass::make('foo')); } From acbdae74989b056297b624020bb845da1d0437a8 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:50:57 +0200 Subject: [PATCH 11/22] Use assert same for scalar types --- .../HyperlinkFileHelperRelativeLinkTest.php | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/packages/framework/tests/Unit/Foundation/HyperlinkFileHelperRelativeLinkTest.php b/packages/framework/tests/Unit/Foundation/HyperlinkFileHelperRelativeLinkTest.php index 7eabdeeb79d..5d684061b4e 100644 --- a/packages/framework/tests/Unit/Foundation/HyperlinkFileHelperRelativeLinkTest.php +++ b/packages/framework/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')); } } From 8bad56bcd1febba0c2fb18e3a1cfd212e6d8c5c2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:51:27 +0200 Subject: [PATCH 12/22] Add todo --- monorepo/HydeStan/HydeStan.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index b8bf7717193..8d45f79e4fa 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -281,7 +281,7 @@ public function run(string $file, string $contents): void } } -class NoUsingAssertEqualsForScalarTypesTestAnalyser extends FileAnalyser +class NoUsingAssertEqualsForScalarTypesTestAnalyser extends FileAnalyser // Todo: Extend line analyser instead? Would allow for checking for more errors after the first error { public function run(string $file, string $contents): void { From 47aa1f2ebf59080e07ee3e2435c4d22d50f7f176 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:52:02 +0200 Subject: [PATCH 13/22] Use assert same for scalar types --- .../HyperlinkFormatHtmlPathTest.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/framework/tests/Unit/Foundation/HyperlinkFormatHtmlPathTest.php b/packages/framework/tests/Unit/Foundation/HyperlinkFormatHtmlPathTest.php index b92c4b133fe..3151a9772bb 100644 --- a/packages/framework/tests/Unit/Foundation/HyperlinkFormatHtmlPathTest.php +++ b/packages/framework/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')); } } From 26eb24d23ae2e033cf075b70e3ab8619e0500068 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:57:00 +0200 Subject: [PATCH 14/22] Use assert same for scalar types --- .../tests/Unit/Pages/HtmlPageTest.php | 2 +- .../framework/tests/Unit/PostAuthorTest.php | 20 +++++++++---------- .../tests/Unit/Views/LinkComponentTest.php | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/framework/tests/Unit/Pages/HtmlPageTest.php b/packages/framework/tests/Unit/Pages/HtmlPageTest.php index 1551b7d23ad..f976cb444aa 100644 --- a/packages/framework/tests/Unit/Pages/HtmlPageTest.php +++ b/packages/framework/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/packages/framework/tests/Unit/PostAuthorTest.php b/packages/framework/tests/Unit/PostAuthorTest.php index 503c59f57d5..4544ff6ce57 100644 --- a/packages/framework/tests/Unit/PostAuthorTest.php +++ b/packages/framework/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/packages/framework/tests/Unit/Views/LinkComponentTest.php b/packages/framework/tests/Unit/Views/LinkComponentTest.php index edcb4c150fc..0fa639a85eb 100644 --- a/packages/framework/tests/Unit/Views/LinkComponentTest.php +++ b/packages/framework/tests/Unit/Views/LinkComponentTest.php @@ -16,13 +16,13 @@ class LinkComponentTest extends TestCase { public function testLinkComponentCanBeRendered() { - $this->assertEquals('bar', rtrim(Blade::render('bar'))); + $this->assertSame('bar', rtrim(Blade::render('bar'))); } public function testLinkComponentCanBeRenderedWithRoute() { $route = Routes::get('index'); - $this->assertEquals('bar', rtrim( + $this->assertSame('bar', rtrim( Blade::render('bar'))); } @@ -30,7 +30,7 @@ public function testLinkComponentCanBeRenderedWithRouteForNestedPages() { Render::share('routeKey', 'foo/bar'); $route = Routes::get('index'); - $this->assertEquals('bar', rtrim( + $this->assertSame('bar', rtrim( Blade::render('bar'))); } } From b72284acf4192d07d4245fa9780b9c035662f4fd Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:57:12 +0200 Subject: [PATCH 15/22] Improve test assertions --- packages/framework/tests/Unit/Pages/MarkdownPageTest.php | 5 +++-- .../framework/tests/Unit/Pages/MarkdownPostParserTest.php | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/framework/tests/Unit/Pages/MarkdownPageTest.php b/packages/framework/tests/Unit/Pages/MarkdownPageTest.php index 712ccdb84e7..ba28e199462 100644 --- a/packages/framework/tests/Unit/Pages/MarkdownPageTest.php +++ b/packages/framework/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/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php index c6b0d4f7eb8..5bbd59dc57a 100644 --- a/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php +++ b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php @@ -10,6 +10,7 @@ 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. @@ -55,8 +56,9 @@ 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')); } } From 2809f7a1f8a69d18c13399a8550d0581e0f105f2 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:57:19 +0200 Subject: [PATCH 16/22] Update ignore list --- monorepo/HydeStan/HydeStan.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index 8d45f79e4fa..ce88a8bc98f 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -301,7 +301,7 @@ public function run(string $file, string $contents): void $line = explode("\n", $contents)[$lineNumber - 1]; // Check for false positives - $commonlyStringCastables = ['$article', '$document', 'getXmlElement()', '$url->loc', '$page->markdown']; + $commonlyStringCastables = ['$article', '$document', 'getXmlElement()', '$url->loc', '$page->markdown', '$post->data(\'author\')']; $strContainsAny = false; foreach ($commonlyStringCastables as $commonlyStringCastable) { From b95d1a5d1aab30ec713badf573843bc3a2750e2e Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 10:59:31 +0200 Subject: [PATCH 17/22] Fix and normalize test code formatting --- .../Unit/Pages/MarkdownPostParserTest.php | 22 +++++++++++-------- .../tests/Unit/Views/LinkComponentTest.php | 19 +++++++++++----- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php index 5bbd59dc57a..fc487db90f3 100644 --- a/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php +++ b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php @@ -5,7 +5,6 @@ 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; @@ -21,16 +20,19 @@ protected function setUp(): void { parent::setUp(); - file_put_contents(Hyde::path('_posts/test-post.md'), '--- -title: My New Post -category: blog -author: Mr. Hyde ---- + Filesystem::putContents('_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 -'); + This is a post stub used in the automated tests + + MD + ); } protected function tearDown(): void @@ -43,6 +45,7 @@ protected function tearDown(): void 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); @@ -56,6 +59,7 @@ public function testCanParseMarkdownFile() public function testParsedMarkdownPostContainsValidFrontMatter() { $post = MarkdownPost::parse('test-post'); + $this->assertSame('My New Post', $post->data('title')); $this->assertSame('blog', $post->data('category')); $this->assertEquals('Mr. Hyde', $post->data('author')); diff --git a/packages/framework/tests/Unit/Views/LinkComponentTest.php b/packages/framework/tests/Unit/Views/LinkComponentTest.php index 0fa639a85eb..30b2b016dee 100644 --- a/packages/framework/tests/Unit/Views/LinkComponentTest.php +++ b/packages/framework/tests/Unit/Views/LinkComponentTest.php @@ -16,21 +16,30 @@ class LinkComponentTest extends TestCase { public function testLinkComponentCanBeRendered() { - $this->assertSame('bar', rtrim(Blade::render('bar'))); + $this->assertSame( + 'bar', + rtrim(Blade::render('bar')) + ); } public function testLinkComponentCanBeRenderedWithRoute() { $route = Routes::get('index'); - $this->assertSame('bar', rtrim( - Blade::render('bar'))); + + $this->assertSame( + 'bar', + rtrim(Blade::render('bar')) + ); } public function testLinkComponentCanBeRenderedWithRouteForNestedPages() { Render::share('routeKey', 'foo/bar'); $route = Routes::get('index'); - $this->assertSame('bar', rtrim( - Blade::render('bar'))); + + $this->assertSame( + 'bar', + rtrim(Blade::render('bar')) + ); } } From 73517e3595ae0fb1b9007a4b62632f4fc065edb6 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 11:00:51 +0200 Subject: [PATCH 18/22] Use filememory testing helper --- .../tests/Unit/Pages/MarkdownPostParserTest.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php index fc487db90f3..f86c4ae82cd 100644 --- a/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php +++ b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php @@ -4,7 +4,6 @@ namespace Hyde\Framework\Testing\Unit\Pages; -use Hyde\Facades\Filesystem; use Hyde\Markdown\Models\FrontMatter; use Hyde\Markdown\Models\Markdown; use Hyde\Pages\MarkdownPost; @@ -20,7 +19,7 @@ protected function setUp(): void { parent::setUp(); - Filesystem::putContents('_posts/test-post.md', <<<'MD' + $this->file('_posts/test-post.md', <<<'MD' --- title: My New Post category: blog @@ -35,13 +34,6 @@ protected function setUp(): void ); } - protected function tearDown(): void - { - Filesystem::unlink('_posts/test-post.md'); - - parent::tearDown(); - } - public function testCanParseMarkdownFile() { $post = MarkdownPost::parse('test-post'); From bd22501e05f201bbeaff72aa847b57e137baabad Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 11:01:06 +0200 Subject: [PATCH 19/22] Add code spacing --- monorepo/HydeStan/HydeStan.php | 1 + 1 file changed, 1 insertion(+) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index ce88a8bc98f..643c1c69bb7 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -310,6 +310,7 @@ public function run(string $file, string $contents): void $strContainsAny = true; } } + if ($strContainsAny) { continue; } From 1a261efb5e9d0ba881fe2fea5ddba9803a0981cb Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 11:02:25 +0200 Subject: [PATCH 20/22] Extract helper function --- monorepo/HydeStan/HydeStan.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index 643c1c69bb7..7b2069e45fe 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -303,13 +303,7 @@ public function run(string $file, string $contents): void // Check for false positives $commonlyStringCastables = ['$article', '$document', 'getXmlElement()', '$url->loc', '$page->markdown', '$post->data(\'author\')']; - $strContainsAny = false; - foreach ($commonlyStringCastables as $commonlyStringCastable) { - AnalysisStatisticsContainer::analysedExpression(); - if (str_contains($line, $commonlyStringCastable)) { - $strContainsAny = true; - } - } + $strContainsAny = check_str_contains_any($commonlyStringCastables, $line); if ($strContainsAny) { continue; @@ -426,3 +420,15 @@ public function __construct(string $file, int $lineNumber, string $line); public function run(string $file, int $lineNumber, string $line): void; } + +function check_str_contains_any(array $searches, string $line): bool +{ + $strContainsAny = false; + foreach ($searches as $search) { + AnalysisStatisticsContainer::analysedExpression(); + if (str_contains($line, $search)) { + $strContainsAny = true; + } + } + return $strContainsAny; +} From b7045f56e78a38c88d27d7fb4eb2523e643b63a4 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Sun, 7 Jul 2024 11:02:49 +0200 Subject: [PATCH 21/22] Inline local variable --- monorepo/HydeStan/HydeStan.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index 7b2069e45fe..990978b4a1b 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -303,9 +303,7 @@ public function run(string $file, string $contents): void // Check for false positives $commonlyStringCastables = ['$article', '$document', 'getXmlElement()', '$url->loc', '$page->markdown', '$post->data(\'author\')']; - $strContainsAny = check_str_contains_any($commonlyStringCastables, $line); - - if ($strContainsAny) { + if (check_str_contains_any($commonlyStringCastables, $line)) { continue; } From c1f4e67f8b17e0a1db99d87a77c2cc469ca2105a Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Sun, 7 Jul 2024 09:03:00 +0000 Subject: [PATCH 22/22] Apply fixes from StyleCI --- monorepo/HydeStan/HydeStan.php | 1 + packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/monorepo/HydeStan/HydeStan.php b/monorepo/HydeStan/HydeStan.php index 990978b4a1b..26c8f4218d6 100644 --- a/monorepo/HydeStan/HydeStan.php +++ b/monorepo/HydeStan/HydeStan.php @@ -428,5 +428,6 @@ function check_str_contains_any(array $searches, string $line): bool $strContainsAny = true; } } + return $strContainsAny; } diff --git a/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php index f86c4ae82cd..8c933156651 100644 --- a/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php +++ b/packages/framework/tests/Unit/Pages/MarkdownPostParserTest.php @@ -19,7 +19,7 @@ protected function setUp(): void { parent::setUp(); - $this->file('_posts/test-post.md', <<<'MD' + $this->file('_posts/test-post.md', <<<'MD' --- title: My New Post category: blog