diff --git a/src/Reporting/Rules/NoUnderscoresInUrl.php b/src/Reporting/Rules/NoUnderscoresInUrl.php index eedd2a52..c79e4116 100644 --- a/src/Reporting/Rules/NoUnderscoresInUrl.php +++ b/src/Reporting/Rules/NoUnderscoresInUrl.php @@ -7,6 +7,7 @@ class NoUnderscoresInUrl extends Rule { + use Concerns\DeductsPointsForFailingPages; use Concerns\FailsWhenPagesDontPass; protected $passes; @@ -35,6 +36,11 @@ public function siteFailingComment() ); } + protected function points() + { + return 1; + } + public function processPage() { $this->passes = ! Str::contains($this->page->url(), '_'); diff --git a/tests/ReportTest.php b/tests/ReportTest.php index 6bfc8ff2..df384a9c 100644 --- a/tests/ReportTest.php +++ b/tests/ReportTest.php @@ -83,7 +83,7 @@ public function it_can_generate_a_report() $expected = <<<"EXPECTED" date: $now->timestamp status: fail -score: 83.0 +score: 86.0 pages_crawled: 10 pages_actionable: 10 results: @@ -207,7 +207,7 @@ public function it_properly_calculates_actionable_count() $expected = <<<"EXPECTED" date: $now->timestamp status: fail -score: 83.0 +score: 86.0 pages_crawled: 10 pages_actionable: 6 results: @@ -255,7 +255,7 @@ public function it_can_generate_a_large_report_with_multiple_chunked_jobs() $expected = <<<"EXPECTED" date: $now->timestamp status: fail -score: 83.0 +score: 86.0 pages_crawled: 10 pages_actionable: 10 results: @@ -299,7 +299,7 @@ public function it_skips_over_pages_with_disabled_seo() $expected = <<<"EXPECTED" date: $now->timestamp status: fail -score: 84.0 +score: 86.0 pages_crawled: 9 pages_actionable: 9 results: @@ -339,7 +339,7 @@ public function it_skips_over_entries_with_redirects() $expected = <<<"EXPECTED" date: $now->timestamp status: fail -score: 87.0 +score: 88.0 pages_crawled: 4 pages_actionable: 4 results: @@ -595,7 +595,29 @@ public function it_does_not_score_100_when_meta_descriptions_are_missing() $this->assertEquals(0, $report->results()['UniqueMetaDescription']); $this->assertEquals(['failures' => 5, 'warnings' => 0], $report->results()['IdealMetaDescriptionLength']); - $this->assertEquals(86, $report->score()); + $this->assertEquals(88, $report->score()); + } + + #[Test] + public function it_does_not_score_100_when_urls_contain_underscores() + { + collect(range(1, 5))->each(function ($i) { + Entry::make() + ->collection('articles') + ->blueprint('article') + ->slug('test_entry_'.$i) + ->set('title', 'Test Entry '.$i) + ->set('seo', ['description' => "A unique meta description for test entry {$i}, written to be an ideal length so that search engines can display all of it in their results."]) + ->save(); + }); + + Report::create()->save()->generate(); + + $report = Report::find(1); + + $this->assertEquals(5, $report->results()['NoUnderscoresInUrl']); + $this->assertEquals(['failures' => 0, 'warnings' => 0], $report->results()['IdealMetaDescriptionLength']); + $this->assertEquals(88, $report->score()); } private function generateReportWithDuplicateTitles()