@@ -110,33 +110,26 @@ public function testModifyDataNewProduct(array $data, int $defaultStatusValue, a
110110 /**
111111 * Verify the product attribute status set owhen editing existing product
112112 *
113- * @throws \Magento\Framework\Exception\NoSuchEntityException
113+ * @param array $data
114+ * @param string $modelId
115+ * @param int $defaultStatus
116+ * @param int $statusAttributeValue
117+ * @param array $expectedResult
118+ * @throws \Magento\Framework\Exception\NoSuchEntityException
119+ * @dataProvider modifyDataOfExistingProductDataProvider
114120 */
115- public function testModifyDataExistingProduct ()
116- {
117- $ data = [];
118- $ modelId = 1 ;
119- $ defaultStatusValue = 1 ;
120- $ expectedResult = [
121- 'enabledProductStatus ' => [
122- General::DATA_SOURCE_DEFAULT => [
123- ProductAttributeInterface::CODE_STATUS => 1 ,
124- ],
125- ],
126- 'disabledProductStatus ' => [
127- General::DATA_SOURCE_DEFAULT => [
128- ProductAttributeInterface::CODE_STATUS => 2 ,
129- ],
130- ],
131- ];
132- $ enabledProductStatus = 1 ;
133- $ disabledProductStatus = 2 ;
134- $ attributeMock = $ this ->getMockBuilder (AttributeInterface::class)
135- ->getMockForAbstractClass ();
136- $ attributeMock
121+ public function testModifyDataOfExistingProduct (
122+ array $ data ,
123+ string $ modelId ,
124+ int $ defaultStatus ,
125+ int $ statusAttributeValue ,
126+ array $ expectedResult
127+ ) {
128+ $ attributeMock = $ this ->getMockForAbstractClass (AttributeInterface::class);
129+ $ attributeMock ->expects ($ this ->any ())
137130 ->method ('getDefaultValue ' )
138- ->willReturn ($ defaultStatusValue );
139- $ this ->attributeRepositoryMock
131+ ->willReturn ($ defaultStatus );
132+ $ this ->attributeRepositoryMock -> expects ( $ this -> any ())
140133 ->method ('get ' )
141134 ->with (
142135 ProductAttributeInterface::ENTITY_TYPE_CODE ,
@@ -148,9 +141,61 @@ public function testModifyDataExistingProduct()
148141 ->willReturn ($ modelId );
149142 $ this ->productMock ->expects ($ this ->any ())
150143 ->method ('getStatus ' )
151- ->willReturnOnConsecutiveCalls ($ enabledProductStatus , $ disabledProductStatus );
152- $ this ->assertSame ($ expectedResult ['enabledProductStatus ' ], current ($ this ->generalModifier ->modifyData ($ data )));
153- $ this ->assertSame ($ expectedResult ['disabledProductStatus ' ], current ($ this ->generalModifier ->modifyData ($ data )));
144+ ->willReturn ($ statusAttributeValue );
145+ $ this ->assertSame ($ expectedResult , current ($ this ->generalModifier ->modifyData ($ data )));
146+ }
147+
148+ /**
149+ * @return array
150+ */
151+ public function modifyDataOfExistingProductDataProvider (): array
152+ {
153+ return [
154+ 'With enable status value ' => [
155+ 'data ' => [],
156+ 'modelId ' => '1 ' ,
157+ 'defaultStatus ' => 1 ,
158+ 'statusAttributeValue ' => 1 ,
159+ 'expectedResult ' => [
160+ General::DATA_SOURCE_DEFAULT => [
161+ ProductAttributeInterface::CODE_STATUS => 1 ,
162+ ],
163+ ],
164+ ],
165+ 'Without disable status value ' => [
166+ 'data ' => [],
167+ 'modelId ' => '1 ' ,
168+ 'defaultStatus ' => 1 ,
169+ 'statusAttributeValue ' => 2 ,
170+ 'expectedResult ' => [
171+ General::DATA_SOURCE_DEFAULT => [
172+ ProductAttributeInterface::CODE_STATUS => 2 ,
173+ ],
174+ ],
175+ ],
176+ 'With enable status value with empty modelId ' => [
177+ 'data ' => [],
178+ 'modelId ' => '' ,
179+ 'defaultStatus ' => 1 ,
180+ 'statusAttributeValue ' => 1 ,
181+ 'expectedResult ' => [
182+ General::DATA_SOURCE_DEFAULT => [
183+ ProductAttributeInterface::CODE_STATUS => 1 ,
184+ ],
185+ ],
186+ ],
187+ 'Without disable status value with empty modelId ' => [
188+ 'data ' => [],
189+ 'modelId ' => '' ,
190+ 'defaultStatus ' => 2 ,
191+ 'statusAttributeValue ' => 2 ,
192+ 'expectedResult ' => [
193+ General::DATA_SOURCE_DEFAULT => [
194+ ProductAttributeInterface::CODE_STATUS => 2 ,
195+ ],
196+ ],
197+ ],
198+ ];
154199 }
155200
156201 /**
0 commit comments