/**
  * @param FixtureFactory $fixtureFactory
  * @param AssertSuccessfulReadinessCheck $assertReadiness
  * @param AssertVersionAndEditionCheck $assertVersionAndEdition
  * @param AssertSuccessMessage $assertSuccessMessage
  * @param AssertApplicationVersion $assertApplicationVersion
  * @param array $upgrade
  * @return void
  */
 public function test(FixtureFactory $fixtureFactory, AssertSuccessfulReadinessCheck $assertReadiness, AssertVersionAndEditionCheck $assertVersionAndEdition, AssertSuccessMessage $assertSuccessMessage, AssertApplicationVersion $assertApplicationVersion, $upgrade = [])
 {
     // Create fixture
     $upgradeFixture = $fixtureFactory->create('Magento\\Upgrade\\Test\\Fixture\\Upgrade', ['data' => $upgrade]);
     $createBackupConfig = array_intersect_key($upgrade, ['optionsCode' => '', 'optionsMedia' => '', 'optionsDb' => '']);
     $createBackupFixture = $fixtureFactory->create('Magento\\Upgrade\\Test\\Fixture\\Upgrade', ['data' => $createBackupConfig]);
     $version = $upgrade['upgradeVersion'];
     $suffix = "( (CE|EE))\$";
     $normalVersion = '(0|[1-9]\\d*)';
     $preReleaseVersion = "((0(?!\\d+(\\.|\\+|{$suffix}))|[1-9A-Za-z])[0-9A-Za-z-]*)";
     $buildVersion = '([0-9A-Za-z][0-9A-Za-z-]*)';
     $versionPattern = "/^{$normalVersion}(\\.{$normalVersion}){2}" . "(-{$preReleaseVersion}(\\.{$preReleaseVersion})*)?" . "(\\+{$buildVersion}(\\.{$buildVersion})*)?{$suffix}/";
     if (preg_match($versionPattern, $version)) {
         preg_match("/(.*){$suffix}/", $version, $matches);
         $version = $matches[1];
     } else {
         $this->fail("Provided version format does not comply with semantic versioning specification. Got '{$version}'");
     }
     // Authenticate in admin area
     $this->adminDashboard->open();
     // Open Web Setup Wizard
     $this->setupWizard->open();
     // Authenticate on repo.magento.com
     if ($upgrade['needAuthentication'] === 'Yes') {
         $this->setupWizard->getSystemConfig()->clickSystemConfig();
         $this->setupWizard->getAuthentication()->fill($upgradeFixture);
         $this->setupWizard->getAuthentication()->clickSaveConfig();
         $this->setupWizard->open();
     }
     // Select upgrade to version
     $this->setupWizard->getSystemUpgradeHome()->clickSystemUpgrade();
     $this->setupWizard->getSelectVersion()->fill($upgradeFixture);
     if ($upgrade['otherComponents'] === 'Yes') {
         $this->setupWizard->getSelectVersion()->chooseUpgradeOtherComponents();
     }
     $this->setupWizard->getSelectVersion()->clickNext();
     // Readiness Check
     $this->setupWizard->getReadiness()->clickReadinessCheck();
     $assertReadiness->processAssert($this->setupWizard);
     $this->setupWizard->getReadiness()->clickNext();
     // Create Backup page
     $this->setupWizard->getCreateBackup()->fill($createBackupFixture);
     $this->setupWizard->getCreateBackup()->clickNext();
     // Check info and press 'Upgrade' button
     $assertVersionAndEdition->processAssert($this->setupWizard, $upgrade['package'], $version);
     $this->setupWizard->getSystemUpgrade()->clickSystemUpgrade();
     $assertSuccessMessage->processAssert($this->setupWizard, $upgrade['package']);
     // Check application version
     $this->adminDashboard->open();
     $assertApplicationVersion->processAssert($this->adminDashboard, $version);
 }
 /**
  * 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];
 }
 /**
  * @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;
 }
 /**
  * @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;
 }
 /**
  * Get product's fixture.
  *
  * @param OrderInjectable $order
  * @param array $data
  * @param int $index [optional]
  * @return FixtureInterface
  */
 protected function getProduct(OrderInjectable $order, array $data, $index = 0)
 {
     if (!isset($data['items_data'][$index]['back_to_stock']) || $data['items_data'][$index]['back_to_stock'] != 'Yes') {
         return $order->getEntityId()['products'][$index];
     }
     $product = $order->getEntityId()['products'][$index];
     $productData = $product->getData();
     $checkoutDataQty = $productData['checkout_data']['qty'];
     $productData['quantity_and_stock_status']['qty'] -= $checkoutDataQty - $data['items_data'][$index]['qty'];
     $productData = array_diff_key($productData, array_flip($this->skipFields));
     return $this->fixtureFactory->create(get_class($product), ['data' => $productData]);
 }
 /**
  * @param FixtureFactory $fixtureFactory
  * @param AssertSuccessfulReadinessCheck $assertReadiness
  * @param AssertVersionAndEditionCheck $assertVersionAndEdition
  * @param AssertSuccessMessage $assertSuccessMessage
  * @param AssertApplicationVersion $assertApplicationVersion
  * @param array $upgrade
  * @return void
  */
 public function test(FixtureFactory $fixtureFactory, AssertSuccessfulReadinessCheck $assertReadiness, AssertVersionAndEditionCheck $assertVersionAndEdition, AssertSuccessMessage $assertSuccessMessage, AssertApplicationVersion $assertApplicationVersion, $upgrade = [])
 {
     // Create fixture
     $upgradeFixture = $fixtureFactory->create('Magento\\Upgrade\\Test\\Fixture\\Upgrade', ['data' => $upgrade]);
     $createBackupConfig = array_intersect_key($upgrade, ['optionsCode' => '', 'optionsMedia' => '', 'optionsDb' => '']);
     $createBackupFixture = $fixtureFactory->create('Magento\\Upgrade\\Test\\Fixture\\Upgrade', ['data' => $createBackupConfig]);
     $version = $upgrade['upgradeVersion'];
     if (preg_match('/^[0-9].[0-9].[0-9]/', $version, $out)) {
         $version = array_shift($out);
     }
     // Authenticate in admin area
     $this->adminDashboard->open();
     // Open Web Setup Wizard
     $this->setupWizard->open();
     // Authenticate on repo.magento.com
     if ($upgrade['needAuthentication'] === 'Yes') {
         $this->setupWizard->getSystemConfig()->clickSystemConfig();
         $this->setupWizard->getAuthentication()->fill($upgradeFixture);
         $this->setupWizard->getAuthentication()->clickSaveConfig();
         $this->setupWizard->open();
     }
     // Select upgrade to version
     $this->setupWizard->getSystemUpgradeHome()->clickSystemUpgrade();
     $this->setupWizard->getSelectVersion()->fill($upgradeFixture);
     $this->setupWizard->getSelectVersion()->clickNext();
     // Readiness Check
     $this->setupWizard->getReadiness()->clickReadinessCheck();
     $assertReadiness->processAssert($this->setupWizard);
     $this->setupWizard->getReadiness()->clickNext();
     // Create Backup page
     $this->setupWizard->getCreateBackup()->fill($createBackupFixture);
     $this->setupWizard->getCreateBackup()->clickNext();
     // Check info and press 'Upgrade' button
     $assertVersionAndEdition->processAssert($this->setupWizard, $upgrade['package'], $version);
     $this->setupWizard->getSystemUpgrade()->clickSystemUpgrade();
     $assertSuccessMessage->processAssert($this->setupWizard, $upgrade['package']);
     // Check application version
     $this->adminDashboard->open();
     $assertApplicationVersion->processAssert($this->adminDashboard, $version);
 }
 /**
  * @param Role $role
  * @param Role $updatedRole
  * @param User $user
  * @return void
  */
 public function testLoginAfterChangingPermissions(Role $role, Role $updatedRole, User $user)
 {
     /** Create role and a new user with this role */
     $role->persist();
     /** @var User $user */
     $user = $this->fixtureFactory->create('Magento\\User\\Test\\Fixture\\User', ['data' => array_merge($user->getData(), ['role_id' => ['role' => $role]])]);
     $user->persist();
     /** Change the scope of resources available for the role created earlier */
     $filter = ['rolename' => $role->getRoleName()];
     $this->userRoleIndex->open();
     $this->userRoleIndex->getRoleGrid()->searchAndOpen($filter);
     $this->userRoleEditRole->getRoleFormTabs()->fill($updatedRole);
     $this->userRoleEditRole->getPageActions()->save();
     $this->dashboard->getAdminPanelHeader()->logOut();
 }
 /**
  * Assign promoted products.
  *
  * @param string $promotedProducts
  * @param string $type
  * @return void
  */
 protected function assignPromotedProducts($promotedProducts, $type)
 {
     $promotedProducts = $this->parsePromotedProducts($promotedProducts);
     foreach ($promotedProducts as $productName => $assignedNames) {
         $initialProduct = $this->products[$productName];
         $filter = ['sku' => $initialProduct->getSku()];
         $assignedProducts = [];
         foreach ($assignedNames as $assignedName) {
             $assignedProducts[] = $this->products[$assignedName];
         }
         $product = $this->fixtureFactory->create(get_class($initialProduct), ['data' => [$type => ['products' => $assignedProducts]]]);
         $this->catalogProductIndex->open();
         $this->catalogProductIndex->getProductGrid()->searchAndOpen($filter);
         $this->catalogProductEdit->getProductForm()->fill($product);
         $this->catalogProductEdit->getFormPageActions()->save();
         $this->catalogProductEdit->getMessagesBlock()->waitSuccessMessage();
     }
 }
 /**
  * @constructor
  * @param FixtureFactory $fixtureFactory
  * @param array $params [optional]
  * @param array $data [optional]
  */
 public function __construct(FixtureFactory $fixtureFactory, array $params = [], array $data = [])
 {
     $this->params = $params;
     if (isset($data['presets'])) {
         $data['presets'] = explode(',', $data['presets']);
         foreach ($data['presets'] as $value) {
             /** @var AddressFixture $fixture */
             $addresses = $fixtureFactory->create('Mage\\Paypal\\Test\\Fixture\\PaypalAddress', ['dataSet' => $value]);
             $this->data[] = $addresses->getData();
             $this->addressesFixture[] = $addresses;
         }
     } elseif (empty($data['presets']) && !empty($data['addresses'])) {
         foreach ($data['addresses'] as $addresses) {
             /** @var AddressFixture $addresses */
             $this->data[] = $addresses->getData();
             $this->addressesFixture[] = $addresses;
         }
     }
 }
Exemple #10
0
 /**
  * Install Magento via web interface.
  *
  * @param User $user
  * @param array $install
  * @param array $configData
  * @param FixtureFactory $fixtureFactory
  * @param AssertAgreementTextPresent $assertLicense
  * @param AssertSuccessfulReadinessCheck $assertReadiness
  * @return array
  */
 public function test(User $user, array $install, array $configData, FixtureFactory $fixtureFactory, AssertAgreementTextPresent $assertLicense, AssertSuccessfulReadinessCheck $assertReadiness)
 {
     $dataConfig = array_merge($install, $configData);
     if ($dataConfig['httpsFront'] != "-") {
         $dataConfig['https'] = str_replace('http', 'https', $dataConfig['web']);
     }
     /** @var InstallConfig $installConfig */
     $installConfig = $fixtureFactory->create('Magento\\Install\\Test\\Fixture\\Install', ['data' => $dataConfig]);
     // Steps
     $this->homePage->open();
     // Verify license agreement.
     $this->installPage->getLandingBlock()->clickTermsAndAgreement();
     $assertLicense->processAssert($this->installPage);
     $this->installPage->getLicenseBlock()->clickBack();
     $this->installPage->getLandingBlock()->clickAgreeAndSetup();
     // Step 1: Readiness Check.
     $this->installPage->getReadinessBlock()->clickReadinessCheck();
     $assertReadiness->processAssert($this->installPage);
     $this->installPage->getReadinessBlock()->clickNext();
     // Step 2: Add a Database.
     $this->installPage->getDatabaseBlock()->fill($installConfig);
     $this->installPage->getDatabaseBlock()->clickNext();
     // Step 3: Web Configuration.
     $this->installPage->getWebConfigBlock()->clickAdvancedOptions();
     $this->installPage->getWebConfigBlock()->fill($installConfig);
     $this->installPage->getWebConfigBlock()->clickNext();
     // Step 4: Customize Your Store
     $this->installPage->getCustomizeStoreBlock()->fill($installConfig);
     $this->installPage->getCustomizeStoreBlock()->clickNext();
     // Step 5: Create Admin Account.
     $this->installPage->getCreateAdminBlock()->fill($user);
     $this->installPage->getCreateAdminBlock()->clickNext();
     // Step 6: Install.
     $this->installPage->getInstallBlock()->clickInstallNow();
     return ['installConfig' => $installConfig];
 }
Exemple #11
0
 /**
  * Disable secret key before creating and activating integration.
  *
  * @return void
  */
 protected function disableSecretKey()
 {
     $config = $this->fixtureFactory->create('Magento\\Config\\Test\\Fixture\\ConfigData', ['dataset' => 'secret_key_disable']);
     $config->persist();
 }
 /**
  * Create Widget.
  *
  * @param string $widget
  * @param Banner $banner
  * @return BannerWidget
  */
 protected function createWidget($widget, Banner $banner)
 {
     $widget = $this->fixtureFactory->create('Enterprise\\Banner\\Test\\Fixture\\BannerWidget', ['dataSet' => $widget, 'data' => ['parameters' => ['banner_ids' => $banner->getBannerId(), 'display_mode' => 'fixed']]]);
     $widget->persist();
     return $widget;
 }