本文整理匯總了PHP中Mtf\Fixture\FixtureInterface::getDataFieldConfig方法的典型用法代碼示例。如果您正苦於以下問題:PHP FixtureInterface::getDataFieldConfig方法的具體用法?PHP FixtureInterface::getDataFieldConfig怎麽用?PHP FixtureInterface::getDataFieldConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mtf\Fixture\FixtureInterface
的用法示例。
在下文中一共展示了FixtureInterface::getDataFieldConfig方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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]];
}
示例2: 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;
}
示例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: 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;
}
示例5: 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);
}
示例6: persist
/**
* POST request for creating Customer Group
*
* @param FixtureInterface $fixture
* @return array|mixed
* @throws \Exception
*/
public function persist(FixtureInterface $fixture = null)
{
$data['code'] = $fixture->getCustomerGroupCode();
$data['tax_class'] = $fixture->getDataFieldConfig('tax_class_id')['source']->getTaxClass()->getId();
$url = $_ENV['app_backend_url'] . $this->saveUrl;
$curl = new BackendDecorator(new CurlTransport(), new Config());
$curl->addOption(CURLOPT_HEADER, 1);
$curl->write(CurlInterface::POST, $url, '1.0', array(), $data);
$response = $curl->read();
$curl->close();
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
throw new \Exception("Customer Group entity creating by curl handler was not successful! Response: {$response}");
}
return ['customer_group_id' => $this->getCustomerGroupId($data, $response)];
}
示例7: prepareFixtureData
/**
* Prepares fixture data for comparison
*
* @param array $data
* @param FixtureInterface $product
* @param array $sortFields [optional]
* @return array
*/
protected function prepareFixtureData(array $data, FixtureInterface $product, array $sortFields = [])
{
if (isset($data['website_ids']) && !is_array($data['website_ids'])) {
$data['website_ids'] = [$data['website_ids']];
}
if (isset($data['custom_options'])) {
$data['custom_options'] = $product->getDataFieldConfig('custom_options')['source']->getCustomOptions();
}
if (!empty($this->specialArray)) {
$data = $this->prepareSpecialPriceArray($data);
}
foreach ($sortFields as $path) {
$data = $this->sortDataByPath($data, $path);
}
return $data;
}
示例8: fill
/**
* Fill the root form
*
* @param FixtureInterface $fixture
* @param Element|null $element
* @param array $replace [optional]
* @return $this
*/
public function fill(FixtureInterface $fixture, Element $element = null, array $replace = [])
{
$data = $fixture->getData();
if (empty($this->getData()['target_path']) && !isset($data['target_path'])) {
$entity = $fixture->getDataFieldConfig('id_path')['source']->getEntity();
$data['target_path'] = $entity->hasData('identifier') ? $entity->getIdentifier() : $entity->getUrlKey() . '.html';
}
foreach ($replace as $key => $pairs) {
if (isset($data[$key])) {
$data[$key] = str_replace(array_keys($pairs), $pairs, $data[$key]);
}
}
// TODO: delete line after removing old fixture
$fields = isset($data['fields']) ? $data['fields'] : $data;
$mapping = $this->dataMapping($fields);
$this->_fill($mapping, $element);
return $this;
}
示例9: persist
/**
* Post request for creating Attribute Set
*
* @param FixtureInterface $fixture
* @return array
* @throws \Exception
*/
public function persist(FixtureInterface $fixture = null)
{
$data = $fixture->getData();
if (!isset($data['gotoEdit'])) {
$data['gotoEdit'] = 1;
}
$data['skeleton_set'] = $fixture->getDataFieldConfig('skeleton_set')['source']->getAttributeSet()->getAttributeSetId();
$url = $_ENV['app_backend_url'] . 'catalog/product_set/save/';
$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*?)\\/.*?data-ui-id=\\"page-actions-toolbar-delete-button\\".*`', $response, $matches);
$id = isset($matches[1]) ? $matches[1] : null;
if (!strpos($response, 'data-ui-id="messages-message-success"')) {
throw new \Exception("Attribute Set creating by curl handler was not successful!");
}
return ['attribute_set_id' => $id];
}
示例10: prepareData
/**
* Returns data for curl POST params
*
* @param FixtureInterface $fixture
* @return mixed
*
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
protected function prepareData($fixture)
{
$data = $fixture->getData();
$fields = ['tax_rate', 'tax_customer_class', 'tax_product_class'];
foreach ($fields as $field) {
if (!array_key_exists($field, $data)) {
$data[$field][] = $this->defaultTaxClasses[$field];
continue;
}
$fieldFixture = $fixture->getDataFieldConfig($field);
$fieldFixture = $fieldFixture['source']->getFixture();
foreach ($data[$field] as $key => $value) {
$id = $fieldFixture[$key]->getId();
if ($id === null) {
$fieldFixture[$key]->persist();
$id = $fieldFixture[$key]->getId();
}
$data[$field][$key] = $id;
}
}
return $data;
}
示例11: prepareData
/**
* Prepare POST data for creating product request
*
* @param FixtureInterface $fixture
* @param string|null $prefix [optional]
* @return array
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function prepareData(FixtureInterface $fixture, $prefix = null)
{
$fields = $this->replaceMappingData($fixture->getData());
// Getting Tax class id
if ($fixture->hasData('tax_class_id')) {
$taxClassId = $fixture->getDataFieldConfig('tax_class_id')['source']->getTaxClass()->getId();
$fields['tax_class_id'] = $taxClassId === null ? $this->getTaxClassId($fields['tax_class_id']) : $taxClassId;
}
if (!empty($fields['category_ids'])) {
$categoryIds = [];
foreach ($fields['category_ids'] as $categoryData) {
$categoryIds[] = $categoryData['id'];
}
$fields['category_ids'] = $categoryIds;
}
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;
}
$fields = $this->prepareStockData($fields);
return $prefix ? [$prefix => $fields] : $fields;
}
示例12: 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);
}
}
示例13: prepareOptions
/**
* Preparation options before comparing
*
* @param FixtureInterface $product
* @param int|null $actualPrice
* @return array
*
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function prepareOptions(FixtureInterface $product, $actualPrice = null)
{
$result = [];
$customOptions = $product->hasData('custom_options') ? $product->getDataFieldConfig('custom_options')['source']->getCustomOptions() : null;
$actualPrice = $actualPrice ? $actualPrice : $product->getPrice();
foreach ($customOptions as $customOption) {
$skippedField = isset($this->skippedFieldOptions[$customOption['type']]) ? $this->skippedFieldOptions[$customOption['type']] : [];
foreach ($customOption['options'] as &$option) {
// recalculate percent price
if ('Percent' == $option['price_type']) {
$option['price'] = $actualPrice * $option['price'] / 100;
$option['price'] = round($option['price'], 2);
}
$option = array_diff_key($option, array_flip($skippedField));
}
$result[$customOption['title']] = $customOption;
}
return $result;
}
示例14: 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());
// 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['group_price'])) {
$fields['group_price'] = $this->preparePriceData($fields['group_price']);
}
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;
}
$fields = $this->prepareStockData($fields);
$fields = $prefix ? [$prefix => $fields] : $fields;
if ($isCustomOptions) {
$fields['affect_product_custom_options'] = 1;
}
return $fields;
}
示例15: 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();
$matrixData = $product->getConfigurableAttributesData()['matrix'];
$result = [];
foreach ($matrixData as $variationKey => $variation) {
$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;
}