/** * Get search value for product attribute. * * @param CatalogProductAttribute $attribute * @return string */ protected function getSearchValue(CatalogProductAttribute $attribute) { $searchValue = ''; switch ($attribute->getFrontendInput()) { case 'Multiple Select': case 'Dropdown': foreach ($attribute->getOptions() as $option) { if ($option['is_default'] == 'Yes') { $searchValue = $option['admin']; } } break; case 'Text Field': $searchValue = $attribute->getDefaultValueText(); break; case 'Text Area': $searchValue = $attribute->getDefaultValueTextarea(); break; case 'Date': $searchValue = $attribute->getDefaultValueDate(); break; case 'Yes/No': $searchValue = $attribute->getDefaultValueYesno(); break; } return $searchValue; }
/** * Assert all product attribute options on product creation form. * * @param InjectableFixture $product * @param CatalogProductIndex $productGrid * @param CatalogProductAttribute $attribute * @param CatalogProductEdit $productEdit * @return void */ public function processAssert(InjectableFixture $product, CatalogProductIndex $productGrid, CatalogProductAttribute $attribute, CatalogProductEdit $productEdit) { $productGrid->open(); $productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]); $attributeOptions = $attribute->getOptions(); $options[] = $attribute->getFrontendLabel(); foreach ($attributeOptions as $option) { $options[] = $option['admin']; } $productAttributeOptions = $productEdit->getProductForm()->getAttributeElement($attribute)->getText(); $productOptions = explode("\n", $productAttributeOptions); $diff = array_diff($options, $productOptions); \PHPUnit_Framework_Assert::assertTrue(empty($diff), "Products attribute options are absent on product form: " . implode(', ', $diff)); }