Skip to content

Commit ce261ee

Browse files
committed
Fix the unit tests for the backend template to work with serilizer mock objects
1 parent 2fbddf0 commit ce261ee

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/EditTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ protected function setUp()
5656
$menuMock = $this->getMock(
5757
\Magento\Backend\Model\Menu::class,
5858
[],
59-
[$this->getMock(\Psr\Log\LoggerInterface::class)]
59+
[$this->getMock(\Psr\Log\LoggerInterface::class)],
60+
'',
61+
false,
62+
false
6063
);
6164
$menuItemMock = $this->getMock(\Magento\Backend\Model\Menu\Item::class, [], [], '', false, false);
6265
$urlBuilder = $this->getMock(\Magento\Backend\Model\Url::class, [], [], '', false, false);

app/code/Magento/Email/Test/Unit/Model/BackendTemplateTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class BackendTemplateTest extends \PHPUnit_Framework_TestCase
4343
*/
4444
protected $objectManagerBackup;
4545

46-
/** @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject */
46+
/**
47+
* @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
48+
*/
4749
private $serilizerMock;
4850

4951
protected function setUp()

app/code/Magento/Email/Test/Unit/Model/TemplateTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
8484
*/
8585
private $templateFactory;
8686

87+
/**
88+
* @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
89+
*/
90+
private $serilizerMock;
91+
8792
protected function setUp()
8893
{
8994
$this->context = $this->getMockBuilder(\Magento\Framework\Model\Context::class)
@@ -138,6 +143,8 @@ protected function setUp()
138143
->setMethods(['create'])
139144
->disableOriginalConstructor()
140145
->getMock();
146+
147+
$this->serilizerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
141148
}
142149

143150
/**
@@ -164,6 +171,8 @@ protected function getModelMock(array $mockedMethods = [])
164171
$this->filterManager,
165172
$this->urlModel,
166173
$this->filterFactory,
174+
[],
175+
$this->serilizerMock
167176
])
168177
->getMock();
169178
}
@@ -532,6 +541,11 @@ public function testGetVariablesOptionArray($withGroup, $templateVariables, $exp
532541
{
533542
$model = $this->getModelMock();
534543
$model->setData('orig_template_variables', $templateVariables);
544+
545+
$this->serilizerMock->expects($this->any())->method('unserialize')
546+
->willReturn(
547+
json_decode($templateVariables, true)
548+
);
535549
$this->assertEquals($expectedResult, $model->getVariablesOptionArray($withGroup));
536550
}
537551

0 commit comments

Comments
 (0)