/** * @magentoDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php */ public function testGetCustomAttributesMetadataWithAttributeNamedCustomAttribute() { $customAttributesMetadata = $this->_service->getCustomAttributesMetadata(); $expectedCustomAttributeCodeArray = ['custom_attribute1', 'custom_attribute2', 'customer_image']; $actual = []; foreach ($customAttributesMetadata as $attribute) { $actual[] = $attribute->getAttributeCode(); } $this->assertEquals($expectedCustomAttributeCodeArray, array_intersect($expectedCustomAttributeCodeArray, $actual), "Expected attributes not returned from the service."); }
/** * @magentoDataFixture Magento/Customer/_files/attribute_user_defined_custom_attribute.php */ public function testGetCustomAttributesMetadataWithAttributeNamedCustomAttribute() { $customAttributesMetadata = $this->_service->getCustomAttributesMetadata(); $customAttributeCodeOne = 'custom_attribute1'; $customAttributeFound = false; $customAttributeCodeTwo = 'custom_attribute2'; $customAttributesFound = false; foreach ($customAttributesMetadata as $attribute) { if ($attribute->getAttributeCode() == $customAttributeCodeOne) { $customAttributeFound = true; } if ($attribute->getAttributeCode() == $customAttributeCodeTwo) { $customAttributesFound = true; } } if (!$customAttributeFound) { $this->fail("Custom attribute declared in the config not found."); } if (!$customAttributesFound) { $this->fail("Custom attributes declared in the config not found."); } $this->assertCount(3, $customAttributesMetadata, "Invalid number of attributes returned."); }