diff --git a/composer.json b/composer.json index ec34cd1b..4a04c00d 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ } }, "require": { - "statamic/cms": "^4.0" + "statamic/cms": "^4.1.3" }, "require-dev": { "orchestra/testbench": "^7.0 || ^8.0", diff --git a/src/Cascade.php b/src/Cascade.php index a3dd7db1..8a5c4216 100644 --- a/src/Cascade.php +++ b/src/Cascade.php @@ -73,7 +73,7 @@ public function get() return $this->getForSitemap(); } - if (array_get($this->current, 'response_code') === 404) { + if (array_get($this->data, 'response_code') === 404) { $this->current['title'] = '404 Page Not Found'; } diff --git a/tests/CascadeTest.php b/tests/CascadeTest.php index 0d1db087..f8401fc6 100644 --- a/tests/CascadeTest.php +++ b/tests/CascadeTest.php @@ -164,4 +164,18 @@ public function it_generates_seo_cascade_without_exception_when_no_home_entry_ex $this->assertArraySubset($expected, $data); } + + /** @test */ + public function it_generates_404_title_with_404_in_response_code_in_context() + { + $data = (new Cascade) + ->with(SiteDefaults::load()->all()) + ->with([ + 'response_code' => 404, + ]) + ->get(); + + $this->assertEquals('404 Page Not Found', $data['title']); + $this->assertEquals('404 Page Not Found | Site Name', $data['compiled_title']); + } } diff --git a/tests/Fixtures/views/antlers/errors/404.antlers.html b/tests/Fixtures/views/antlers/errors/404.antlers.html new file mode 100644 index 00000000..a8eab27f --- /dev/null +++ b/tests/Fixtures/views/antlers/errors/404.antlers.html @@ -0,0 +1,2 @@ +