本文整理汇总了PHP中Magento\Mtf\Fixture\FixtureInterface::hasData方法的典型用法代码示例。如果您正苦于以下问题:PHP FixtureInterface::hasData方法的具体用法?PHP FixtureInterface::hasData怎么用?PHP FixtureInterface::hasData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Mtf\Fixture\FixtureInterface
的用法示例。
在下文中一共展示了FixtureInterface::hasData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: prepareFilter
/**
* Prepare filter for product grid.
*
* @return array
*/
protected function prepareFilter()
{
$productStatus = $this->product->getStatus() === null || $this->product->getStatus() === 'Product online' ? 'Enabled' : 'Disabled';
$filter = ['type' => $this->getProductType(), 'sku' => $this->product->getSku(), 'status' => $productStatus];
if ($this->product->hasData('attribute_set_id')) {
$filter['set_name'] = $this->product->getAttributeSetId();
}
return $filter;
}
示例3: prepareData
/**
* Prepare data from text to values
*
* @param FixtureInterface $fixture
* @return array
*/
protected function prepareData(FixtureInterface $fixture)
{
$categoryId = $fixture->getDataFieldConfig('root_category_id')['source']->getCategory()->getId();
$websiteId = $fixture->getDataFieldConfig('website_id')['source']->getWebsite()->getWebsiteId();
$data = ['group' => ['name' => $fixture->getName(), 'root_category_id' => $categoryId, 'website_id' => $websiteId, 'group_id' => $fixture->hasData('group_id') ? $fixture->getGroupId() : ''], 'store_action' => 'add', 'store_type' => 'group'];
return $data;
}
示例4: persist
/**
* Curl creation of Admin User Role
*
* @param FixtureInterface $fixture
* @return array|mixed
* @throws \Exception
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function persist(FixtureInterface $fixture = null)
{
$data = $fixture->getData();
$data['all'] = $data['resource_access'] == 'All' ? 1 : 0;
if (isset($data['roles_resources'])) {
foreach ((array) $data['roles_resources'] as $resource) {
$data['resource'][] = $resource;
}
}
unset($data['roles_resources']);
$data['gws_is_all'] = isset($data['gws_is_all']) ? $data['gws_is_all'] : '1';
if ($fixture->hasData('in_role_user')) {
$adminUsers = $fixture->getDataFieldConfig('in_role_user')['source']->getAdminUsers();
$userIds = [];
foreach ($adminUsers as $adminUser) {
$userIds[] = $adminUser->getUserId() . "=true";
}
$data['in_role_user'] = implode('&', $userIds);
}
$url = $_ENV['app_backend_url'] . 'admin/user_role/saverole/active_tab/info/';
$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("Role creating by curl handler was not successful! Response: {$response}");
}
$url = 'admin/user_role/roleGrid/sort/role_id/dir/desc/';
$regExpPattern = '/class=\\"\\scol\\-id col\\-role_id\\W*>\\W+(\\d+)\\W+<\\/td>\\W+<td[\\w\\s\\"=\\-]*?>\\W+?' . $data['rolename'] . '/siu';
$extractor = new Extractor($url, $regExpPattern);
return ['role_id' => $extractor->getData()[1]];
}
示例5: 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;
}
示例6: assertPrice
/**
* Verify product price on category view page.
*
* @param FixtureInterface $bundle
* @param CatalogCategoryView $catalogCategoryView
* @return void
*/
protected function assertPrice(FixtureInterface $bundle, CatalogCategoryView $catalogCategoryView)
{
/** @var BundleProduct $bundle */
$priceData = $bundle->getDataFieldConfig('price')['source']->getPreset();
//Price from/to verification
$priceBlock = $catalogCategoryView->getListProductBlock()->getProductPriceBlock($bundle->getName());
if ($bundle->hasData('special_price') || $bundle->hasData('group_price')) {
$priceLow = $priceBlock->getFinalPrice();
} else {
$priceLow = $bundle->getPriceView() == 'Price Range' ? $priceBlock->getPriceFrom() : $priceBlock->getRegularPrice();
}
\PHPUnit_Framework_Assert::assertEquals($priceData['price_from'], $priceLow, 'Bundle price From on category page is not correct.');
if ($bundle->getPriceView() == 'Price Range') {
\PHPUnit_Framework_Assert::assertEquals($priceData['price_to'], $priceBlock->getPriceTo(), 'Bundle price To on category page is not correct.');
}
}
示例7: 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);
}
}
示例8: 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;
}
示例9: getOptions
/**
* Get configurable product options
*
* @param FixtureInterface|null $product [optional]
* @return array
* @throws \Exception
*/
public function getOptions(FixtureInterface $product)
{
/** @var ConfigurableProduct $product */
$attributesData = $product->hasData('configurable_attributes_data') ? $product->getConfigurableAttributesData()['attributes_data'] : [];
$listOptions = $this->getListOptions();
$result = [];
foreach ($attributesData as $option) {
$title = $option['label'];
if (!isset($listOptions[$title])) {
throw new \Exception("Can't find option: \"{$title}\"");
}
/** @var SimpleElement $optionElement */
$optionElement = $listOptions[$title];
$typeMethod = preg_replace('/[^a-zA-Z]/', '', $option['frontend_input']);
$getTypeData = 'get' . ucfirst(strtolower($typeMethod)) . 'Data';
$optionData = $this->{$getTypeData}($optionElement);
$optionData['title'] = $title;
$optionData['type'] = $option['frontend_input'];
$optionData['is_require'] = $optionElement->find($this->required, Locator::SELECTOR_XPATH)->isVisible() ? 'Yes' : 'No';
foreach ($optionData['options'] as $key => $value) {
$optionData['options'][$key]['price'] = $this->getOptionPrice($title, $value['title']);
}
$result[$title] = $optionData;
}
return $result;
}
示例10: getData
/**
* Get data of the tabs.
*
* @param FixtureInterface $fixture
* @param SimpleElement $element
* @return array
* @throws \Exception
*
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getData(FixtureInterface $fixture = null, SimpleElement $element = null)
{
$this->waitForElementVisible($this->propertiesTab);
$data = [];
if (null === $fixture) {
foreach ($this->tabs as $tabName => $tab) {
if ($this->isTabVisible($tabName)) {
$this->openTab($tabName);
$this->expandAllToggles();
$tabData = $this->getTabElement($tabName)->getDataFormTab();
$data = array_merge($data, $tabData);
}
}
} else {
$isHasData = $fixture instanceof InjectableFixture ? $fixture->hasData() : true;
$tabsFields = $isHasData ? $this->getFieldsByTabs($fixture) : [];
foreach ($tabsFields as $tabName => $fields) {
if ($this->isTabVisible($tabName)) {
$this->openTab($tabName);
$this->expandAllToggles();
$tabData = $this->getTabElement($tabName)->getDataFormTab($fields, $this->_rootElement);
$data = array_merge($data, $tabData);
}
}
}
return $data;
}
示例11: fill
/**
* Fill the root form.
*
* @param FixtureInterface $review
* @param SimpleElement|null $element
* @return $this
*/
public function fill(FixtureInterface $review, SimpleElement $element = null)
{
if ($review->hasData('ratings')) {
$this->fillRatings($review);
}
return parent::fill($review, $element);
}
示例12: prepareData
/**
* Prepare POST data for creating product request.
*
* @param FixtureInterface $fixture
* @param string|null $prefix [optional]
* @return array
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function prepareData(FixtureInterface $fixture, $prefix = null)
{
$fields = $this->replaceMappingData($fixture->getData());
if (!isset($fields['status'])) {
// Default product is enabled
$fields['status'] = 1;
}
if (!isset($fields['visibility'])) {
// Default product is visible on Catalog, Search
$fields['visibility'] = 4;
}
// Getting Tax class id
if ($fixture->hasData('tax_class_id')) {
$fields['tax_class_id'] = $fixture->getDataFieldConfig('tax_class_id')['source']->getTaxClassId();
}
if (!empty($fields['category_ids'])) {
$categoryIds = [];
foreach ($fixture->getDataFieldConfig('category_ids')['source']->getCategories() as $category) {
$categoryIds[] = $category->getId();
}
$fields['category_ids'] = $categoryIds;
}
if (isset($fields['tier_price'])) {
$fields['tier_price'] = $this->preparePriceData($fields['tier_price']);
}
if (isset($fields['fpt'])) {
$attributeLabel = $fixture->getDataFieldConfig('attribute_set_id')['source']->getAttributeSet()->getDataFieldConfig('assigned_attributes')['source']->getAttributes()[0]->getFrontendLabel();
$fields[$attributeLabel] = $this->prepareFptData($fields['fpt']);
}
if ($isCustomOptions = isset($fields['custom_options'])) {
$fields = $this->prepareCustomOptionsData($fields);
}
if (!empty($fields['website_ids'])) {
foreach ($fields['website_ids'] as &$value) {
$value = isset($this->mappingData['website_ids'][$value]) ? $this->mappingData['website_ids'][$value] : $value;
}
}
// Getting Attribute Set id
if ($fixture->hasData('attribute_set_id')) {
$attributeSetId = $fixture->getDataFieldConfig('attribute_set_id')['source']->getAttributeSet()->getAttributeSetId();
$fields['attribute_set_id'] = $attributeSetId;
}
// Prepare assigned attribute
if (isset($fields['attributes'])) {
$fields += $fields['attributes'];
unset($fields['attributes']);
}
if (isset($fields['custom_attribute'])) {
$fields[$fields['custom_attribute']['code']] = $fields['custom_attribute']['value'];
}
$fields = $this->prepareStockData($fields);
$fields = $prefix ? [$prefix => $fields] : $fields;
if ($isCustomOptions) {
$fields['affect_product_custom_options'] = 1;
}
return $fields;
}
示例13: __construct
/**
* @param FixtureFactory $fixtureFactory
* @param array $params
* @param string $data [optional]
*/
public function __construct(FixtureFactory $fixtureFactory, array $params, $data = '')
{
$this->params = $params;
if (!isset($data['entity']) || $data['entity'] === '-') {
$this->data = $data;
return;
}
preg_match('`%(.*?)%`', $data['entity'], $dataSet);
$entityConfig = isset($dataSet[1]) ? explode('::', $dataSet[1]) : [];
if (count($entityConfig) > 1) {
/** @var FixtureInterface $fixture */
$this->entity = $fixtureFactory->createByCode($entityConfig[0], ['dataSet' => $entityConfig[1]]);
$this->entity->persist();
$id = $this->entity->hasData('id') ? $this->entity->getId() : $this->entity->getPageId();
$this->data = preg_replace('`(%.*?%)`', $id, $data['entity']);
} else {
$this->data = strval($data['entity']);
}
}
示例14: persist
/**
* Post request for creating Product Attribute
*
* @param FixtureInterface|null $fixture [optional]
* @return array
* @throws \Exception
*/
public function persist(FixtureInterface $fixture = null)
{
if ($fixture->hasData('attribute_id')) {
return ['attribute_id' => $fixture->getData('attribute_id')];
}
$data = $this->replaceMappingData($fixture->getData());
$data['frontend_label'] = [0 => $data['frontend_label']];
if (isset($data['options'])) {
foreach ($data['options'] as $key => $values) {
$index = 'option_' . $key;
if ($values['is_default'] == 'Yes') {
$data['default'][] = $index;
}
$data['option']['value'][$index] = [$values['admin'], $values['view']];
$data['option']['order'][$index] = $key;
}
unset($data['options']);
}
$url = $_ENV['app_backend_url'] . 'catalog/product_attribute/save/back/edit';
$curl = new BackendDecorator(new CurlTransport(), $this->_configuration);
$curl->write($url, $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
throw new \Exception("Product Attribute creating by curl handler was not successful! \n" . $response);
}
$resultData = [];
$matches = [];
preg_match('#attribute_id[^>]+value="(\\d+)"#', $response, $matches);
$resultData['attribute_id'] = $matches[1];
$matches = [];
preg_match_all('#"id":"(\\d+)"#Umi', $response, $matches);
if ($fixture->hasData('options')) {
$optionsData = $fixture->getData()['options'];
foreach (array_unique($matches[1]) as $key => $optionId) {
$optionsData[$key]['id'] = $optionId;
}
$resultData['options'] = $optionsData;
}
return $resultData;
}
示例15: prepareData
/**
* Prepare data for create widget.
*
* @param FixtureInterface $widget
* @return array
*/
protected function prepareData(FixtureInterface $widget)
{
$data = $this->replaceMappingData($widget->getData());
if ($widget->hasData('store_ids')) {
$data['store_ids'][0] = $widget->getDataFieldConfig('store_ids')['source']->getStores()[0]->getStoreId();
}
unset($data['code']);
unset($data['theme_id']);
$data = $this->prepareWidgetInstance($data);
$data = $this->prepareParameters($data);
return $data;
}