7
7
8
8
namespace Magento \PageCache \Model \App \Request \Http ;
9
9
10
- use Magento \Framework \App \Request \Http as HttpRequest ;
11
- use Magento \Framework \App \Response \Http as HttpResponse ;
12
10
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 ;
17
11
use Magento \TestFramework \Fixture \Config as ConfigFixture ;
18
12
use Magento \TestFramework \Fixture \DataFixture ;
19
13
use Magento \TestFramework \Fixture \DataFixtureStorage ;
20
14
use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
21
- use Magento \TestFramework \Fixture \DbIsolation ;
22
15
use Magento \TestFramework \Helper \Bootstrap ;
23
16
use Magento \Customer \Model \Session ;
24
17
use Magento \Framework \App \Http \Context ;
29
22
30
23
/**
31
24
* Integration test for \Magento\PageCache\Model\App\Request\Http\IdentifierForSave
25
+ *
26
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
32
27
*/
33
28
class IdentifierForSaveTest extends TestCase
34
29
{
@@ -37,11 +32,6 @@ class IdentifierForSaveTest extends TestCase
37
32
*/
38
33
private $ objectManager ;
39
34
40
- /**
41
- * @var HttpRequest
42
- */
43
- private $ request ;
44
-
45
35
/**
46
36
* @var IdentifierForSave
47
37
*/
@@ -67,10 +57,14 @@ class IdentifierForSaveTest extends TestCase
67
57
*/
68
58
private $ cookieMetadataFactory ;
69
59
60
+ /**
61
+ * @var string
62
+ */
63
+ private const COOKIE_VARY_STRING = 'X-Magento-Vary ' ;
64
+
70
65
protected function setUp (): void
71
66
{
72
67
$ this ->objectManager = Bootstrap::getObjectManager ();
73
- $ this ->request = $ this ->objectManager ->get (HttpRequest::class);
74
68
$ this ->identifierForSave = $ this ->objectManager ->get (IdentifierForSave::class);
75
69
$ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
76
70
$ this ->context = $ this ->objectManager ->get (Context::class);
@@ -82,23 +76,12 @@ protected function setUp(): void
82
76
* Test that cache identifier properly handles logged-in customers
83
77
*/
84
78
#[
85
- DbIsolation(false ),
86
79
ConfigFixture('system/full_page_cache/caching_application ' , '1 ' , 'store ' ),
87
80
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 ' ),
91
81
DataFixture(CustomerFixture::class, as: 'customer ' )
92
82
]
93
83
public function testAfterGetValueWithLoggedInCustomer ()
94
84
{
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
-
102
85
// Get customer and login
103
86
$ customer = $ this ->fixtures ->get ('customer ' );
104
87
$ customerSession = $ this ->objectManager ->get (Session::class);
@@ -118,7 +101,7 @@ public function testAfterGetValueWithLoggedInCustomer()
118
101
// Set the vary cookie to simulate a previous request
119
102
$ cookieMetadata = $ this ->cookieMetadataFactory ->createSensitiveCookieMetadata ()->setPath ('/ ' );
120
103
$ this ->cookieManager ->setSensitiveCookie (
121
- HttpResponse ::COOKIE_VARY_STRING ,
104
+ self ::COOKIE_VARY_STRING ,
122
105
$ originalVaryString ,
123
106
$ cookieMetadata
124
107
);
@@ -142,9 +125,6 @@ public function testAfterGetValueWithLoggedInCustomer()
142
125
$ this ->assertEquals ($ result , $ resultWithEmptyContext );
143
126
144
127
// Clean up
145
- $ this ->cookieManager ->deleteCookie (
146
- HttpResponse::COOKIE_VARY_STRING ,
147
- $ cookieMetadata
148
- );
128
+ $ this ->cookieManager ->deleteCookie (self ::COOKIE_VARY_STRING , $ cookieMetadata );
149
129
}
150
130
}
0 commit comments