/**
  * Prepare data.
  *
  * @param FixtureFactory $fixtureFactory
  * @param Customer $customer
  * @return array
  */
 public function __prepare(FixtureFactory $fixtureFactory, Customer $customer)
 {
     $product = $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => '100_dollar_product']);
     $product->persist();
     $customer->persist();
     return ['product' => $product, 'customer' => $customer];
 }
예제 #2
0
 /**
  * @constructor
  * @param array $params
  * @param array $data
  * @param FixtureFactory|null $fixtureFactory
  */
 public function __construct(array $params, array $data, FixtureFactory $fixtureFactory)
 {
     $this->params = $params;
     $this->data = !isset($data['preset']) && !isset($data['import_products']) ? $data : [];
     $this->customOptions = $this->data;
     if (isset($data['preset'])) {
         $this->data = $this->replaceData($this->getPreset($data['preset']), mt_rand());
         $this->customOptions = $this->data;
     }
     if (isset($data['import_products'])) {
         $importData = explode(',', $data['import_products']);
         $importCustomOptions = [];
         $importProducts = [];
         foreach ($importData as $item) {
             list($fixture, $dataSet) = explode('::', $item);
             $product = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]);
             if ($product->hasData('id') !== null) {
                 $product->persist();
             }
             $importCustomOptions = array_merge($importCustomOptions, $product->getCustomOptions());
             $importProducts[] = $product->getSku();
         }
         $this->customOptions = array_merge($this->data, $importCustomOptions);
         $this->data['import'] = ['options' => $importCustomOptions, 'products' => $importProducts];
     }
 }
예제 #3
0
 /**
  * Constructor
  *
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $data
  * @param array $params [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $data, array $params = [])
 {
     $this->params = $params;
     $this->data = !isset($data['preset']) ? $data : [];
     if (isset($data['preset'])) {
         $this->data = $this->getPreset($data['preset']);
         if (!empty($data['products'])) {
             $this->data['products'] = [];
             $this->data['products'] = explode('|', $data['products']);
             foreach ($this->data['products'] as $key => $products) {
                 $this->data['products'][$key] = explode(',', $products);
             }
         }
     }
     if (!empty($this->data['products'])) {
         $productsSelections = $this->data['products'];
         $this->data['products'] = [];
         foreach ($productsSelections as $index => $products) {
             $productSelection = [];
             foreach ($products as $key => $product) {
                 if ($product instanceof FixtureInterface) {
                     $productSelection[$key] = $product;
                     continue;
                 }
                 list($fixture, $dataSet) = explode('::', $product);
                 $productSelection[$key] = $fixtureFactory->createByCode($fixture, ['dataSet' => $dataSet]);
                 $productSelection[$key]->persist();
                 $this->data['bundle_options'][$index]['assigned_products'][$key]['search_data']['name'] = $productSelection[$key]->getName();
             }
             $this->data['products'][] = $productSelection;
         }
     }
 }
 /**
  * Create custom admin user and setup configuration.
  *
  * @param FixtureFactory $fixtureFactory
  * @return array
  */
 public function __prepare(FixtureFactory $fixtureFactory)
 {
     $adminUser = $fixtureFactory->createByCode('user', ['dataSet' => 'custom_admin']);
     $adminUser->persist();
     $this->objectManager->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'max_admin_login_failures'])->run();
     return ['adminUser' => $adminUser];
 }
예제 #5
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param string $data
  * @param array $params [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, $data, array $params = [])
 {
     $this->params = $params;
     $explodedData = explode('::', $data);
     switch (sizeof($explodedData)) {
         case 1:
             $this->data = $explodedData[0];
             break;
         case 3:
             list($fixture, $dataset, $field) = $explodedData;
             $entity = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
             if (!$entity->hasData('id')) {
                 $entity->persist();
             }
             $this->data = $entity->getData($field);
             $this->entity = $entity;
             break;
         case 4:
             list($fixture, $dataset, $source, $field) = $explodedData;
             $entity = $fixtureFactory->createByCode($fixture, ['dataset' => $dataset]);
             if (!$entity->hasData('id')) {
                 $entity->persist();
             }
             $source = $source == 'product' ? $entity->getEntityId()['products'][0] : $entity->getData($source);
             $this->data = $source->getData($field);
             $this->entity = $entity;
             break;
     }
 }
 /**
  * Injection data
  *
  * @param CatalogProductIndex $productGrid
  * @param CatalogProductEdit $editProductPage
  * @param Category $category
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function __inject(CatalogProductIndex $productGrid, CatalogProductEdit $editProductPage, Category $category, FixtureFactory $fixtureFactory)
 {
     $this->product = $fixtureFactory->createByCode('catalogProductVirtual', ['dataset' => 'default', 'data' => ['category_ids' => ['category' => $category]]]);
     $this->product->persist();
     $this->productGrid = $productGrid;
     $this->editProductPage = $editProductPage;
 }
예제 #7
0
 /**
  * @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['dataset'])) {
         $productsList = array_map('trim', explode(',', $data['dataset']));
         foreach ($productsList as $productData) {
             list($fixtureCode, $dataset) = explode('::', $productData);
             $this->products[] = $fixtureFactory->createByCode($fixtureCode, ['dataset' => $dataset]);
         }
     }
     if (isset($data['products'])) {
         foreach ($data['products'] as $product) {
             $this->products[] = $product;
         }
     }
     foreach ($this->products as $product) {
         if (!$product->hasData('id')) {
             $product->persist();
         }
         $this->data[] = ['id' => $product->getId(), 'name' => $product->getName(), 'sku' => $product->getSku()];
     }
     if (isset($data['data'])) {
         $this->data = array_replace_recursive($this->data, $data['data']);
     }
 }
예제 #8
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (!empty($data['category']) && empty($data['dataset']) && $data['category'] instanceof Category) {
         /** @var Category $category */
         $category = $data['category'];
         if (!$category->hasData('id')) {
             $category->persist();
         }
         $this->data[] = $category->getName();
         $this->categories[] = $category;
     } elseif (isset($data['dataset'])) {
         $datasets = explode(',', $data['dataset']);
         foreach ($datasets as $dataset) {
             if (trim($dataset) == '-') {
                 $this->data[] = '';
                 continue;
             }
             $category = $fixtureFactory->createByCode('category', ['dataset' => $dataset]);
             if (!isset($data['new_category']) || $data['new_category'] !== 'yes') {
                 $category->persist();
             }
             /** @var Category $category */
             $this->data[] = $category->getName();
             $this->categories[] = $category;
         }
     }
 }
예제 #9
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (!empty($data['category']) && empty($data['presets'])) {
         /** @var CatalogCategory $category */
         $category = $data['category'];
         if (!$category->hasData('id')) {
             $category->persist();
         }
         $this->data[] = $category->getName();
         $this->categories[] = $category;
     } elseif (isset($data['presets'])) {
         $presets = explode(',', $data['presets']);
         foreach ($presets as $preset) {
             $category = $fixtureFactory->createByCode('catalogCategory', ['dataSet' => $preset]);
             $category->persist();
             /** @var CatalogCategory $category */
             $this->data[] = $category->getName();
             $this->categories[] = $category;
         }
     }
     if (!empty($this->categories) && count($this->categories) == 1) {
         $this->productCategory = $this->categories[0];
     }
 }
 /**
  * Check whether the attribute filter is displayed on the frontend in Layered navigation.
  *
  * @param CatalogCategoryView $catalogCategoryView
  * @param InjectableFixture $product
  * @param CatalogProductAttribute $attribute
  * @param CmsIndex $cmsIndex
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function processAssert(CatalogCategoryView $catalogCategoryView, InjectableFixture $product, CatalogProductAttribute $attribute, CmsIndex $cmsIndex, FixtureFactory $fixtureFactory)
 {
     $fixtureFactory->createByCode('catalogProductSimple', ['dataSet' => 'product_with_category_with_anchor', 'data' => ['category_ids' => ['presets' => null, 'category' => $product->getDataFieldConfig('category_ids')['source']->getCategories()[0]]]])->persist();
     $cmsIndex->open()->getTopmenu()->selectCategoryByName($product->getCategoryIds()[0]);
     $label = $attribute->hasData('manage_frontend_label') ? $attribute->getManageFrontendLabel() : $attribute->getFrontendLabel();
     \PHPUnit_Framework_Assert::assertTrue(in_array($label, $catalogCategoryView->getLayeredNavigationBlock()->getFilters()), 'Attribute is absent in layered navigation on category page.');
 }
 /**
  * @param OrderCreateIndex $orderCreateIndex
  * @param array $payment
  * @param FixtureFactory $fixtureFactory
  * @param $creditCardClass
  * @param array $creditCard
  * @param string $creditCardSave
  */
 public function __construct(OrderCreateIndex $orderCreateIndex, array $payment, FixtureFactory $fixtureFactory, $creditCardClass, array $creditCard, $creditCardSave = 'No')
 {
     $this->orderCreatePage = $orderCreateIndex;
     $this->payment = $payment;
     $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]);
     $this->creditCardSave = $creditCardSave;
 }
예제 #12
0
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param DataInterface $configuration
  * @param array $params
  * @param array|string $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, DataInterface $configuration, array $params, $data = [])
 {
     $this->params = $params;
     $this->configuration = $configuration;
     if (!isset($data['dataSet']) && !isset($data['tax_product_class'])) {
         $this->data = $data;
         return;
     }
     if (isset($data['dataSet'])) {
         $this->taxClass = $fixtureFactory->createByCode('taxClass', ['dataSet' => $data['dataSet']]);
         $this->data = $this->taxClass->getClassName();
         if (!$this->taxClass->hasData('id')) {
             $this->taxClass->persist();
         }
     }
     if (isset($data['tax_product_class']) && $data['tax_product_class'] instanceof FixtureTaxClass) {
         $this->taxClass = $data['tax_product_class'];
         $this->data = $this->taxClass->getClassName();
     }
     if ($this->taxClass->hasData('id')) {
         $this->taxClassId = $this->taxClass->getId();
     } else {
         $this->setTaxClassId($this->data);
     }
 }
 /**
  * Filling objects of the class
  *
  * @param CatalogProductIndex $catalogProductIndexNewPage
  * @param CatalogProductEdit $catalogProductEditPage
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function __inject(CatalogProductIndex $catalogProductIndexNewPage, CatalogProductEdit $catalogProductEditPage, FixtureFactory $fixtureFactory)
 {
     $this->product = $fixtureFactory->createByCode('downloadableProduct', ['dataset' => 'default']);
     $this->product->persist();
     $this->catalogProductIndex = $catalogProductIndexNewPage;
     $this->catalogProductEdit = $catalogProductEditPage;
 }
 /**
  * Create new order via curl.
  *
  * @return array
  */
 public function run()
 {
     /** @var Order $order */
     $order = $this->fixtureFactory->createByCode('order', ['dataSet' => $this->orderDataSet]);
     $order->persist();
     return ['order' => $order];
 }
 /**
  * @constructor
  * @param RepositoryFactory $repositoryFactory
  * @param FixtureFactory $fixtureFactory
  * @param array $params
  * @param array $data [optional]
  */
 public function __construct(RepositoryFactory $repositoryFactory, FixtureFactory $fixtureFactory, array $params, array $data = [])
 {
     $this->params = $params;
     if (isset($data['dataset']) && isset($this->params['repository'])) {
         $datasets = $repositoryFactory->get($this->params['repository'])->get($data['dataset']);
         foreach ($datasets as $dataset) {
             list($fixtureCode, $dataset) = explode('::', $dataset);
             $this->products[] = $fixtureFactory->createByCode($fixtureCode, ['dataset' => $dataset]);
         }
     }
     if (isset($data['products'])) {
         foreach ($data['products'] as $product) {
             $this->products[] = $product;
         }
     }
     foreach ($this->products as $product) {
         if (!$product->hasData('id')) {
             $product->persist();
         }
         $this->data[] = ['entity_id' => $product->getId(), 'name' => $product->getName(), 'sku' => $product->getSku()];
     }
     if (isset($data['data'])) {
         $this->data = array_replace_recursive($this->data, $data['data']);
     }
 }
 /**
  * Prepare magento customer for test and delete all tax rules.
  *
  * @param FixtureFactory $fixtureFactory
  * @return array
  */
 public function __prepare(FixtureFactory $fixtureFactory)
 {
     $this->objectManager->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
     $magentoCustomer = $fixtureFactory->create('Mage\\Customer\\Test\\Fixture\\Customer', ['dataSet' => 'default']);
     $magentoCustomer->persist();
     return ['customer' => $magentoCustomer];
 }
 /**
  * Prepare environment for test.
  *
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function __prepare(FixtureFactory $fixtureFactory)
 {
     // Delete existing tax rules.
     $this->objectManager->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
     // Create US tax rule
     $taxRule = $fixtureFactory->createByCode('taxRule', ['dataSet' => 'us_tax_rule']);
     $taxRule->persist();
 }
 /**
  * @constructor
  * @param OrderCreateIndex $orderCreateIndex
  * @param array $payment
  * @param FixtureFactory $fixtureFactory
  * @param string $creditCardClass
  * @param array|CreditCard|null $creditCard
  */
 public function __construct(OrderCreateIndex $orderCreateIndex, array $payment, FixtureFactory $fixtureFactory, $creditCardClass = 'credit_card', array $creditCard = null)
 {
     $this->orderCreateIndex = $orderCreateIndex;
     $this->payment = $payment;
     if (isset($creditCard['dataset'])) {
         $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]);
     }
 }
예제 #19
0
 /**
  * @constructor
  * @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['dataSet'])) {
         $address = $fixtureFactory->createByCode('address', ['dataSet' => $data['dataSet']]);
         $this->data = $address->getData();
     }
 }
 /**
  * @constructor
  * @param CheckoutOnepage $checkoutOnepage
  * @param array $payment
  * @param FixtureFactory $fixtureFactory
  * @param string $creditCardClass
  * @param array|CreditCard|null $creditCard
  */
 public function __construct(CheckoutOnepage $checkoutOnepage, array $payment, FixtureFactory $fixtureFactory, $creditCardClass = 'credit_card', $creditCard = null)
 {
     $this->checkoutOnepage = $checkoutOnepage;
     $this->payment = $payment;
     if (isset($creditCard['dataset'])) {
         $this->creditCard = $fixtureFactory->createByCode($creditCardClass, ['dataset' => $creditCard['dataset']]);
     }
 }
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param CheckoutMultishippingBilling $checkoutMultishippingBilling
  * @param array $payment
  */
 public function __construct(FixtureFactory $fixtureFactory, CheckoutMultishippingBilling $checkoutMultishippingBilling, array $payment)
 {
     $this->checkoutMultishippingBilling = $checkoutMultishippingBilling;
     if (isset($payment['cc']) && !$payment['cc'] instanceof Cc) {
         $payment['cc'] = $fixtureFactory->create('Mage\\Payment\\Test\\Fixture\\Cc', ['dataSet' => $payment['cc']]);
     }
     $this->payment = $payment;
 }
 /**
  * Prepare VAT ID confguration.
  *
  * @param ConfigData $vatConfig
  * @param string $customerGroup
  * @return void
  */
 protected function prepareVatConfig(ConfigData $vatConfig, $customerGroup)
 {
     $groupConfig = ['customer/create_account/viv_domestic_group' => ['value' => $this->vatGroups['valid_domestic_group']->getCustomerGroupId()], 'customer/create_account/viv_intra_union_group' => ['value' => $this->vatGroups['valid_intra_union_group']->getCustomerGroupId()], 'customer/create_account/viv_invalid_group' => ['value' => $this->vatGroups['invalid_group']->getCustomerGroupId()], 'customer/create_account/viv_error_group' => ['value' => $this->vatGroups['error_group']->getCustomerGroupId()]];
     $vatConfig = $this->fixtureFactory->createByCode('configData', ['data' => array_replace_recursive($vatConfig->getSection(), $groupConfig)]);
     $vatConfig->persist();
     $customerData = array_merge($this->customer->getData(), ['group_id' => ['value' => $this->vatGroups[$customerGroup]->getCustomerGroupCode()]], ['address' => ['addresses' => $this->customer->getDataFieldConfig('address')['source']->getAddresses()]]);
     $this->customer = $this->fixtureFactory->createByCode('customer', ['data' => $customerData]);
 }
 /**
  * Create order with PayPal standard test.
  *
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function test(FixtureFactory $fixtureFactory)
 {
     // Preconditions:
     // Create US tax rule. @TODO: Move to __prepare() after implementing MAGETWO-29331.
     $taxRule = $fixtureFactory->createByCode('taxRule', ['dataSet' => 'us_tax_rule']);
     $taxRule->persist();
     $this->executeScenario();
 }
예제 #24
0
 /**
  * Fill Sales Data.
  *
  * @return array
  */
 public function run()
 {
     $this->orderCreateIndex->getCreateBlock()->submitOrder();
     $this->salesOrderView->getMessagesBlock()->waitSuccessMessage();
     $orderId = trim($this->salesOrderView->getTitleBlock()->getTitle(), '#');
     $order = $this->fixtureFactory->createByCode('orderInjectable', ['data' => ['id' => $orderId, 'customer_id' => ['customer' => $this->customer], 'entity_id' => ['products' => $this->products], 'billing_address_id' => ['billingAddress' => $this->billingAddress]]]);
     return ['orderId' => $orderId, 'order' => $order];
 }
 /**
  * Inject page
  *
  * @param UrlRewriteEdit $urlRewriteEdit
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param FixtureFactory $fixtureFactory
  * @return array
  */
 public function __inject(UrlRewriteEdit $urlRewriteEdit, UrlRewriteIndex $urlRewriteIndex, FixtureFactory $fixtureFactory)
 {
     $this->urlRewriteEdit = $urlRewriteEdit;
     $this->urlRewriteIndex = $urlRewriteIndex;
     $category = $fixtureFactory->createByCode('category', ['dataSet' => 'default_subcategory']);
     $category->persist();
     return ['category' => $category];
 }
 /**
  * Assert product details.
  *
  * @param WishlistIndex $wishlistIndex
  * @param InjectableFixture $product
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 protected function assertProductDetails(WishlistIndex $wishlistIndex, InjectableFixture $product, FixtureFactory $fixtureFactory)
 {
     $actualOptions = $wishlistIndex->getItemsBlock()->getItemProduct($product)->getOptions();
     $cartFixture = $fixtureFactory->createByCode('cart', ['data' => ['items' => ['products' => [$product]]]]);
     $expectedOptions = $cartFixture->getItems()[0]->getData()['options'];
     $errors = $this->verifyData($this->sortDataByPath($expectedOptions, '::title'), $this->sortDataByPath($actualOptions, '::title'));
     \PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
 }
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param CheckoutOnepage $checkoutOnepage
  * @param array $payment
  */
 public function __construct(FixtureFactory $fixtureFactory, CheckoutOnepage $checkoutOnepage, array $payment)
 {
     if (isset($payment['cc']) && !$payment['cc'] instanceof Cc) {
         $payment['cc'] = $fixtureFactory->create('Mage\\Payment\\Test\\Fixture\\Cc', ['dataSet' => $payment['cc']]);
     }
     $this->payment = $payment;
     $this->checkoutOnepage = $checkoutOnepage;
 }
 /**
  * Prepare datasets and pages
  *
  * @param UrlRewriteIndex $urlRewriteIndex
  * @param UrlRewriteEdit $urlRewriteEdit
  * @param FixtureFactory $fixtureFactory
  * @param Category $category
  * @return array
  */
 public function __inject(UrlRewriteIndex $urlRewriteIndex, UrlRewriteEdit $urlRewriteEdit, FixtureFactory $fixtureFactory, Category $category)
 {
     $this->urlRewriteIndex = $urlRewriteIndex;
     $this->urlRewriteEdit = $urlRewriteEdit;
     $category->persist();
     $categoryRedirect = $fixtureFactory->createByCode('urlRewrite', ['dataset' => 'default', 'data' => ['target_path' => $category->getUrlKey() . '.html']]);
     $categoryRedirect->persist();
     return ['categoryRedirect' => $categoryRedirect, 'category' => $category];
 }
 /**
  * Set Default Attribute Value.
  *
  * @return void
  */
 public function run()
 {
     $customAttribute = $this->attribute;
     if ($this->attributeValue !== null) {
         $customAttribute = ['value' => $this->attributeValue, 'attribute' => $customAttribute];
     }
     $product = $this->fixtureFactory->createByCode('catalogProductSimple', ['data' => ['custom_attribute' => $customAttribute]]);
     $this->catalogProductEdit->getProductForm()->fill($product);
 }
 /**
  * Assert that created CMS block displayed on frontend category page (in order to assign block to category:
  * go to category page> Display settings> CMS Block).
  *
  * @param CmsIndex $cmsIndex
  * @param CmsBlock $cmsBlock
  * @param CatalogCategoryView $catalogCategoryView
  * @param FixtureFactory $fixtureFactory
  * @return void
  */
 public function processAssert(CmsIndex $cmsIndex, CmsBlock $cmsBlock, CatalogCategoryView $catalogCategoryView, FixtureFactory $fixtureFactory)
 {
     $category = $fixtureFactory->createByCode('category', ['dataset' => 'default_subcategory', 'data' => ['display_mode' => 'Static block and products', 'landing_page' => $cmsBlock->getTitle()]]);
     $category->persist();
     $cmsIndex->open();
     $cmsIndex->getTopmenu()->selectCategoryByName($category->getName());
     $categoryViewContent = $catalogCategoryView->getViewBlock()->getContent();
     \PHPUnit_Framework_Assert::assertEquals($cmsBlock->getContent(), $categoryViewContent, 'Wrong block content on category is displayed.');
 }