本文整理匯總了PHP中Mtf\Fixture\FixtureInterface::hasData方法的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureInterface::hasData方法的具體用法?PHP FixtureInterface::hasData怎麽用?PHP FixtureInterface::hasData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mtf\Fixture\FixtureInterface
的用法示例。
在下文中一共展示了FixtureInterface::hasData方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getOptions
/**
* Get configurable product options
*
* @param FixtureInterface|null $product [optional]
* @return array
* @throws \Exception
*/
public function getOptions(FixtureInterface $product)
{
if ($product instanceof InjectableFixture) {
/** @var ConfigurableProductInjectable $product */
$attributesData = $product->hasData('configurable_attributes_data') ? $product->getConfigurableAttributesData()['attributes_data'] : [];
} else {
/** @var ConfigurableProduct $product */
$attributesData = $product->getConfigurableAttributes();
foreach ($attributesData as $key => $attributeData) {
$attributeData['label'] = $attributeData['label']['value'];
$attributeData['frontend_input'] = 'dropdown';
$attributesData[$key] = $attributeData;
}
}
$listOptions = $this->getListOptions();
$result = [];
foreach ($attributesData as $option) {
$title = $option['label'];
if (!isset($listOptions[$title])) {
throw new \Exception("Can't find option: \"{$title}\"");
}
/** @var Element $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';
$result[$title] = $optionData;
}
return $result;
}
示例2: 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;
}
示例3: 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 ($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]];
}
示例4: 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 CustomerInjectable $customer */
$url = $_ENV['app_frontend_url'] . 'customer/account/createpost/?nocookie=true';
$data = $customer->getData();
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();
if (!strpos($response, 'data-ui-id="global-messages-message-success"')) {
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->addAddress($data);
}
return $result;
}
示例5: getDataCustomer
/**
* Get data of Customer information, addresses on tabs.
*
* @param FixtureInterface $customer
* @param FixtureInterface|FixtureInterface[]|null $address
* @return array
*/
public function getDataCustomer(FixtureInterface $customer, $address = null)
{
$data = ['customer' => $customer->hasData() ? parent::getData($customer) : parent::getData()];
if (null !== $address) {
$this->openTab('addresses');
$data['addresses'] = $this->getTabElement('addresses')->getDataAddresses($address);
}
return $data;
}
示例6: __construct
/**
* @param FixtureFactory $fixtureFactory
* @param array $params
* @param array $data [optional]
*/
public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
{
$this->params = $params;
if (!isset($data['entity']) || $data['entity'] === '-') {
$this->data = array_shift($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']);
}
}
示例7: persist
/**
* Post request for creating Attribute Set
*
* @param FixtureInterface|null $fixture
* @return array
*
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function persist(FixtureInterface $fixture = null)
{
/** @var CatalogAttributeSet $fixture */
$response = $fixture->hasData('attribute_set_id') ? $this->getDefaultAttributeSet($fixture) : $this->createAttributeSet($fixture);
$attributeSetId = $fixture->hasData('attribute_set_id') ? $fixture->getAttributeSetId() : $this->getData($this->attributeSetId, $response);
$assignedAttributes = $fixture->hasData('assigned_attributes') ? $fixture->getDataFieldConfig('assigned_attributes')['source']->getAttributes() : [];
$dataAttribute = $this->getDataAttributes($response);
$lastAttribute = array_pop($dataAttribute['attributes']);
foreach ($assignedAttributes as $key => $assignedAttribute) {
$dataAttribute['attributes'][] = [$assignedAttribute->getAttributeId(), $dataAttribute['groups'][0][0], $lastAttribute[2] + ($key + 1), null];
}
$this->updateAttributeSet($attributeSetId, $dataAttribute);
return ['attribute_set_id' => $attributeSetId];
}
示例8: __construct
/**
* @constructor
* @param FixtureInterface $product
*/
public function __construct(FixtureInterface $product)
{
/** @var CatalogProductSimple $product */
$checkoutData = $product->getCheckoutData();
$cartItem = isset($checkoutData['cartItem']) ? $checkoutData['cartItem'] : [];
$customOptions = $product->hasData('custom_options') ? $product->getCustomOptions() : [];
$checkoutCustomOptions = isset($checkoutData['options']['custom_options']) ? $checkoutData['options']['custom_options'] : [];
foreach ($checkoutCustomOptions as $key => $checkoutCustomOption) {
$attribute = str_replace('attribute_key_', '', $checkoutCustomOption['title']);
$option = str_replace('option_key_', '', $checkoutCustomOption['value']);
$checkoutCustomOptions[$key] = ['title' => isset($customOptions[$attribute]['title']) ? $customOptions[$attribute]['title'] : $attribute, 'value' => isset($customOptions[$attribute]['options'][$option]['title']) ? $customOptions[$attribute]['options'][$option]['title'] : $option];
}
$cartItem['options'] = isset($cartItem['options']) ? $cartItem['options'] + $checkoutCustomOptions : $checkoutCustomOptions;
$this->data = $cartItem;
}
示例9: processAssert
/**
* Assert form data equals fixture data
*
* @param FixtureInterface $product
* @param CatalogProductIndex $productGrid
* @param CatalogProductEdit $productPage
* @return void
*/
public function processAssert(FixtureInterface $product, CatalogProductIndex $productGrid, CatalogProductEdit $productPage)
{
$filter = ['sku' => $product->getSku()];
$productGrid->open();
$productGrid->getProductGrid()->searchAndOpen($filter);
$productData = $product->getData();
if ($product->hasData('custom_options')) {
$customOptionsSource = $product->getDataFieldConfig('custom_options')['source'];
$productData['custom_options'] = $customOptionsSource->getCustomOptions();
}
$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);
}
示例10: processAssert
/**
* Assert that product is visible in the assigned category
*
* @param CatalogCategoryView $catalogCategoryView
* @param CmsIndex $cmsIndex
* @param FixtureInterface $product
* @param CatalogCategory|null $category
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, CatalogCategory $category = null)
{
$categoryName = $product->hasData('category_ids') ? $product->getCategoryIds()[0] : $category->getName();
$cmsIndex->open();
$cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
while (!$isProductVisible && $catalogCategoryView->getBottomToolbar()->nextPage()) {
$isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
}
if ($product->getVisibility() === 'Search' || $this->getStockStatus($product) === 'Out of Stock') {
$isProductVisible = !$isProductVisible;
$this->errorMessage = 'Product found in this category.';
$this->successfulMessage = 'Asserts that the product could not be found in this category.';
}
\PHPUnit_Framework_Assert::assertTrue($isProductVisible, $this->errorMessage);
}
示例11: processAssert
/**
* Assert that product can be searched via Quick Search using searchable product attributes (Search by SKU)
*
* @param CatalogsearchResult $catalogSearchResult
* @param CmsIndex $cmsIndex
* @param FixtureInterface $product
* @return void
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function processAssert(CatalogsearchResult $catalogSearchResult, CmsIndex $cmsIndex, FixtureInterface $product)
{
$cmsIndex->open();
$sku = $product->hasData('sku') !== false ? $product->getSku() : $product->getName();
$cmsIndex->getSearchBlock()->search($sku);
$quantityAndStockStatus = $product->getQuantityAndStockStatus();
$stockStatus = isset($quantityAndStockStatus['is_in_stock']) ? $quantityAndStockStatus['is_in_stock'] : null;
$isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName());
while (!$isVisible && $catalogSearchResult->getBottomToolbar()->nextPage()) {
$isVisible = $catalogSearchResult->getListProductBlock()->isProductVisible($product->getName());
}
if ($product->getVisibility() === 'Catalog' || $stockStatus === 'Out of Stock') {
$isVisible = !$isVisible;
list($this->errorMessage, $this->successfulMessage) = [$this->successfulMessage, $this->errorMessage];
}
\PHPUnit_Framework_Assert::assertTrue($isVisible, $this->errorMessage);
}
示例12: processAssert
/**
* Checking the product in the page of its price
*
* @param CatalogCategoryView $catalogCategoryView
* @param CmsIndex $cmsIndex
* @param FixtureInterface $product
* @param CatalogCategory $category
* @return void
*/
public function processAssert(CatalogCategoryView $catalogCategoryView, CmsIndex $cmsIndex, FixtureInterface $product, CatalogCategory $category)
{
// Open category view page and check visible product
$categoryName = $category->getName();
if ($product->hasData('category_ids')) {
$categoryIds = $product->getCategoryIds();
$categoryName = is_array($categoryIds) ? reset($categoryIds) : $categoryName;
}
$cmsIndex->open();
$cmsIndex->getTopmenu()->selectCategoryByName($categoryName);
$isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
while (!$isProductVisible && $catalogCategoryView->getToolbar()->nextPage()) {
$isProductVisible = $catalogCategoryView->getListProductBlock()->isProductVisible($product->getName());
}
\PHPUnit_Framework_Assert::assertTrue($isProductVisible, 'Product is absent on category page.');
//Process price asserts
$this->assertPrice($product, $catalogCategoryView);
}
示例13: prepareOptionArray
/**
* Preparation options before comparing
*
* @param array $options
* @return array
*/
protected function prepareOptionArray(array $options)
{
$result = [];
$productPrice = $this->product->hasData('group_price') ? $this->product->getGroupPrice()[0]['price'] : $this->product->getPrice();
$placeholder = ['Yes' => true, 'No' => false];
foreach ($options as $option) {
$result[$option['title']]['is_require'] = $placeholder[$option['is_require']];
$result[$option['title']]['title'] = $option['title'];
$result[$option['title']]['price'] = [];
foreach ($option['options'] as $optionValue) {
if ($optionValue['price_type'] === 'Percent') {
$optionValue['price'] = $productPrice / 100 * $optionValue['price'];
}
$result[$option['title']]['price'][] = number_format($optionValue['price'], 2);
}
}
return $result;
}
示例14: persist
/**
* Post request for creating Product Attribute
*
* @param FixtureInterface|null $fixture [optional]
* @return array
* @throws \Exception
*/
public function persist(FixtureInterface $fixture = null)
{
$data = $this->replaceMappingData($fixture->getData());
$data['frontend_label'] = [0 => $data['frontend_label']];
if (isset($data['options'])) {
foreach ($data['options'] as $key => $values) {
if ($values['is_default'] == 'Yes') {
$data['default'][] = $values['view'];
}
$index = 'option_' . $key;
$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(), new Config());
$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 Attribute creating by curl handler was not successful!");
}
$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 ($matches[1] as $key => $optionId) {
$optionsData[$key]['id'] = $optionId;
}
$resultData['options'] = $optionsData;
}
return $resultData;
}
示例15: fillOptions
/**
* Fill in the option specified for the product
*
* @param FixtureInterface $product
* @return void
*/
public function fillOptions(FixtureInterface $product)
{
$dataConfig = $product->getDataConfig();
$typeId = isset($dataConfig['type_id']) ? $dataConfig['type_id'] : null;
/** @var CatalogProductSimple $product */
if ($this->hasRender($typeId)) {
$this->callRender($typeId, 'fillOptions', ['product' => $product]);
} else {
$optionsCheckoutData = [];
if ($product instanceof InjectableFixture) {
/** @var CatalogProductSimple $product */
$customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : [];
$checkoutData = $product->getCheckoutData();
$productCheckoutData = isset($checkoutData['custom_options']) ? $checkoutData['custom_options'] : [];
$optionsCheckoutData = $this->prepareCheckoutData($customOptions, $productCheckoutData);
}
$this->getCustomOptionsBlock()->fillCustomOptions($optionsCheckoutData);
}
}