Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BeforeTest.php
Go to the documentation of this file.
1 <?php
11 
12 class BeforeTest extends \PHPUnit\Framework\TestCase
13 {
19  protected $_model;
20 
26  protected $_sourceEntities = [
27  'entity_1' => ['code' => 'behavior_1', 'token' => 'Some_Random_First_Class'],
28  'entity_2' => ['code' => 'behavior_2', 'token' => 'Some_Random_Second_Class'],
29  ];
30 
36  protected $_expectedEntities = ['entity_1' => 'behavior_1', 'entity_2' => 'behavior_2'];
37 
43  protected $_sourceBehaviors = [
44  'behavior_1' => 'Some_Random_First_Class',
45  'behavior_2' => 'Some_Random_Second_Class',
46  ];
47 
53  protected $_expectedBehaviors = ['behavior_1', 'behavior_2'];
54 
55  protected function setUp()
56  {
57  $importModel = $this->createPartialMock(
58  \Magento\ImportExport\Model\Import::class,
59  ['getEntityBehaviors', 'getUniqueEntityBehaviors']
60  );
61  $importModel->expects(
62  $this->any()
63  )->method(
64  'getEntityBehaviors'
65  )->will(
66  $this->returnValue($this->_sourceEntities)
67  );
68  $importModel->expects(
69  $this->any()
70  )->method(
71  'getUniqueEntityBehaviors'
72  )->will(
73  $this->returnValue($this->_sourceBehaviors)
74  );
75 
77  $this->_model = $objectManager->create(
78  \Magento\ImportExport\Block\Adminhtml\Import\Edit\Before::class,
79  [
80  'importModel' => $importModel,
81  ]
82  );
83  }
84 
90  public function testGetEntityBehaviors()
91  {
92  $actualEntities = $this->_model->getEntityBehaviors();
93  $expectedEntities = json_encode($this->_expectedEntities);
94  $this->assertEquals($expectedEntities, $actualEntities);
95  }
96 
102  public function testGetUniqueBehaviors()
103  {
104  $actualBehaviors = $this->_model->getUniqueBehaviors();
105  $expectedBehaviors = json_encode($this->_expectedBehaviors);
106  $this->assertEquals($expectedBehaviors, $actualBehaviors);
107  }
108 }
$objectManager
Definition: bootstrap.php:17