Skip to content

Commit 76dd347

Browse files
committed
AC-14999: FPC not work when login
Static test fix
1 parent d03c7d3 commit 76dd347

File tree

1 file changed

+9
-29
lines changed

1 file changed

+9
-29
lines changed

dev/tests/integration/testsuite/Magento/PageCache/Model/App/Request/Http/IdentifierForSaveTest.php

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@
77

88
namespace Magento\PageCache\Model\App\Request\Http;
99

10-
use Magento\Framework\App\Request\Http as HttpRequest;
11-
use Magento\Framework\App\Response\Http as HttpResponse;
1210
use Magento\Framework\ObjectManagerInterface;
13-
use Magento\Store\Model\StoreManager;
14-
use Magento\Store\Test\Fixture\Group as StoreGroupFixture;
15-
use Magento\Store\Test\Fixture\Store as StoreFixture;
16-
use Magento\Store\Test\Fixture\Website as WebsiteFixture;
1711
use Magento\TestFramework\Fixture\Config as ConfigFixture;
1812
use Magento\TestFramework\Fixture\DataFixture;
1913
use Magento\TestFramework\Fixture\DataFixtureStorage;
2014
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
21-
use Magento\TestFramework\Fixture\DbIsolation;
2215
use Magento\TestFramework\Helper\Bootstrap;
2316
use Magento\Customer\Model\Session;
2417
use Magento\Framework\App\Http\Context;
@@ -29,6 +22,8 @@
2922

3023
/**
3124
* Integration test for \Magento\PageCache\Model\App\Request\Http\IdentifierForSave
25+
*
26+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
3227
*/
3328
class IdentifierForSaveTest extends TestCase
3429
{
@@ -37,11 +32,6 @@ class IdentifierForSaveTest extends TestCase
3732
*/
3833
private $objectManager;
3934

40-
/**
41-
* @var HttpRequest
42-
*/
43-
private $request;
44-
4535
/**
4636
* @var IdentifierForSave
4737
*/
@@ -67,10 +57,14 @@ class IdentifierForSaveTest extends TestCase
6757
*/
6858
private $cookieMetadataFactory;
6959

60+
/**
61+
* @var string
62+
*/
63+
private const COOKIE_VARY_STRING = 'X-Magento-Vary';
64+
7065
protected function setUp(): void
7166
{
7267
$this->objectManager = Bootstrap::getObjectManager();
73-
$this->request = $this->objectManager->get(HttpRequest::class);
7468
$this->identifierForSave = $this->objectManager->get(IdentifierForSave::class);
7569
$this->fixtures = $this->objectManager->get(DataFixtureStorageManager::class)->getStorage();
7670
$this->context = $this->objectManager->get(Context::class);
@@ -82,23 +76,12 @@ protected function setUp(): void
8276
* Test that cache identifier properly handles logged-in customers
8377
*/
8478
#[
85-
DbIsolation(false),
8679
ConfigFixture('system/full_page_cache/caching_application', '1', 'store'),
8780
ConfigFixture('system/full_page_cache/enabled', '1', 'store'),
88-
DataFixture(WebsiteFixture::class, as: 'website'),
89-
DataFixture(StoreGroupFixture::class, ['website_id' => '$website.id$'], 'store_group'),
90-
DataFixture(StoreFixture::class, ['store_group_id' => '$store_group.id$'], 'store'),
9181
DataFixture(CustomerFixture::class, as: 'customer')
9282
]
9383
public function testAfterGetValueWithLoggedInCustomer()
9484
{
95-
$storeCode = $this->fixtures->get('store')->getCode();
96-
$serverParams = [
97-
StoreManager::PARAM_RUN_TYPE => 'store',
98-
StoreManager::PARAM_RUN_CODE => $storeCode
99-
];
100-
$this->request->setServer(new \Laminas\Stdlib\Parameters($serverParams));
101-
10285
// Get customer and login
10386
$customer = $this->fixtures->get('customer');
10487
$customerSession = $this->objectManager->get(Session::class);
@@ -118,7 +101,7 @@ public function testAfterGetValueWithLoggedInCustomer()
118101
// Set the vary cookie to simulate a previous request
119102
$cookieMetadata = $this->cookieMetadataFactory->createSensitiveCookieMetadata()->setPath('/');
120103
$this->cookieManager->setSensitiveCookie(
121-
HttpResponse::COOKIE_VARY_STRING,
104+
self::COOKIE_VARY_STRING,
122105
$originalVaryString,
123106
$cookieMetadata
124107
);
@@ -142,9 +125,6 @@ public function testAfterGetValueWithLoggedInCustomer()
142125
$this->assertEquals($result, $resultWithEmptyContext);
143126

144127
// Clean up
145-
$this->cookieManager->deleteCookie(
146-
HttpResponse::COOKIE_VARY_STRING,
147-
$cookieMetadata
148-
);
128+
$this->cookieManager->deleteCookie(self::COOKIE_VARY_STRING, $cookieMetadata);
149129
}
150130
}

0 commit comments

Comments
 (0)