本文整理汇总了PHP中Magento\Mtf\Fixture\InjectableFixture::getSku方法的典型用法代码示例。如果您正苦于以下问题:PHP InjectableFixture::getSku方法的具体用法?PHP InjectableFixture::getSku怎么用?PHP InjectableFixture::getSku使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Mtf\Fixture\InjectableFixture
的用法示例。
在下文中一共展示了InjectableFixture::getSku方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPrice
/**
* Returns the item price for the specified product.
*
* @param InjectableFixture $product
* @return array|string
*/
public function getPrice(InjectableFixture $product)
{
$productName = $product->getName();
if ($product instanceof ConfigurableProduct) {
// Find the price for the specific configurable product that was purchased
$attributesData = $product->getConfigurableAttributesData()['attributes_data'];
$matrix = $product->getConfigurableAttributesData()['matrix'];
$checkoutOptions = $product->getCheckoutData()['options']['configurable_options'];
$optionsDetails = [];
$matrixKey = [];
$optionsPrice = 0;
foreach ($checkoutOptions as $checkoutOption) {
$titleKey = $checkoutOption['title'];
$valueKey = $checkoutOption['value'];
$attributeName = $attributesData[$titleKey]['frontend_label'];
$optionLabel = $attributesData[$titleKey]['options'][$valueKey]['label'];
$optionsDetails[] = "{$attributeName}{$optionLabel}";
$matrixKey[] = "{$titleKey}:{$valueKey}";
$optionsPrice += $attributesData[$titleKey]['options'][$valueKey]['pricing_value'];
}
$optionsDetails = implode(' ', $optionsDetails);
$matrixKey = implode(' ', $matrixKey);
$productDisplay = $productName . 'SKU: ' . $matrix[$matrixKey]['sku'] . $optionsDetails;
} else {
$productDisplay = $productName . 'SKU: ' . $product->getSku();
}
$selector = '//tr[normalize-space(td)="' . $productDisplay . '"]' . $this->priceSelector;
return $this->escapeCurrency($this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText());
}
示例2: processAssert
/**
* Assert that video is not displayed in admin panel.
*
* @param CatalogProductIndex $productGrid
* @param InjectableFixture $product
* @return void
*/
public function processAssert(CatalogProductIndex $productGrid, InjectableFixture $product)
{
$filter = ['sku' => $product->getSku()];
$productGrid->open();
$productGrid->getProductGrid()->search($filter);
$src = $productGrid->getProductGrid()->getBaseImageSource();
\PHPUnit_Framework_Assert::assertTrue(strpos($src, '/placeholder/') !== false, 'Product image is displayed in product grid when it should not');
}
示例3: processAssert
/**
* Assert that video data received from external service is correct.
*
* @param CatalogProductIndex $productGrid
* @param CatalogProductEdit $editProductPage
* @param InjectableFixture $product
* @param array $video
* @return void
*/
public function processAssert(CatalogProductIndex $productGrid, CatalogProductEdit $editProductPage, InjectableFixture $product, array $video)
{
$productGrid->open();
$productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
$editProductPage->getProductForm()->openSection('images-and-videos');
$imagesTab = $editProductPage->getProductForm()->getSection('images-and-videos');
$result = $imagesTab->clickFirstVideo()->getVideoDialog()->validate($video);
\PHPUnit_Framework_Assert::assertTrue($result, 'Video data received from external service is not correct.');
}
示例4: getAssociatedItems
/**
* Get associated items for grouped product.
*
* @param InjectableFixture $product
* @return array
*/
protected function getAssociatedItems(InjectableFixture $product)
{
$cartItems = [];
/** @var GroupedProduct $product */
$associatedProducts = $product->getDataFieldConfig('associated')['source']->getProducts();
foreach ($associatedProducts as $product) {
$cartItems[$product->getSku()] = parent::getCartItem($product);
}
return $cartItems;
}
示例5: processAssert
/**
* Check whether the attribute is mandatory.
*
* @param CatalogProductIndex $catalogProductIndex
* @param CatalogProductEdit $catalogProductEdit
* @param CatalogProductAttribute $attribute
* @param InjectableFixture $product
* @return void
*/
public function processAssert(CatalogProductIndex $catalogProductIndex, CatalogProductEdit $catalogProductEdit, CatalogProductAttribute $attribute, InjectableFixture $product)
{
$catalogProductIndex->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
$productForm = $catalogProductEdit->getProductForm();
$productForm->getAttributeElement($attribute)->setValue('');
$catalogProductEdit->getFormPageActions()->save();
$failedAttributes = $productForm->getRequireNoticeAttributes($product);
$actualMessage = $failedAttributes['product-details'][$attribute->getFrontendLabel()];
\PHPUnit_Framework_Assert::assertEquals(self::REQUIRE_MESSAGE, $actualMessage, 'JS error notice on product edit page is not equal to expected.');
}
示例6: processAssert
/**
* Assert that configurable options available on configurable product Edit form on backend.
*
* @param CatalogProduct $catalogProductIndex
* @param CatalogProductEdit $catalogProductEdit
* @param CatalogProductAttribute $attribute
* @param InjectableFixture $product
* @return void
*/
public function processAssert(CatalogProduct $catalogProductIndex, CatalogProductEdit $catalogProductEdit, CatalogProductAttribute $attribute, InjectableFixture $product)
{
$options = $attribute->getOptions();
$attributeOptionsFromFixture = [];
foreach ($options as $option) {
$attributeOptionsFromFixture[] = $option['admin'];
}
$catalogProductIndex->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
$productForm = $catalogProductEdit->getProductForm();
$attributeOptions = $productForm->getAttributeElement($attribute)->getValues();
\PHPUnit_Framework_Assert::assertEquals($attributeOptionsFromFixture, $attributeOptions);
}
示例7: processAssert
/**
* Assert form data equals fixture data.
*
* @param InjectableFixture $product
* @param CatalogProduct $productGrid
* @param CatalogProductEdit $productPage
* @return void
*/
public function processAssert(InjectableFixture $product, CatalogProduct $productGrid, CatalogProductEdit $productPage)
{
$this->catalogProductEdit = $productPage;
$filter = ['sku' => $product->getSku()];
$productGrid->open();
$productGrid->getProductGrid()->searchAndOpen($filter);
$productData = $product->getData();
$fixtureData = $this->prepareFixtureData($productData, $this->sortFields);
$formData = $this->prepareFormData($productPage->getProductForm()->getData($product), $this->sortFields);
$error = $this->verifyData($fixtureData, $formData);
\PHPUnit_Framework_Assert::assertTrue(empty($error), $error);
}
示例8: processAssert
/**
* Check whether the attribute is mandatory.
*
* @param CatalogProductIndex $catalogProductIndex
* @param CatalogProductEdit $catalogProductEdit
* @param CatalogProductAttribute $attribute
* @param InjectableFixture $product
* @param string $sectionName
* @return void
*/
public function processAssert(CatalogProductIndex $catalogProductIndex, CatalogProductEdit $catalogProductEdit, CatalogProductAttribute $attribute, InjectableFixture $product, $sectionName)
{
$catalogProductIndex->open()->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
$productForm = $catalogProductEdit->getProductForm();
if (!$productForm->checkAttributeLabel($attribute)) {
$productForm->openSection($sectionName);
}
$productForm->getAttributeElement($attribute)->setValue('');
$catalogProductEdit->getFormPageActions()->save();
$validationErrors = $productForm->getSection($sectionName)->getValidationErrors();
$actualMessage = isset($validationErrors[$attribute->getFrontendLabel()]) ? $validationErrors[$attribute->getFrontendLabel()] : '';
\PHPUnit_Framework_Assert::assertEquals(self::REQUIRE_MESSAGE, $actualMessage, 'JS error notice on product edit page is not equal to expected.');
}
示例9: processAssert
/**
* 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));
}
示例10: getPrice
/**
* Returns the item price for the specified product.
*
* @param InjectableFixture $product
* @return array|string
*/
public function getPrice(InjectableFixture $product)
{
$productName = $product->getName();
if ($product instanceof ConfigurableProduct) {
// Find the price for the specific configurable product that was purchased
$configurableAttributes = $product->getConfigurableAttributes();
$productOptions = $product->getCheckoutData()['options']['configurable_options'];
$checkoutOption = reset($productOptions);
$attributeKey = $checkoutOption['title'];
$optionKey = $checkoutOption['value'];
$attributeValue = $configurableAttributes[$attributeKey]['label']['value'];
$optionValue = $configurableAttributes[$attributeKey][$optionKey]['option_label']['value'];
$productDisplay = $productName . ' SKU: ' . $product->getVariationSku($checkoutOption);
$productDisplay .= ' ' . $attributeValue . ' ' . $optionValue;
} else {
$productDisplay = $productName . ' SKU: ' . $product->getSku();
}
$selector = '//tr[normalize-space(td)="' . $productDisplay . '"]' . $this->priceSelector;
return $this->_rootElement->find($selector, Locator::SELECTOR_XPATH)->getText();
}
示例11: isNotDisplayingOnFrontendAssert
/**
* Verify product displaying on frontend.
*
* @param InjectableFixture $product
* @return array
*/
protected function isNotDisplayingOnFrontendAssert(InjectableFixture $product)
{
$errors = [];
//Check that product is not available by url
$this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
if ($this->catalogProductView->getViewBlock()->isVisible()) {
$errors[] = '- product view block is visible in product page.';
}
//Check that product can't be found
$this->cmsIndex->open()->getSearchBlock()->search($product->getSku());
if ($this->catalogSearchResult->getListProductBlock()->isProductVisible($product)) {
$errors[] = '- successful product search.';
}
//Check that product is not available in category page
$categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $this->category->getName();
$this->cmsIndex->open()->getTopmenu()->selectCategory($categoryName);
$isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product);
$bottomToolBar = $this->catalogCategoryView->getBottomToolbar();
while (!$isProductVisible && $bottomToolBar->nextPage()) {
$isProductVisible = $this->catalogCategoryView->getListProductBlock()->isProductVisible($product);
}
if ($isProductVisible) {
$errors[] = "- product with name '{$product->getName()}' is found in this category.";
}
return $errors;
}
示例12: processAssert
/**
* Assert that created attribute is displayed on product form.
*
* @param InjectableFixture $product
* @param CatalogProduct $productGrid
* @param CatalogProductEdit $productEdit
* @param CatalogProductAttribute $attribute
* @return void
*/
public function processAssert(InjectableFixture $product, CatalogProduct $productGrid, CatalogProductEdit $productEdit, CatalogProductAttribute $attribute)
{
$productGrid->open();
$productGrid->getProductGrid()->searchAndOpen(['sku' => $product->getSku()]);
\PHPUnit_Framework_Assert::assertTrue($productEdit->getProductForm()->checkAttributeLabel($attribute->getData()), "Product Attribute is absent on Product form.");
}
示例13: run
/**
* Open products on backend.
*
* @return void
*/
public function run()
{
$this->catalogProductIndex->open();
$this->catalogProductIndex->getProductGrid()->searchAndOpen(['sku' => $this->product->getSku()]);
}
示例14: processAssert
/**
* Assert that product cannot be found via Quick Search using searchable product attributes.
*
* @param CatalogsearchResult $catalogSearchResult
* @param CmsIndex $cmsIndex
* @param InjectableFixture $product
* @return void
*/
public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, InjectableFixture $product)
{
$cmsIndex->open();
$cmsIndex->getSearchBlock()->search($product->getSku());
\PHPUnit_Framework_Assert::assertFalse($catalogSearchResult->getListProductBlock()->isProductVisible($product), 'Product was found by SKU.');
}
示例15: assert
/**
* Check product on product grid.
*
* @param InjectableFixture $product
* @param CatalogProduct $productGrid
* @return void
*/
public function assert(InjectableFixture $product, CatalogProduct $productGrid)
{
$filter = ['sku' => $product->getSku(), 'name' => $product->getName()];
\PHPUnit_Framework_Assert::assertFalse($productGrid->getProductGrid()->isRowVisible($filter), "Product with sku {$filter['sku']} and name {$filter['name']} is present in Products grid.");
}