/** * Check whether there is an opportunity to compare products using given attribute. * * @param InjectableFixture $product * @param CatalogProductAttribute $attribute * @param BrowserInterface $browser * @param CatalogProductView $catalogProductView * @param CatalogProductCompare $catalogProductCompare * @return void */ public function processAssert(InjectableFixture $product, CatalogProductAttribute $attribute, BrowserInterface $browser, CatalogProductView $catalogProductView, CatalogProductCompare $catalogProductCompare) { $browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); $catalogProductView->getViewBlock()->clickAddToCompare(); $catalogProductCompare->open(); $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel(); \PHPUnit_Framework_Assert::assertTrue($catalogProductCompare->getCompareProductsBlock()->isAttributeVisible($label), 'Attribute is absent on product compare page.'); }
/** * Prepare attribute data. * * @param InjectableFixture $product * @param int $key * @return array */ protected function prepareAttributeData(InjectableFixture $product, $key) { $data = []; foreach ($this->attributeProduct as $attributeKey => $attribute) { $value = $attribute; $attribute = is_numeric($attributeKey) ? $attribute : $attributeKey; $attributeValue = $attribute != 'price' ? $product->hasData($attribute) ? $product->getData($attribute) : 'N/A' : ($product->getDataFieldConfig('price')['source']->getPreset() !== null ? $product->getDataFieldConfig('price')['source']->getPreset() : number_format($product->getPrice(), 2)); $data['attributeValues'][$attribute] = !is_array($attributeValue) ? strtolower($attributeValue) : $attributeValue; $attributeName = $value === 'name' || $value === 'price' ? 'Info' : 'MetaData'; $data['attributeValuesFromPage'][$attribute] = $this->comparePage->getCompareProductsBlock()->{'getProduct' . $attributeName}($key + 1, $value); } return $data; }