Skip to content

Commit 37e9962

Browse files
author
okarpenko
committed
MAGETWO-33074: Upgrade response class
- update PhpEnvironment\Response test
1 parent a829ab8 commit 37e9962

File tree

1 file changed

+6
-61
lines changed

1 file changed

+6
-61
lines changed

dev/tests/unit/testsuite/Magento/Framework/HTTP/PhpEnvironment/ResponseTest.php

Lines changed: 6 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,7 @@ public function testClearHeaderIfHeaderExistsAndWasFound()
115115

116116
$this->headers->addHeaderLine('Header-name: header-value');
117117

118-
$header = $this->getMock(
119-
'Zend\Http\Header\GenericHeader',
120-
['getFieldName'],
121-
['Header-name', 'header-value']
122-
);
123-
$header
124-
->expects($this->once())
125-
->method('getFieldName')
126-
->will($this->returnValue('Header-name'));
118+
$header = \Zend\Http\Header\GenericHeader::fromString('Header-name: header-value');
127119

128120
$this->headers
129121
->expects($this->once())
@@ -132,7 +124,8 @@ public function testClearHeaderIfHeaderExistsAndWasFound()
132124
->will($this->returnValue(true));
133125
$this->headers
134126
->expects($this->once())
135-
->method('current')
127+
->method('get')
128+
->with('Header-name')
136129
->will($this->returnValue($header));
137130
$this->headers
138131
->expects($this->once())
@@ -148,47 +141,6 @@ public function testClearHeaderIfHeaderExistsAndWasFound()
148141
$response->clearHeader('Header-name');
149142
}
150143

151-
public function testClearHeaderIfHeaderExistsAndWasNotFound()
152-
{
153-
$response = $this->response = $this->getMock(
154-
'Magento\Framework\HTTP\PhpEnvironment\Response',
155-
['getHeaders', 'send']
156-
);
157-
158-
$this->headers->addHeaderLine('Header-name: header-value');
159-
160-
$header = $this->getMock(
161-
'Zend\Http\Header\GenericHeader',
162-
['getFieldName'],
163-
['Header-name', 'header-value']
164-
);
165-
$header
166-
->expects($this->once())
167-
->method('getFieldName')
168-
->will($this->returnValue('Wrong-header-name'));
169-
170-
$this->headers
171-
->expects($this->once())
172-
->method('has')
173-
->with('Header-name')
174-
->will($this->returnValue(true));
175-
$this->headers
176-
->expects($this->once())
177-
->method('current')
178-
->will($this->returnValue($header));
179-
$this->headers
180-
->expects($this->never())
181-
->method('removeHeader')
182-
->with($header);
183-
184-
$response
185-
->expects($this->once())
186-
->method('getHeaders')
187-
->will($this->returnValue($this->headers));
188-
189-
$response->clearHeader('Header-name');
190-
}
191-
192144
public function testClearHeaderAndHeaderNotExists()
193145
{
194146
$response = $this->response = $this->getMock(
@@ -198,15 +150,7 @@ public function testClearHeaderAndHeaderNotExists()
198150

199151
$this->headers->addHeaderLine('Header-name: header-value');
200152

201-
$header = $this->getMock(
202-
'Zend\Http\Header\GenericHeader',
203-
['getFieldName'],
204-
['Header-name', 'header-value']
205-
);
206-
$header
207-
->expects($this->never())
208-
->method('getFieldName')
209-
->will($this->returnValue('Wrong-header-name'));
153+
$header = \Zend\Http\Header\GenericHeader::fromString('Header-name: header-value');
210154

211155
$this->headers
212156
->expects($this->once())
@@ -215,7 +159,8 @@ public function testClearHeaderAndHeaderNotExists()
215159
->will($this->returnValue(false));
216160
$this->headers
217161
->expects($this->never())
218-
->method('current')
162+
->method('get')
163+
->with('Header-name')
219164
->will($this->returnValue($header));
220165
$this->headers
221166
->expects($this->never())

0 commit comments

Comments
 (0)