本文整理汇总了PHP中Magento\Mtf\Fixture\FixtureInterface类的典型用法代码示例。如果您正苦于以下问题:PHP FixtureInterface类的具体用法?PHP FixtureInterface怎么用?PHP FixtureInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FixtureInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAssert
/**
* Assert that product is displayed in up-sell section
*
* @param BrowserInterface $browser
* @param FixtureInterface $product
* @param InjectableFixture[] $relatedProducts,
* @param CatalogProductView $catalogProductView
* @return void
*/
public function processAssert(BrowserInterface $browser, FixtureInterface $product, array $relatedProducts, CatalogProductView $catalogProductView)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
foreach ($relatedProducts as $relatedProduct) {
\PHPUnit_Framework_Assert::assertTrue($catalogProductView->getUpsellBlock()->isUpsellProductVisible($relatedProduct->getName()), 'Product \'' . $relatedProduct->getName() . '\' is absent in up-sells products.');
}
}
示例2: persist
/**
* Post request for creating simple product
*
* @param FixtureInterface $fixture [optional]
* @return mixed|string
* @throws \Exception
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function persist(FixtureInterface $fixture = null)
{
$config = $fixture->getDataConfig();
$prefix = isset($config['input_prefix']) ? $config['input_prefix'] : null;
// @todo remove "if" when fixtures refactored
if ($fixture instanceof InjectableFixture) {
$fields = $fixture->getData();
if ($prefix) {
$data[$prefix] = $fields;
} else {
$data = $fields;
}
} else {
$data = $this->_prepareData($fixture->getData('fields'), $prefix);
}
if ($fixture->getData('category_id')) {
$data['product']['category_ids'] = $fixture->getCategoryIds();
}
$url = $this->_getUrl($config);
$curl = new BackendDecorator(new CurlTransport(), new Config());
$curl->addOption(CURLOPT_HEADER, 1);
$curl->write(CurlInterface::POST, $url, '1.0', [], $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
throw new \Exception("Product creation by curl handler was not successful! Response: {$response}");
}
preg_match("~Location: [^\\s]*\\/id\\/(\\d+)~", $response, $matches);
return isset($matches[1]) ? $matches[1] : null;
}
示例3: getGroupedPrice
/**
* Get grouped price with fixture product and product page
*
* @param View $view
* @param FixtureInterface $product
* @return array
*/
protected function getGroupedPrice(View $view, FixtureInterface $product)
{
$fields = $product->getData();
$groupPrice['onPage'] = $view->getPriceBlock()->getSpecialPrice();
$groupPrice['fixture'] = number_format($fields['group_price'][array_search($this->customerGroup, $fields['group_price'])]['price'], 2);
return $groupPrice;
}
示例4: prepareData
/**
* Prepare data from text to values
*
* @param FixtureInterface $fixture
* @return array
*/
protected function prepareData(FixtureInterface $fixture)
{
$data = ['store' => $this->replaceMappingData($fixture->getData()), 'store_action' => 'add', 'store_type' => 'store'];
$data['store']['group_id'] = $fixture->getDataFieldConfig('group_id')['source']->getStoreGroup()->getGroupId();
$data['store']['store_id'] = isset($data['store']['store_id']) ? $data['store']['store_id'] : '';
return $data;
}
示例5: fill
/**
* Fill the customer data
*
* @param FixtureInterface $customer
* @param SimpleElement|null $element
* @return $this
*/
public function fill(FixtureInterface $customer, SimpleElement $element = null)
{
/** @var Customer $customer */
if ($customer->hasData()) {
return parent::fill($customer, $element);
}
}
示例6: prepareFilter
/**
* Prepare filter for assert.
*
* @param FixtureInterface $product
* @param array $review
* @param string $gridStatus [optional]
* @return array
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function prepareFilter(FixtureInterface $product, array $review, $gridStatus = '')
{
$filter = [];
foreach ($this->filter as $key => $item) {
list($type, $param) = [$key, $item];
if (is_numeric($key)) {
$type = $param = $item;
}
switch ($param) {
case 'name':
case 'sku':
$value = $product->getData($param);
break;
case 'select_stores':
$value = isset($review[$param]) ? $review[$param][0] : null;
break;
case 'status_id':
$value = $gridStatus != '' ? $gridStatus : (isset($review[$param]) ? $review[$param] : null);
break;
case 'type':
$value = isset($review[$param]) ? $review[$param] : 'Administrator';
break;
default:
$value = isset($review[$param]) ? $review[$param] : null;
break;
}
if ($value !== null) {
$filter += [$type => $value];
}
}
return $filter;
}
示例7: prepareData
/**
* Prepare data for POST request.
*
* @param FixtureInterface $fixture
* @return array
*/
protected function prepareData(FixtureInterface $fixture)
{
$result = [];
$data = $fixture->getData();
$result['rate'][$data['currency_from']][$data['currency_to']] = $data['rate'];
return $result;
}
示例8: fill
/**
* Fill the root form.
*
* @param FixtureInterface $fixture
* @param SimpleElement|null $element
* @param array|null $mapping
* @return $this
*/
public function fill(FixtureInterface $fixture, SimpleElement $element = null, array $mapping = null)
{
$attribute = $fixture->getDataFieldConfig('custom_attribute')['source']->getAttribute();
$mapping['custom_attribute']['selector'] = sprintf($this->inputSelector, $attribute->getAttributeCode());
$this->_fill($mapping, $element);
return $this;
}
示例9: prepareVariationsMatrix
/**
* Preparing matrix data
*
* @param FixtureInterface $product
* @return array
*/
protected function prepareVariationsMatrix(FixtureInterface $product)
{
/** @var ConfigurableAttributesData $configurableAttributesData */
$configurableAttributesData = $product->getDataFieldConfig('configurable_attributes_data')['source'];
$attributesData = $configurableAttributesData->getAttributesData();
$assignedProducts = $configurableAttributesData->getProducts();
$matrixData = $product->getConfigurableAttributesData()['matrix'];
$result = [];
foreach ($matrixData as $variationKey => $variation) {
// For assigned products doesn't send data about them
if (isset($assignedProducts[$variationKey])) {
continue;
}
$compositeKeys = explode(' ', $variationKey);
$keyIds = [];
$configurableAttribute = [];
foreach ($compositeKeys as $compositeKey) {
list($attributeKey, $optionKey) = explode(':', $compositeKey);
$attribute = $attributesData[$attributeKey];
$keyIds[] = $attribute['options'][$optionKey]['id'];
$configurableAttribute[] = sprintf('"%s":"%s"', $attribute['attribute_code'], $attribute['options'][$optionKey]['id']);
}
$keyIds = implode('-', $keyIds);
$variation['configurable_attribute'] = '{' . implode(',', $configurableAttribute) . '}';
$result[$keyIds] = $variation;
}
return $result;
}
示例10: getData
/**
* Get data of the tabs.
*
* @param FixtureInterface|null $fixture
* @param Element|null $element
* @return array
*
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getData(FixtureInterface $fixture = null, Element $element = null)
{
$data = [];
if (null === $fixture) {
foreach ($this->tabs as $tabName => $tab) {
$this->openTab($tabName);
$tabData = $this->getTabElement($tabName)->getDataFormTab();
$data = array_merge($data, $tabData);
}
} else {
$tabsFields = $fixture->hasData() ? $this->getFieldsByTabs($fixture) : [];
$tabsFields['frontend_properties'] = array_merge_recursive($tabsFields['frontend_properties'], $tabsFields['settings']);
unset($tabsFields['settings']);
foreach ($tabsFields as $tabName => $fields) {
$this->openTab($tabName);
if (isset($fields['widgetOptions'])) {
unset($fields['widgetOptions']['value']['type_id']);
$fields['widgetOptions'] = $fields['widgetOptions']['value'];
} elseif (isset($fields['layout'])) {
$fields['layout'] = $fields['layout']['value'];
}
$tabData = $this->getTabElement($tabName)->getDataFormTab($fields, $this->_rootElement);
$data = array_merge($data, $tabData);
}
}
$data['type'] = $this->type[$data['type']];
return $data;
}
示例11: getPreparedData
/**
* Prepare and return data of review
*
* @param FixtureInterface $review
* @return array
*/
protected function getPreparedData(FixtureInterface $review)
{
$data = $review->getData();
/* Prepare ratings */
if ($review->hasData('ratings')) {
$sourceRatings = $review->getDataFieldConfig('ratings')['source'];
$ratings = [];
foreach ($data['ratings'] as $rating) {
$ratings[$rating['title']] = $rating['rating'];
}
$data['ratings'] = [];
foreach ($sourceRatings->getRatings() as $ratingFixture) {
/** @var Rating $ratingFixture */
$ratingCode = $ratingFixture->getRatingCode();
if (isset($ratings[$ratingCode])) {
$ratingOptions = $ratingFixture->getOptions();
$vote = $ratings[$ratingCode];
$data['ratings'][$ratingFixture->getRatingId()] = $ratingOptions[$vote];
}
}
}
if ($review->hasData('select_stores')) {
foreach (array_keys($data['select_stores']) as $key) {
if (isset($this->mappingData['select_stores'][$data['select_stores'][$key]])) {
$data['select_stores'][$key] = $this->mappingData['select_stores'][$data['select_stores'][$key]];
}
}
}
/* Prepare product id */
$data['product_id'] = $data['entity_id'];
unset($data['entity_id']);
return $data;
}
示例12: prepareFilter
/**
* Prepare filter for assert
*
* @param FixtureInterface $product
* @param Review $review
* @param string $gridStatus
* @return array
*/
public function prepareFilter(FixtureInterface $product, Review $review, $gridStatus)
{
$filter = [];
foreach ($this->filter as $key => $item) {
list($type, $param) = [$key, $item];
if (is_numeric($key)) {
$type = $param = $item;
}
switch ($param) {
case 'name':
case 'sku':
$value = $product->getData($param);
break;
case 'select_stores':
$value = $review->getData($param)[0];
break;
case 'status_id':
$value = $gridStatus != '' ? $gridStatus : $review->getData($param);
break;
default:
$value = $review->getData($param);
break;
}
if ($value !== null) {
$filter += [$type => $value];
}
}
return $filter;
}
示例13: prepareData
/**
* Prepare data for curl.
*
* @param FixtureInterface $fixture
* @return array
*/
protected function prepareData(FixtureInterface $fixture)
{
$data = ['catalogevent' => $this->replaceMappingData($fixture->getData())];
$data['catalogevent']['display_state'] = array_values($data['catalogevent']['display_state']);
$categoryId = isset($data['catalogevent']['category_id']['id']) ? $data['catalogevent']['category_id']['id'] : $fixture->getDataFieldConfig('category_id')['source']->getCategory()->getId();
return ['data' => $data, 'categoryId' => $categoryId];
}
示例14: fillCustom
/**
* Fill form with custom fields.
* (for End To End Tests)
*
* @param FixtureInterface $fixture
* @param array $fields
* @param SimpleElement $element
*/
public function fillCustom(FixtureInterface $fixture, array $fields, SimpleElement $element = null)
{
$data = $fixture->getData('fields');
$dataForMapping = array_intersect_key($data, array_flip($fields));
$mapping = $this->dataMapping($dataForMapping);
$this->_fill($mapping, $element);
}
示例15: fill
/**
* Fill the root form.
*
* @param FixtureInterface $fixture
* @param SimpleElement|null $element
* @return $this
*/
public function fill(FixtureInterface $fixture, SimpleElement $element = null)
{
// Prepare price data
$data = $fixture->getData();
if (isset($data['price'])) {
$data = array_merge($data, $data['price']);
unset($data['price']);
}
// Mapping
$mapping = $this->dataMapping($data);
$attributeType = $attributeCode = '';
if ($fixture->hasData('custom_attribute')) {
/** @var CatalogProductAttribute $attribute */
$attribute = $fixture->getDataFieldConfig('custom_attribute')['source']->getAttribute();
$attributeType = $attribute->getFrontendInput();
$attributeCode = $attribute->getAttributeCode();
}
if ($this->hasRender($attributeType)) {
$element = $this->_rootElement->find(sprintf($this->customAttributeSelector, $attributeCode));
$arguments = ['fixture' => $fixture, 'element' => $element, 'mapping' => $mapping];
$this->callRender($attributeType, 'fill', $arguments);
} else {
$this->_fill($mapping, $element);
}
return $this;
}