Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BackendTemplateTest.php
Go to the documentation of this file.
1 <?php
11 
14 
15 class BackendTemplateTest extends \PHPUnit\Framework\TestCase
16 {
22  protected $model;
23 
27  protected $scopeConfigMock;
28 
32  protected $structureMock;
33 
37  protected $resourceModelMock;
38 
43 
47  private $serializerMock;
48 
49  protected function setUp()
50  {
51  $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
52 
53  $this->scopeConfigMock = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
54  $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn(['test' => 1]);
55 
56  $this->structureMock = $this->createMock(\Magento\Config\Model\Config\Structure::class);
57  $this->structureMock->expects($this->any())->method('getFieldPathsByAttribute')->willReturn(['path' => 'test']);
58 
59  $this->resourceModelMock = $this->createMock(\Magento\Email\Model\ResourceModel\Template::class);
60  $this->resourceModelMock->expects($this->any())
61  ->method('getSystemConfigByPathsAndTemplateId')
62  ->willReturn(['test_config' => 2015]);
64  $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
65  $objectManagerMock->expects($this->any())
66  ->method('get')
67  ->with(\Magento\Email\Model\ResourceModel\Template::class)
68  ->will($this->returnValue($this->resourceModelMock));
69 
71 
72  $this->serializerMock = $this->getMockBuilder(\Magento\Framework\Serialize\Serializer\Json::class)->getMock();
73 
74  $this->model = $helper->getObject(
75  \Magento\Email\Model\BackendTemplate::class,
76  [
77  'scopeConfig' => $this->scopeConfigMock,
78  'structure' => $this->structureMock,
79  'serializer' => $this->serializerMock
80  ]
81  );
82  }
83 
84  protected function tearDown()
85  {
86  parent::tearDown();
88  $objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
90  }
91 
93  {
94  $this->assertEquals([], $this->model->getSystemConfigPathsWhereCurrentlyUsed());
95  }
96 
98  {
99  $this->model->setId(1);
100  $this->assertEquals(['test_config' => 2015], $this->model->getSystemConfigPathsWhereCurrentlyUsed());
101  }
102 }
$helper
Definition: iframe.phtml:13
static setInstance(\Magento\Framework\ObjectManagerInterface $objectManager)