Skip to content

Commit 5f58dff

Browse files
author
Bohdan Korablov
committed
Merge branch 'MAGETWO-37720' of https://github.corp.ebay.com/magento-tango/magento2ce into MAGETWO-37720
2 parents 9c7bd2c + 96ca749 commit 5f58dff

File tree

1 file changed

+11
-29
lines changed
  • app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block

1 file changed

+11
-29
lines changed

app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Block/SaveTest.php

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,7 @@ protected function setUp()
7979
{
8080
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
8181

82-
$this->contextMock = $this->getMock(
83-
'Magento\Backend\App\Action\Context',
84-
[
85-
'getTitle',
86-
'getRequest',
87-
'getObjectManager',
88-
'getEventManager',
89-
'getResponse',
90-
'getMessageManager',
91-
'getResultRedirectFactory'
92-
],
93-
[],
94-
'',
95-
false
96-
);
82+
$this->contextMock = $this->getMock('Magento\Backend\App\Action\Context', [], [], '', false);
9783

9884
$this->resultRedirectFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\RedirectFactory')
9985
->disableOriginalConstructor()
@@ -132,12 +118,7 @@ protected function setUp()
132118
['getParam', 'getPostValue']
133119
);
134120

135-
$this->blockMock = $this->getMockBuilder('Magento\Cms\Model\Block')
136-
->disableOriginalConstructor()
137-
->setMethods(
138-
['load', 'getId', 'setData', 'save']
139-
)
140-
->getMock();
121+
$this->blockMock = $this->getMockBuilder('Magento\Cms\Model\Block')->disableOriginalConstructor()->getMock();
141122

142123
$this->messageManagerMock = $this->getMock('Magento\Framework\Message\ManagerInterface', [], [], '', false);
143124

@@ -191,7 +172,10 @@ public function testSaveAction()
191172
'content' => '"><script>alert("cookie: "+document.cookie)</script>'
192173
];
193174

194-
$this->dataProcessorMock->expects($this->any())->method('filter')->willReturn($filteredPostData);
175+
$this->dataProcessorMock->expects($this->any())
176+
->method('filter')
177+
->with($postData)
178+
->willReturn($filteredPostData);
195179

196180
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn($postData);
197181
$this->requestMock->expects($this->atLeastOnce())
@@ -232,16 +216,14 @@ public function testSaveAction()
232216

233217
$this->resultRedirect->expects($this->atLeastOnce())->method('setPath')->with('*/*/') ->willReturnSelf();
234218

235-
$this->assertEquals($this->resultRedirect, $this->saveController->execute());
219+
$this->assertSame($this->resultRedirect, $this->saveController->execute());
236220
}
237221

238222
public function testSaveActionWithoutData()
239223
{
240224
$this->requestMock->expects($this->any())->method('getPostValue')->willReturn(false);
241-
242225
$this->resultRedirect->expects($this->atLeastOnce())->method('setPath')->with('*/*/') ->willReturnSelf();
243-
244-
$this->assertEquals($this->resultRedirect, $this->saveController->execute());
226+
$this->assertSame($this->resultRedirect, $this->saveController->execute());
245227
}
246228

247229
public function testSaveActionNoId()
@@ -274,7 +256,7 @@ public function testSaveActionNoId()
274256

275257
$this->resultRedirect->expects($this->atLeastOnce())->method('setPath')->with('*/*/') ->willReturnSelf();
276258

277-
$this->assertEquals($this->resultRedirect, $this->saveController->execute());
259+
$this->assertSame($this->resultRedirect, $this->saveController->execute());
278260
}
279261

280262
public function testSaveAndContinue()
@@ -321,7 +303,7 @@ public function testSaveAndContinue()
321303
->with('*/*/edit', ['block_id' => $this->blockId])
322304
->willReturnSelf();
323305

324-
$this->assertEquals($this->resultRedirect, $this->saveController->execute());
306+
$this->assertSame($this->resultRedirect, $this->saveController->execute());
325307
}
326308

327309
public function testSaveActionThrowsException()
@@ -370,6 +352,6 @@ public function testSaveActionThrowsException()
370352
->with('*/*/edit', ['block_id' => $this->blockId])
371353
->willReturnSelf();
372354

373-
$this->assertEquals($this->resultRedirect, $this->saveController->execute());
355+
$this->assertSame($this->resultRedirect, $this->saveController->execute());
374356
}
375357
}

0 commit comments

Comments
 (0)