From 156ef9688ffe8198f2ee2175d0bf94acfb86a3a3 Mon Sep 17 00:00:00 2001 From: Jisse Reitsma Date: Mon, 4 Mar 2024 13:11:18 +0100 Subject: [PATCH] Fix PHPStan issues --- Test/Integration/BodyTest.php | 10 ++++++++-- Test/Integration/HeaderTest.php | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Test/Integration/BodyTest.php b/Test/Integration/BodyTest.php index 88c7333..7aa7d85 100644 --- a/Test/Integration/BodyTest.php +++ b/Test/Integration/BodyTest.php @@ -2,6 +2,8 @@ namespace Yireo\LinkPreload\Test\Integration; +use Magento\Framework\App\Response\Http; + class BodyTest extends AbstractTestCase { /** @@ -11,7 +13,9 @@ public function testIfLinkHeadersExistsWhenModuleIsEnabled() { $this->assertEnabledValue(1); $this->dispatch('/'); - $body = (string)$this->getResponse()->getBody(); + /** @var Http $response */ + $response = $this->getResponse(); + $body = (string)$response->getBody(); foreach ((new LinkDataProvider())->getLinks() as $link) { $this->assertBodyContainsLink($link[0], $link[1], $body); } @@ -31,7 +35,9 @@ public function testIfLinkHeadersExistsWhenModuleIsEnabledAndWithFullPageCache() $this->assertEnabledValue(1); $this->dispatch('/'); - $body = (string)$this->getResponse()->getBody(); + /** @var Http $response */ + $response = $this->getResponse(); + $body = (string)$response->getBody(); $this->assertNotEmpty($body); foreach ((new LinkDataProvider())->getLinks() as $link) { diff --git a/Test/Integration/HeaderTest.php b/Test/Integration/HeaderTest.php index e0fc18e..7092809 100644 --- a/Test/Integration/HeaderTest.php +++ b/Test/Integration/HeaderTest.php @@ -5,6 +5,7 @@ use Magento\Framework\App\Cache\Manager; use Magento\Framework\App\Config\ScopeConfigInterface; use Laminas\Http\Header\HeaderInterface; +use Magento\Framework\App\Response\Http; class HeaderTest extends AbstractTestCase { @@ -41,11 +42,13 @@ public function testIfLinkHeadersExistsWhenModuleIsEnabledAndWithFullPageCache() $this->getLinkHeaders(); $this->getLinkHeaders(); - $allHeaders = $this->getResponse()->getHeaders(); + /** @var Http $response */ + $response = $this->getResponse(); + $allHeaders = $response->getHeaders(); $this->assertTrue(count($allHeaders) > 0, 'No headers found: '.$allHeaders->toString()); $linkHeaders = $this->getLinkHeaders(); - $this->assertTrue(count($linkHeaders) > 0, 'No Link-headers found: '.$this->getResponse()->getHeaders()->toString()); + $this->assertTrue(count($linkHeaders) > 0, 'No Link-headers found: '.$allHeaders->toString()); } /** @@ -61,7 +64,9 @@ public function testIfLinkHeadersExistsWhenModuleIsDisabled() private function getLinkHeaders(): array { $this->dispatch('/'); - $headers = $this->getResponse()->getHeaders(); + /** @var Http $response */ + $response = $this->getResponse(); + $headers = $response->getHeaders(); $linkHeaders = []; foreach ($headers as $header) {