Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductMediaAttributeManagementTest.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Catalog\Api;
8 
10 
12 {
16  public function testGetList()
17  {
18  $attributeSetName = 'attribute_set_with_media_attribute';
19  $serviceInfo = [
20  'rest' => [
21  'resourcePath' => '/V1/products/media/types/' . $attributeSetName,
23  ],
24  'soap' => [
25  'service' => 'catalogProductMediaAttributeManagementV1',
26  'serviceVersion' => 'V1',
27  'operation' => 'catalogProductMediaAttributeManagementV1GetList',
28  ],
29  ];
30 
31  $requestData = [
32  'attributeSetName' => $attributeSetName,
33  ];
34 
35  $mediaAttributes = $this->_webApiCall($serviceInfo, $requestData);
36 
37  $this->assertNotEmpty($mediaAttributes);
38  $attribute = $this->getAttributeByCode($mediaAttributes, 'funny_image');
39  $this->assertNotNull($attribute);
40  $this->assertEquals('Funny image', $attribute['default_frontend_label']);
41  $this->assertEquals(1, $attribute['is_user_defined']);
42  }
43 
51  protected function getAttributeByCode($attributeList, $attributeCode)
52  {
53  foreach ($attributeList as $attribute) {
54  if ($attributeCode == $attribute['attribute_code']) {
55  return $attribute;
56  }
57  }
58 
59  return null;
60  }
61 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$attributeCode
Definition: extend.phtml:12