示例#1
0
 /**
  * initialize data
  */
 protected function _initData()
 {
     /** @var \Magento\Mtf\System\Config $systemConfig */
     $systemConfig = ObjectManager::getInstance()->create('Magento\\Mtf\\System\\Config');
     $superAdminPassword = $systemConfig->getConfigParam('application/backend_user_credentials/password');
     $this->_data = ['fields' => ['email' => ['value' => '*****@*****.**'], 'firstname' => ['value' => 'firstname%isolation%'], 'lastname' => ['value' => 'lastname%isolation%'], 'password' => ['value' => '%password%'], 'password_confirmation' => ['value' => '%password%'], 'roles' => ['value' => ['1']], 'username' => ['value' => 'admin%isolation%'], 'current_password' => ['value' => $superAdminPassword]]];
 }
示例#2
0
 /**
  * @constructor
  * @param array $params
  * @param array $data
  */
 public function __construct(array $params, array $data = [])
 {
     $this->params = $params;
     $this->products = isset($data['products']) ? $data['products'] : [];
     foreach ($this->products as $product) {
         $classItem = 'Magento\\' . $this->getModuleName($product) . '\\Test\\Fixture\\Cart\\Item';
         $item = ObjectManager::getInstance()->create($classItem, ['product' => $product]);
         $this->data[] = $item;
     }
 }
 /**
  * @construct
  * @param array $params
  * @param string $data
  */
 public function __construct(array $params, $data = '')
 {
     $this->params = $params;
     /** @var \Magento\Mtf\Config\DataInterface $systemConfig */
     if ($data == '%current_password%') {
         $systemConfig = ObjectManager::getInstance()->create('Magento\\Mtf\\Config\\DataInterface');
         $data = $systemConfig->get('application/0/backendPassword/0/value');
     }
     $this->data = $data;
 }
 /**
  * Prepare data
  *
  * @param array $viewsReport
  * @return array
  */
 protected function prepareData(array $viewsReport)
 {
     foreach ($viewsReport as $key => $reportFilter) {
         if (in_array($key, $this->dateFields)) {
             $date = ObjectManager::getInstance()->create('\\Magento\\Backend\\Test\\Fixture\\Source\\Date', ['params' => [], 'data' => ['pattern' => $reportFilter]]);
             $viewsReport[$key] = $date->getData();
         }
     }
     return $viewsReport;
 }
示例#5
0
 /**
  * Open backend page and log in if needed.
  *
  * @param array $params
  * @return $this
  */
 public function open(array $params = [])
 {
     $systemConfig = ObjectManager::getInstance()->create('Magento\\Mtf\\Config\\DataInterface');
     $admin = ['username' => ['value' => $systemConfig->get('application/0/backendLogin/0/value')], 'password' => ['value' => $systemConfig->get('application/0/backendPassword/0/value')]];
     $this->adminAuthLogin = ObjectManager::getInstance()->create('Mage\\Adminhtml\\Test\\Page\\AdminAuthLogin');
     $this->dashboard = ObjectManager::getInstance()->create('Mage\\Adminhtml\\Test\\Page\\Adminhtml\\Dashboard');
     if (!$this->dashboard->getAdminPanelHeader()->isVisible()) {
         $this->loginSuperAdmin($admin);
     }
     return parent::open($params);
 }
示例#6
0
 /**
  * Prepare data
  *
  * @param array $customersReport
  * @return array
  */
 protected function prepareData(array $customersReport)
 {
     foreach ($customersReport as $name => $reportFilter) {
         if ($name === 'report_period') {
             continue;
         }
         $date = ObjectManager::getInstance()->create('\\Magento\\Backend\\Test\\Fixture\\Source\\Date', ['params' => [], 'data' => ['pattern' => $reportFilter]]);
         $customersReport[$name] = $date->getData();
     }
     return $customersReport;
 }
 /**
  * Get block by class.
  *
  * @param string $class
  * @return mixed
  */
 protected function getClassBlock($class)
 {
     return \Magento\Mtf\ObjectManager::getInstance()->create($class, ['element' => $this->find($this->selectBlock, Locator::SELECTOR_XPATH)]);
 }
 /**
  * Setup default configuration after test.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     $objectManager = ObjectManager::getInstance();
     $objectManager->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'default_tax_configuration'])->run();
     $objectManager->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'shipping_tax_class_taxable_goods', 'rollback' => true])->run();
 }
示例#9
0
 /**
  * Create new variation set.
  *
  * @param array $attribute
  * @return void
  */
 protected function createNewVariationSet(array $attribute)
 {
     $attributeFixture = ObjectManager::getInstance()->create('Magento\\Catalog\\Test\\Fixture\\CatalogProductAttribute', ['data' => $attribute]);
     $this->browser->find($this->createNewVariationSet)->click();
     $this->getEditAttributeForm()->fill($attributeFixture);
     $this->getEditAttributeForm()->saveAttributeForm();
     $this->waitBlock($this->newAttributeFrame);
 }
 /**
  * Rollback default configuration.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     $objectManager = ObjectManager::getInstance();
     $objectManager->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'default_tax_configuration'])->run();
     $objectManager->create('\\Mage\\Tax\\Test\\TestStep\\CreateTaxRuleStep', ['taxRule' => 'default'])->run();
 }
示例#11
0
 /**
  * Get module name from fixture.
  *
  * @param FixtureInterface $product
  * @return string
  */
 protected function getCartItemClass(FixtureInterface $product)
 {
     $typeId = $product->getDataConfig()['type_id'];
     return ObjectManager::getInstance()->create($this->itemRender[$typeId], ['product' => $product]);
 }
 /**
  * Delete attribute after test.
  *
  * @return void
  */
 public function tearDown()
 {
     ObjectManager::getInstance()->create('Magento\\Catalog\\Test\\TestStep\\DeleteAttributeStep', ['attribute' => $this->attribute])->run();
 }
 /**
  * Login customer to frontend.
  *
  * @param Customer $customer
  * @return void
  */
 public function loginCustomer(Customer $customer)
 {
     $loginCustomerOnFrontendStep = ObjectManager::getInstance()->create('Mage\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer]);
     $loginCustomerOnFrontendStep->run();
 }
 /**
  * Fill single condition
  *
  * @param array $rules
  * @param ElementInterface $element
  * @return void
  * @throws \Exception
  */
 protected function fillCondition(array $rules, ElementInterface $element)
 {
     $this->resetKeyParam();
     foreach ($rules as $rule) {
         /** @var ElementInterface $param */
         $param = $this->findNextParam($element);
         $this->driver->selectWindow();
         $param->find('a')->click();
         if (preg_match('`%(.*?)%`', $rule, $chooserGrid)) {
             $chooserConfig = explode('#', $chooserGrid[1]);
             $param->find($this->chooserLocator)->click();
             $rule = preg_replace('`%(.*?)%`', '', $rule);
             $grid = ObjectManager::getInstance()->create(str_replace('/', '\\', $chooserConfig[0]), ['element' => $this->find($this->chooserGridLocator)]);
             $grid->searchAndSelect([$chooserConfig[1] => $rule]);
             continue;
         }
         $input = $this->ruleParamInput;
         $param->waitUntil(function () use($param, $input) {
             $element = $param->find($input);
             return $element->isVisible() ? true : null;
         });
         $value = $param->find('select', Locator::SELECTOR_TAG_NAME, 'select');
         if ($value->isVisible()) {
             $value->setValue($rule);
             $this->click();
             continue;
         }
         $value = $param->find('input', Locator::SELECTOR_TAG_NAME);
         if ($value->isVisible()) {
             $value->setValue($rule);
             $apply = $param->find('.//*[@class="rule-param-apply"]', Locator::SELECTOR_XPATH);
             if ($apply->isVisible()) {
                 $apply->click();
             }
             continue;
         }
         throw new \Exception('Undefined type of value ');
     }
 }
 /**
  * Add products to cart
  *
  * @param array $products
  * @return void
  */
 protected function addToCart(array $products)
 {
     $addToCartStep = ObjectManager::getInstance()->create('Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', ['products' => $products]);
     $addToCartStep->run();
 }
 /**
  * Get backend abstract block.
  *
  * @return Template
  */
 protected function getTemplateBlock()
 {
     return ObjectManager::getInstance()->create('Mage\\Adminhtml\\Test\\Block\\Template', ['element' => $this->driver->find($this->templateBlock, Locator::SELECTOR_XPATH)]);
 }
示例#17
0
 /**
  * Rollback configuration after test.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     ObjectManager::getInstance()->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'manual_layered_navigation_mysql', 'rollback' => true])->run();
 }
 /**
  * Disable multiple wish list in config.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     ObjectManager::getInstance()->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'enable_multiple_wishlist', 'rollback' => true])->run();
 }
示例#19
0
 /**
  * Clear data after test.
  *
  * @return void
  */
 public function tearDown()
 {
     $this->objectManager->create('Magento\\CheckoutAgreements\\Test\\TestStep\\DeleteAllTermsEntityStep')->run();
     // TODO: Move set default configuration to "tearDownAfterClass" method after fix bug MAGETWO-29331
     ObjectManager::getInstance()->create('Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'checkout_term_condition', 'rollback' => true])->run();
 }
 /**
  * Clear data after test suite.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     ObjectManager::getInstance()->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'checkout_term_condition', 'rollback' => true])->run();
 }
示例#21
0
 /**
  * Get options form.
  *
  * @param SimpleElement|null $element
  * @return Option
  */
 protected function getFormInstance(SimpleElement $element = null)
 {
     return ObjectManager::getInstance()->create('Magento\\Catalog\\Test\\Block\\Adminhtml\\Product\\Attribute\\Edit\\Tab\\Options\\Option', ['element' => $element === null ? $this->find($this->option . ':last-child') : $element]);
 }
示例#22
0
 /**
  * Create a new category and retrieve category fixture
  *
  * @param string $key
  * @return mixed
  */
 protected function getCategory($key)
 {
     if (!isset($this->categories[$key])) {
         $category = ObjectManager::getInstance()->create('\\Magento\\Catalog\\Test\\Fixture\\Category', ['dataSet' => 'default_subcategory']);
         $category->persist();
         $this->categories[$key] = $category;
     }
     return $this->categories[$key];
 }
 /**
  * Delete all tax rules after test and rollback configuration.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     $objectManager = ObjectManager::getInstance();
     $objectManager->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
     $objectManager->create('Mage\\Core\\Test\\TestStep\\SetupConfigurationStep', ['configData' => 'enable_vat_rollback'])->run();
 }
 /**
  * Delete all tax rules after test.
  *
  * @return void
  */
 public static function tearDownAfterClass()
 {
     ObjectManager::getInstance()->create('Mage\\Tax\\Test\\TestStep\\DeleteAllTaxRulesStep')->run();
 }
 /**
  * @param $customer
  * @param $creditCard
  * @param $creditCardClass
  */
 protected function deleteCreditCardFromMyAccount($customer, $creditCard, $creditCardClass)
 {
     $deleteCreditCardFromMyAccountStep = ObjectManager::getInstance()->create(\Magento\Vault\Test\TestStep\DeleteCreditCardFromMyAccountStep::class, ['customer' => $customer, 'creditCard' => $creditCard, 'creditCardClass' => $creditCardClass]);
     $deletedCard = $deleteCreditCardFromMyAccountStep->run();
     return $deletedCard;
 }
 /**
  * Create Product With AttributeSet.
  *
  * @param CatalogProductAttribute $attribute
  * @param CatalogAttributeSet $attributeSet
  * @return CatalogProductSimple
  */
 protected function createProductWithAttributeSet(CatalogProductAttribute $attribute, CatalogAttributeSet $attributeSet)
 {
     $product = ObjectManager::getInstance()->create('Magento\\Catalog\\Test\\TestStep\\AddAttributeToAttributeSetStep', ['attribute' => $attribute, 'attributeSet' => $attributeSet])->run();
     return $product['product'];
 }
 /**
  * Fill grid element.
  *
  * @param string $rule
  * @param ElementInterface $param
  * @return bool
  */
 protected function fillGrid($rule, ElementInterface $param)
 {
     if (preg_match('`%(.*?)%`', $rule, $chooserGrid)) {
         $chooserConfig = explode('#', $chooserGrid[1]);
         $rule = preg_replace('`%(.*?)%`', '', $rule);
         $param->find($this->chooserLocator)->click();
         $grid = ObjectManager::getInstance()->create(str_replace('/', '\\', $chooserConfig[0]), ['element' => $this->find($this->chooserGridLocator)]);
         $grid->searchAndSelect([$chooserConfig[1] => $rule]);
         $apply = $param->find($this->applyRuleParam, Locator::SELECTOR_XPATH);
         if ($apply->isVisible()) {
             $apply->click();
         }
         return true;
     }
     return false;
 }