Skip to content

Commit f3cf2eb

Browse files
author
Joan He
committed
Merge branch 'MAGETWO-66190-unserialize-in-tests' into pr
2 parents 4a2bcc0 + 395827d commit f3cf2eb

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testGet($isCached)
8888
{
8989
$path = 'default/dev/unsecure/url';
9090
$url = 'http://magento.test/';
91-
$data = [
91+
$unserializedData = [
9292
'default' => [
9393
'dev' => [
9494
'unsecure' => [
@@ -97,41 +97,42 @@ public function testGet($isCached)
9797
]
9898
]
9999
];
100+
$serializedDataString = '{"serialized-data"}';
100101

101102
$this->cache->expects($this->once())
102103
->method('load')
103104
->with(System::CONFIG_TYPE)
104-
->willReturn($isCached ? $data : null);
105+
->willReturn($isCached ? $unserializedData : null);
105106

106107
if ($isCached) {
107108
$this->serializer->expects($this->once())
108109
->method('unserialize')
109-
->willReturn($data);
110+
->willReturn($unserializedData);
110111
}
111112

112113
if (!$isCached) {
113114
$this->serializer->expects($this->once())
114115
->method('serialize')
115-
->willReturn(serialize($data));
116+
->willReturn($serializedDataString);
116117
$this->source->expects($this->once())
117118
->method('get')
118-
->willReturn($data);
119+
->willReturn($unserializedData);
119120
$this->fallback->expects($this->once())
120121
->method('process')
121-
->with($data)
122+
->with($unserializedData)
122123
->willReturnArgument(0);
123124
$this->preProcessor->expects($this->once())
124125
->method('process')
125-
->with($data)
126+
->with($unserializedData)
126127
->willReturnArgument(0);
127128
$this->postProcessor->expects($this->once())
128129
->method('process')
129-
->with($data)
130+
->with($unserializedData)
130131
->willReturnArgument(0);
131132
$this->cache->expects($this->once())
132133
->method('save')
133134
->with(
134-
serialize($data),
135+
$serializedDataString,
135136
System::CONFIG_TYPE,
136137
[System::CACHE_TAG]
137138
);

lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ protected function tearDown()
8484

8585
public function testSendVary()
8686
{
87-
$data = ['some-vary-key' => 'some-vary-value'];
8887
$expectedCookieName = Http::COOKIE_VARY_STRING;
89-
$expectedCookieValue = sha1(serialize($data));
88+
$expectedCookieValue = 'SHA1 Serialized String';
9089
$sensitiveCookieMetadataMock = $this->getMockBuilder(
9190
\Magento\Framework\Stdlib\Cookie\SensitiveCookieMetadata::class)
9291
->disableOriginalConstructor()

lib/internal/Magento/Framework/Filter/Test/Unit/TemplateTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ public function varDirectiveDataProvider()
149149

150150
$stub->expects($this->once())
151151
->method('bar')
152-
->will($this->returnCallback(function ($arg) {
153-
return serialize($arg);
154-
}));
152+
->willReturn('Mocked Method Return');
155153

156154
return [
157155
'no variables' => [
@@ -177,14 +175,7 @@ public function varDirectiveDataProvider()
177175
'b' => 'bee',
178176
'd' => 'dee',
179177
],
180-
serialize([
181-
'param_1' => 'value_1',
182-
'param_2' => 'lorem',
183-
'param_3' => [
184-
'a' => 'bee',
185-
'c' => 'dee',
186-
],
187-
]),
178+
'Mocked Method Return'
188179
],
189180
];
190181
}

0 commit comments

Comments
 (0)