12
12
use Magento \Eav \Api \Data \AttributeOptionInterface ;
13
13
use Magento \Eav \Api \Data \AttributeOptionLabelInterface ;
14
14
use Magento \Eav \Model \AttributeRepository ;
15
+ use Magento \Framework \DataObject ;
15
16
use Magento \Framework \Webapi \Rest \Request ;
16
17
use Magento \Swatches \Model \ResourceModel \Swatch \Collection ;
17
18
use Magento \Swatches \Model \ResourceModel \Swatch \CollectionFactory ;
@@ -33,23 +34,23 @@ class ProductAttributeOptionManagementInterfaceTest extends WebapiAbstract
33
34
/**
34
35
* Test add option to swatch attribute
35
36
*
37
+ * @dataProvider addDataProvider
36
38
* @magentoApiDataFixture Magento/Catalog/Model/Product/Attribute/_files/select_attribute.php
37
39
* @param array $data
38
40
* @param array $payload
39
41
* @param int $expectedSwatchType
40
42
* @param string $expectedLabel
41
43
* @param string $expectedValue
42
44
*
43
- * @dataProvider addDataProvider
45
+ * @return void
44
46
*/
45
47
public function testAdd (
46
48
array $ data ,
47
49
array $ payload ,
48
50
int $ expectedSwatchType ,
49
51
string $ expectedLabel ,
50
52
string $ expectedValue
51
- )
52
- {
53
+ ): void {
53
54
$ objectManager = Bootstrap::getObjectManager ();
54
55
/** @var $attributeRepository AttributeRepository */
55
56
$ attributeRepository = $ objectManager ->get (AttributeRepository::class);
@@ -87,8 +88,9 @@ public function testAdd(
87
88
88
89
/**
89
90
* @magentoApiDataFixture Magento/Swatches/_files/text_swatch_attribute.php
91
+ * @return void
90
92
*/
91
- public function testUpdate ()
93
+ public function testUpdate (): void
92
94
{
93
95
$ testAttributeCode = 'test_configurable ' ;
94
96
$ optionData = [
@@ -115,7 +117,7 @@ public function testUpdate()
115
117
$ this ->assertNotNull (
116
118
$ this ->getAttributeOption (
117
119
$ testAttributeCode ,
118
- $ optionData [AttributeOptionLabelInterface ::LABEL ]
120
+ $ optionData [AttributeOptionInterface ::LABEL ]
119
121
)
120
122
);
121
123
}
@@ -124,7 +126,7 @@ public function testUpdate()
124
126
* @return array
125
127
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
126
128
*/
127
- public function addDataProvider ()
129
+ public function addDataProvider (): array
128
130
{
129
131
return [
130
132
'visual swatch option with value ' => [
@@ -249,14 +251,15 @@ public function addDataProvider()
249
251
* Get swatch model
250
252
*
251
253
* @param int $optionId
252
- * @return Swatch
254
+ * @return DataObject
253
255
*/
254
- private function getSwatch (int $ optionId )
256
+ private function getSwatch (int $ optionId ): DataObject
255
257
{
256
258
/** @var Collection $collection */
257
259
$ collection = Bootstrap::getObjectManager ()->get (CollectionFactory::class)->create ();
258
260
$ collection ->addFieldToFilter ('option_id ' , $ optionId );
259
261
$ collection ->setPageSize (1 );
262
+
260
263
return $ collection ->getFirstItem ();
261
264
}
262
265
@@ -300,6 +303,8 @@ private function webApiCallAttributeOptions(
300
303
}
301
304
302
305
/**
306
+ * Get Attribute options by attribute code
307
+ *
303
308
* @param string $testAttributeCode
304
309
* @param string|null $storeCode
305
310
* @return array|bool|float|int|string
@@ -317,6 +322,8 @@ private function getAttributeOptions(string $testAttributeCode, ?string $storeCo
317
322
}
318
323
319
324
/**
325
+ * Get Attribute option by attribute code
326
+ *
320
327
* @param string $attributeCode
321
328
* @param string $optionLabel
322
329
* @param string|null $storeCode
@@ -326,8 +333,7 @@ private function getAttributeOption(
326
333
string $ attributeCode ,
327
334
string $ optionLabel ,
328
335
?string $ storeCode = null
329
- ): ?array
330
- {
336
+ ): ?array {
331
337
$ attributeOptions = $ this ->getAttributeOptions ($ attributeCode , $ storeCode );
332
338
$ option = null ;
333
339
/** @var array $attributeOption */
0 commit comments