本文整理匯總了PHP中Mtf\Fixture\FixtureInterface類的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureInterface類的具體用法?PHP FixtureInterface怎麽用?PHP FixtureInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了FixtureInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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;
}
示例2: prepareFilter
/**
* Prepare filter for assert
*
* @param FixtureInterface $product
* @param ReviewInjectable $review
* @param string $gridStatus
* @return array
*/
public function prepareFilter(FixtureInterface $product, ReviewInjectable $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;
}
示例3: prepareData
/**
* Prepare data from text to values
*
* @param FixtureInterface $fixture
* @return array
*/
protected function prepareData(FixtureInterface $fixture)
{
$data['store'] = $this->replaceMappingData($fixture->getData());
$data['store_action'] = isset($data['store_action']) ? $data['store_action'] : 'add';
$data['store_type'] = isset($data['store_type']) ? $data['store_type'] : 'store';
return $data;
}
示例4: 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;
}
示例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)
{
$groupPrice['onPage'] = $view->getProductPrice();
$groupPrice['onPage'] = isset($groupPrice['onPage']['price_regular_price']) ? str_replace('As low as $', '', $groupPrice['onPage']['price_regular_price']) : str_replace('$', '', $groupPrice['onPage']['price_from']);
$groupPrice['fixture'] = $product->getDataFieldConfig('price')['source']->getPreset()['price_from'];
return $groupPrice;
}
示例6: 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;
}
示例7: persist
/**
* Post request for creating Subcategory
*
* @param FixtureInterface $fixture [optional]
* @return mixed|string
*/
public function persist(FixtureInterface $fixture = null)
{
$data['general'] = $fixture->getData();
foreach ($data['general'] as $key => $value) {
if ($value == 'Yes') {
$data['general'][$key] = 1;
}
if ($value == 'No') {
$data['general'][$key] = 0;
}
}
$diff = array_diff($this->dataUseConfig, array_keys($data['general']));
if (!empty($diff)) {
$data['use_config'] = $diff;
}
$parentCategoryId = $data['general']['parent_id'];
$url = $_ENV['app_backend_url'] . 'catalog/category/save/store/0/parent/' . $parentCategoryId . '/';
$curl = new BackendDecorator(new CurlTransport(), new Config());
$curl->write(CurlInterface::POST, $url, '1.0', array(), $data);
$response = $curl->read();
$curl->close();
preg_match('#http://.+/id/(\\d+).+store/#m', $response, $matches);
$id = isset($matches[1]) ? $matches[1] : null;
return ['id' => $id];
}
示例8: 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]];
}
示例9: processAssert
/**
* Assert that displayed product data on product page(front-end) equals passed from fixture:
* 1. Product Name
* 2. Price
* 3. Special price
* 4. SKU
* 5. Description
* 6. Short Description
*
* @param Browser $browser
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @return void
*/
public function processAssert(Browser $browser, CatalogProductView $catalogProductView, FixtureInterface $product)
{
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$this->product = $product;
$this->productView = $catalogProductView->getViewBlock();
$errors = $this->verify();
\PHPUnit_Framework_Assert::assertEmpty($errors, "\nFound the following errors:\n" . implode(" \n", $errors));
}
示例10: 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->getData('sku')];
$productGrid->open()->getProductGrid()->searchAndOpen($filter);
$fields = $this->convertDownloadableArray($this->prepareFixtureData($product));
$fieldsForm = $productPage->getForm()->getData($product);
\PHPUnit_Framework_Assert::assertEquals($fields, $fieldsForm, 'Form data not equals fixture data.');
}
示例11: init
/**
* Page initialization
*
* @param FixtureInterface $fixture
* @return void
*/
public function init(FixtureInterface $fixture)
{
$dataConfig = $fixture->getDataConfig();
$params = isset($dataConfig['create_url_params']) ? $dataConfig['create_url_params'] : array();
foreach ($params as $paramName => $paramValue) {
$this->_url .= '/' . $paramName . '/' . $paramValue;
}
}
示例12: prepareData
/**
* Prepare data from text to values
*
* @param FixtureInterface $fixture
* @return array
*/
protected function prepareData(FixtureInterface $fixture)
{
$data['store'] = $this->replaceMappingData($fixture->getData());
$data['store_action'] = isset($data['store_action']) ? $data['store_action'] : 'add';
$data['store_type'] = isset($data['store_type']) ? $data['store_type'] : 'store';
$data['store']['group_id'] = $fixture->getDataFieldConfig('group_id')['source']->getStoreGroup()->getGroupId();
return $data;
}
示例13: assertPrice
/**
* Verify product special price on product view page
*
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @param string $block [optional]
* @return void
*/
public function assertPrice(FixtureInterface $product, CatalogProductView $catalogProductView, $block = '')
{
$fields = $product->getData();
$specialPrice = $catalogProductView->getViewBlock()->getPriceBlock()->getSpecialPrice();
if (isset($fields['special_price'])) {
\PHPUnit_Framework_Assert::assertEquals(number_format($fields['special_price'], 2), $specialPrice, $this->errorMessage);
}
}
示例14: persist
/**
* Create product
*
* @param FixtureInterface $fixture [optional]
* @return mixed|string
*/
public function persist(FixtureInterface $fixture = null)
{
Factory::getApp()->magentoBackendLoginUser();
$createProductPage = Factory::getPageFactory()->getCatalogProductNew();
$createProductPage->open(['type' => $fixture->getDataConfig()['create_url_params']['type'], 'set' => $fixture->getDataConfig()['create_url_params']['set']]);
$createProductPage->getProductForm()->fill($fixture);
$createProductPage->getFormPageActions()->save();
$createProductPage->getMessagesBlock()->assertSuccessMessage();
}
示例15: processAssert
/**
* Assertion that tier prices are displayed correctly
*
* @param CatalogProductView $catalogProductView
* @param FixtureInterface $product
* @param Browser $browser
* @return void
*/
public function processAssert(CatalogProductView $catalogProductView, FixtureInterface $product, Browser $browser)
{
//Open product view page
$browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$viewBlock = $catalogProductView->getViewBlock();
$viewBlock->clickCustomize();
//Process assertions
$this->assertPrice($product, $catalogProductView);
}