本文整理匯總了PHP中Magento\Mtf\Fixture\FixtureInterface::getData方法的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureInterface::getData方法的具體用法?PHP FixtureInterface::getData怎麽用?PHP FixtureInterface::getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Mtf\Fixture\FixtureInterface
的用法示例。
在下文中一共展示了FixtureInterface::getData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* @inheritdoc
*
* @return array
*/
public function run()
{
$this->objectManager->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer])->run();
$this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Credit Cards');
$myCreditCardsBlock = $this->myCreditCardsPage->getCreditCardsBlock();
$creditCardData = $this->creditCard->getData();
$creditCardNumber = preg_grep('/([a-z]+)_number/', array_flip($creditCardData));
$lastFourDigits = substr(key($creditCardNumber), -4, 4);
$availableCreditCards = $myCreditCardsBlock->getCreditCards();
if (key_exists($lastFourDigits, $availableCreditCards)) {
$myCreditCardsBlock->deleteCreditCard($availableCreditCards[$lastFourDigits]);
}
$this->assertCreditCardDeletedMessage->processAssert($this->myCreditCardsPage);
return ['deletedCreditCard' => $lastFourDigits];
}
示例2: 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]];
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: prepareData
/**
* Prepare data from text to values
*
* @param FixtureInterface $fixture
* @return array
*/
protected function prepareData($fixture)
{
$data = $this->replaceMappingData($fixture->getData());
if (isset($data['website_ids'])) {
$websiteIds = [];
foreach ($data['website_ids'] as $websiteId) {
$websiteIds[] = isset($this->websiteIds[$websiteId]) ? $this->websiteIds[$websiteId] : $websiteId;
}
$data['website_ids'] = $websiteIds;
}
if (isset($data['customer_group_ids'])) {
$customerGroupIds = [];
foreach ($data['customer_group_ids'] as $customerGroupId) {
$customerGroupIds[] = isset($this->customerGroupIds[$customerGroupId]) ? $this->customerGroupIds[$customerGroupId] : $customerGroupId;
}
$data['customer_group_ids'] = $customerGroupIds;
}
if (!isset($data['stop_rules_processing'])) {
$data['stop_rules_processing'] = 0;
}
if (!isset($data['rule'])) {
$data['rule'] = null;
}
$data['rule'] = ['conditions' => $this->prepareCondition($data['rule'])];
return $data;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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);
}
示例10: 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;
}
示例11: persist
/**
* Post request for creating customer in frontend
*
* @param FixtureInterface|null $customer
* @return array
* @throws \Exception
*/
public function persist(FixtureInterface $customer = null)
{
$address = [];
$result = [];
/** @var Customer $customer */
$url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
$data = $customer->getData();
$data['group_id'] = $this->getCustomerGroup($customer);
if ($customer->hasData('address')) {
$address = $customer->getAddress();
unset($data['address']);
}
$curl = new CurlTransport();
$curl->write(CurlInterface::POST, $url, '1.0', [], $data);
$response = $curl->read();
$curl->close();
// After caching My Account page we cannot check by success message
if (!strpos($response, 'customer/account/logout')) {
throw new \Exception("Customer entity creating by curl handler was not successful! Response: {$response}");
}
$result['id'] = $this->getCustomerId($customer->getEmail());
$data['customer_id'] = $result['id'];
if (!empty($address)) {
$data['address'] = $address;
}
$this->updateCustomer($data);
return $result;
}
示例12: persist
/**
* Post request for creating customer in frontend.
*
* @param FixtureInterface|null $customer
* @return array
* @throws \Exception
*/
public function persist(FixtureInterface $customer = null)
{
$result = [];
/** @var Customer $customer */
$url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
$data = $customer->getData();
$data['group_id'] = $this->getCustomerGroup($customer);
if ($customer->hasData('address')) {
$data['address'] = http_build_query($data['address']);
}
$curl = new CurlTransport();
$curl->write(CurlInterface::POST, $url, '1.0', [], $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'class="success-msg"')) {
throw new \Exception("Customer entity creating by curl handler was not successful! Response: {$response}");
}
$result['id'] = $this->getCustomerId($customer->getEmail());
$data['customer_id'] = $result['id'];
if ($this->checkForUpdateData($data)) {
parse_str($data['address'], $data['address']);
$this->updateCustomer($data);
}
return $result;
}
示例13: persist
/**
* Post request for creating sales rule.
*
* @param FixtureInterface $fixture
* @return array
* @throws \Exception
*/
public function persist(FixtureInterface $fixture = null)
{
$this->mapTypeParams = array_merge($this->mapTypeParams, $this->additionalMapTypeParams);
$url = $_ENV['app_backend_url'] . 'sales_rule/promo_quote/save/';
$data = $this->replaceMappingData($fixture->getData());
$data['rule'] = [];
if (isset($data['conditions_serialized'])) {
$data['rule']['conditions'] = $this->prepareCondition($data['conditions_serialized']);
unset($data['conditions_serialized']);
}
$data['website_ids'] = $this->prepareWebsites($data);
$data['customer_group_ids'] = $this->prepareCustomerGroup($data);
if (isset($data['actions_serialized'])) {
$this->mapTypeParams['Conditions combination']['type'] = 'Magento\\SalesRule\\Model\\Rule\\Condition\\Product\\Combine';
$data['rule']['actions'] = $this->prepareCondition($data['actions_serialized']);
unset($data['actions_serialized']);
}
$curl = new BackendDecorator(new CurlTransport(), $this->_configuration);
$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("Sales rule entity creating by curl handler was not successful! Response: {$response}");
}
preg_match('`<tr.*title=".*sales_rule\\/promo_quote\\/edit\\/id\\/([\\d]+)`ims', $response, $matches);
if (empty($matches)) {
throw new \Exception('Cannot find Sales Rule id');
}
return ['id' => $matches[1]];
}
示例14: 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];
}
示例15: 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;
}