@@ -18,10 +18,71 @@ class BeforeTest extends \PHPUnit_Framework_TestCase
18
18
*/
19
19
protected $ _model ;
20
20
21
+ /**
22
+ * Source entity behaviors
23
+ *
24
+ * @var array
25
+ */
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
+
31
+ /**
32
+ * Expected entity behaviors
33
+ *
34
+ * @var array
35
+ */
36
+ protected $ _expectedEntities = ['entity_1 ' => 'behavior_1 ' , 'entity_2 ' => 'behavior_2 ' ];
37
+
38
+ /**
39
+ * Source unique behaviors
40
+ *
41
+ * @var array
42
+ */
43
+ protected $ _sourceBehaviors = [
44
+ 'behavior_1 ' => 'Some_Random_First_Class ' ,
45
+ 'behavior_2 ' => 'Some_Random_Second_Class ' ,
46
+ ];
47
+
48
+ /**
49
+ * Expected unique behaviors
50
+ *
51
+ * @var array
52
+ */
53
+ protected $ _expectedBehaviors = ['behavior_1 ' , 'behavior_2 ' ];
54
+
21
55
protected function setUp ()
22
56
{
57
+ $ importModel = $ this ->getMock (
58
+ 'Magento\ImportExport\Model\Import ' ,
59
+ ['getEntityBehaviors ' , 'getUniqueEntityBehaviors ' ],
60
+ [],
61
+ '' ,
62
+ false
63
+ );
64
+ $ importModel ->expects (
65
+ $ this ->any ()
66
+ )->method (
67
+ 'getEntityBehaviors '
68
+ )->will (
69
+ $ this ->returnValue ($ this ->_sourceEntities )
70
+ );
71
+ $ importModel ->expects (
72
+ $ this ->any ()
73
+ )->method (
74
+ 'getUniqueEntityBehaviors '
75
+ )->will (
76
+ $ this ->returnValue ($ this ->_sourceBehaviors )
77
+ );
78
+
23
79
$ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
24
- $ this ->_model = $ objectManager ->create ('Magento\ImportExport\Block\Adminhtml\Import\Edit\Before ' );
80
+ $ this ->_model = $ objectManager ->create (
81
+ 'Magento\ImportExport\Block\Adminhtml\Import\Edit\Before ' ,
82
+ [
83
+ 'importModel ' => $ importModel ,
84
+ ]
85
+ );
25
86
}
26
87
27
88
/**
@@ -32,8 +93,7 @@ protected function setUp()
32
93
public function testGetEntityBehaviors ()
33
94
{
34
95
$ actualEntities = $ this ->_model ->getEntityBehaviors ();
35
- $ expectedEntities = '{"catalog_product":"basic_behavior","customer_finance":"custom_behavior", ' .
36
- '"customer_composite":"basic_behavior","customer":"custom_behavior","customer_address":"custom_behavior"} ' ;
96
+ $ expectedEntities = \Zend_Json::encode ($ this ->_expectedEntities );
37
97
$ this ->assertEquals ($ expectedEntities , $ actualEntities );
38
98
}
39
99
@@ -45,7 +105,7 @@ public function testGetEntityBehaviors()
45
105
public function testGetUniqueBehaviors ()
46
106
{
47
107
$ actualBehaviors = $ this ->_model ->getUniqueBehaviors ();
48
- $ expectedBehaviors = ' ["basic_behavior","custom_behavior"] ' ;
108
+ $ expectedBehaviors = \Zend_Json:: encode ( $ this -> _expectedBehaviors ) ;
49
109
$ this ->assertEquals ($ expectedBehaviors , $ actualBehaviors );
50
110
}
51
111
}
0 commit comments