Skip to content

Commit

Permalink
Fix PHPStan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jissereitsma committed Mar 4, 2024
1 parent 7947b17 commit 156ef96
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
10 changes: 8 additions & 2 deletions Test/Integration/BodyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Yireo\LinkPreload\Test\Integration;

use Magento\Framework\App\Response\Http;

class BodyTest extends AbstractTestCase
{
/**
Expand All @@ -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);
}
Expand All @@ -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) {
Expand Down
11 changes: 8 additions & 3 deletions Test/Integration/HeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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());
}

/**
Expand All @@ -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) {
Expand Down

0 comments on commit 156ef96

Please sign in to comment.