本文整理汇总了PHP中magento\mtf\factory\Factory类的典型用法代码示例。如果您正苦于以下问题:PHP Factory类的具体用法?PHP Factory怎么用?PHP Factory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Factory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initData
/**
* Initialize fixture data
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _initData()
{
$this->_data['checkout'] = ['prices' => ['price_from' => 110, 'price_to' => 120], 'selection' => [0]];
parent::_initData();
$this->_data['fields'] = array_merge_recursive($this->_data['fields'], ['sku_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'price' => ['value' => 100, 'group' => static::GROUP_PRODUCT_DETAILS], 'tax_class_id' => ['value' => 'Taxable Goods', 'input_value' => '2', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'weight_type' => ['value' => 'Fixed', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'weight' => ['value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS], 'product_website_1' => ['value' => 'Yes', 'input_value' => [1], 'group' => static::GROUP_PRODUCT_WEBSITE, 'input' => 'checkbox', 'input_name' => 'website_ids'], 'shipment_type' => ['value' => 'Separately', 'input_value' => '1', 'group' => static::GROUP_PRODUCT_DETAILS, 'input' => 'select'], 'bundle_selections' => ['value' => ['bundle_options' => [['title' => 'Drop-down Option', 'type' => 'Drop-down', 'required' => 'Yes', 'assigned_products' => [['search_data' => ['name' => '%item1_simple1::getName%'], 'data' => ['selection_price_value' => 10, 'selection_price_type' => 'Fixed', 'selection_qty' => 1, 'product_id' => '%item1_simple1::getProductId%']], ['search_data' => ['name' => '%item1_virtual2::getName%'], 'data' => ['selection_price_value' => 20, 'selection_price_type' => 'Percent', 'selection_qty' => 1, 'product_id' => '%item1_virtual2::getProductId%']]]]]], 'group' => static::GROUP]]);
$this->_repository = Factory::getRepositoryFactory()->getMagentoBundleBundle($this->_dataConfig, $this->_data);
}
示例2: testCreateNewLocalizedStoreView
/**
* @ZephyrId MAGETWO-12405
*/
public function testCreateNewLocalizedStoreView()
{
$objectManager = Factory::getObjectManager();
$storeFixture = $objectManager->create('Magento\\Store\\Test\\Fixture\\Store', ['dataSet' => 'german']);
$storeListPage = Factory::getPageFactory()->getAdminSystemStore();
$storeListPage->open();
$storeListPage->getGridPageActions()->addStoreView();
$newStorePage = Factory::getPageFactory()->getAdminSystemStoreNewStore();
$newStorePage->getStoreForm()->fill($storeFixture);
$newStorePage->getFormPageActions()->save();
$storeListPage->getMessagesBlock()->waitSuccessMessage();
$this->assertContains('The store view has been saved', $storeListPage->getMessagesBlock()->getSuccessMessages());
$this->assertTrue($storeListPage->getStoreGrid()->isStoreExists($storeFixture->getName()));
$cachePage = Factory::getPageFactory()->getAdminCache();
$cachePage->open();
$cachePage->getActionsBlock()->flushCacheStorage();
$cachePage->getMessagesBlock()->waitSuccessMessage();
$configPage = Factory::getPageFactory()->getAdminSystemConfig();
$configPage->open();
$configPage->getPageActions()->selectStore($storeFixture->getGroupId() . "/" . $storeFixture->getName());
$configGroup = $configPage->getForm()->getGroup('Locale Options');
$configGroup->open();
$configGroup->setValue('select-groups-locale-fields-code-value', 'German (Germany)');
$configPage->getPageActions()->save();
$configPage->getMessagesBlock()->waitSuccessMessage();
$homePage = Factory::getPageFactory()->getCmsIndexIndex();
$homePage->open();
$homePage->getStoreSwitcherBlock()->selectStoreView($storeFixture->getName());
$this->assertTrue($homePage->getSearchBlock()->isPlaceholderContains('Den gesamten Shop durchsuchen'));
}
示例3: assertOnFrontend
/**
* Assert configurable product on Frontend
*
* @param ConfigurableProduct $product
* @return void
*/
protected function assertOnFrontend(ConfigurableProduct $product)
{
//Pages
$frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
$categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
$productPage = Factory::getPageFactory()->getCatalogProductView();
//Steps
$frontendHomePage->open();
$frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName());
//Verification on category product list
$productListBlock = $categoryPage->getListProductBlock();
$this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.');
//Verification on product detail page
$productViewBlock = $productPage->getViewBlock();
$productListBlock->openProductViewPage($product->getName());
$this->assertEquals($product->getName(), $productViewBlock->getProductName(), 'Product name does not correspond to specified.');
$price = $product->getProductPrice();
$priceOnPage = $productViewBlock->getPriceBlock()->getPrice();
$this->assertEquals(number_format($price, 2), number_format($priceOnPage, 2), 'Product price does not correspond to specified.');
$pageOptions = $productViewBlock->getOptions($product);
$configurableOptions = [];
foreach ($pageOptions['configurable_options'] as $attribute) {
$configurableOption = [];
foreach ($attribute['options'] as $option) {
$configurableOption[] = $option['title'];
}
$configurableOptions[$attribute['title']] = $configurableOption;
}
$this->assertEquals($product->getConfigurableOptions(), $configurableOptions);
}
示例4: testCreateConfigurableProduct
/**
* Edit configurable product and add new options to attribute
*
* @ZephyrId MAGETWO-12840
* @return void
*/
public function testCreateConfigurableProduct()
{
//Preconditions
//Preparing Data for original product
$configurable = Factory::getFixtureFactory()->getMagentoConfigurableProductConfigurableProduct();
$configurable->switchData('configurable');
$configurable->persist();
$productSku = $configurable->getSku();
//Preparing Data for editing product
$editProduct = $configurable->getEditData();
//Steps
$createProductPage = Factory::getPageFactory()->getCatalogProductNew();
$productForm = $createProductPage->getProductForm();
//Login
Factory::getApp()->magentoBackendLoginUser();
$productGridPage = Factory::getPageFactory()->getCatalogProductIndex();
$productGridPage->open();
//Search and open original configurable product
$productGridPage->getProductGrid()->searchAndOpen(['sku' => $productSku]);
//Editing product options
$productForm->fill($editProduct);
$createProductPage->getFormPageActions()->save();
//Verifying
$createProductPage->getMessagesBlock()->waitSuccessMessage();
//Flush cache
$cachePage = Factory::getPageFactory()->getAdminCache();
$cachePage->open();
$cachePage->getActionsBlock()->flushMagentoCache();
//Verifying
$this->assertOnGrid($editProduct);
$this->assertOnFrontend($editProduct);
}
示例5: assertOnCategory
/**
* Assert product data on category and product pages
*
* @param Product $product
* @return void
*/
protected function assertOnCategory($product)
{
//Pages
$frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
$categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
$productPage = Factory::getPageFactory()->getCatalogProductView();
//Steps
$frontendHomePage->open();
$frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName());
//Verification on category product list
$productListBlock = $categoryPage->getListProductBlock();
$this->assertTrue($productListBlock->isProductVisible($product->getName()));
$productListBlock->openProductViewPage($product->getName());
//Verification on product detail page
$productViewBlock = $productPage->getViewBlock();
$this->assertEquals($product->getName(), $productViewBlock->getProductName());
$price = $productViewBlock->getPriceBlock()->getPrice();
$this->assertEquals(number_format($product->getProductPrice(), 2), $price);
$productOptionsBlock = $productPage->getViewBlock()->getCustomOptionsBlock();
$fixture = $product->getData('fields/custom_options/value');
$actualOptions = $productOptionsBlock->getOptions($product);
$this->assertCount(count($fixture), $actualOptions);
$this->assertTrue(isset($actualOptions['custom_options'][$fixture[0]['title']]['options'][0]['title']));
$this->assertEquals($fixture[0]['title'], $actualOptions['custom_options'][$fixture[0]['title']]['title']);
}
示例6: initCustomRoles
/**
* Init most popular custom roles
*/
protected function initCustomRoles()
{
$resourceFixture = Factory::getFixtureFactory()->getMagentoUserResource();
$salesAllScopes = $this->_data['custom_permissions_all_scopes']['data'];
$salesAllScopes['fields']['resource']['value'] = $resourceFixture->get('Magento_Sales::sales');
$this->_data['sales_all_scopes']['data'] = $salesAllScopes;
}
示例7: 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()->waitSuccessMessage();
}
示例8: fillFormTab
/**
* Fill condition options
*
* @param array $fields
* @param SimpleElement|null $element
* @return void
*/
public function fillFormTab(array $fields, SimpleElement $element = null)
{
$data = $this->dataMapping($fields);
$conditionsBlock = Factory::getBlockFactory()->getMagentoCatalogRuleConditions($element->find($this->ruleConditions));
$conditionsBlock->clickAddNew();
$conditionsBlock->selectCondition($data['condition_type']['value']);
$conditionsBlock->clickEllipsis();
$conditionsBlock->selectConditionValue($data['condition_value']['value']);
}
示例9: assertAbsenceOnCategory
/**
* Assert absence product on category page (frontend)
*
* @param Product $product
* @return void
*/
protected function assertAbsenceOnCategory(Product $product)
{
//Pages
$frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
$categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
//Steps
$frontendHomePage->open();
$frontendHomePage->getTopmenu()->selectCategoryByName($product->getCategoryName());
//Verification on category product list
$productListBlock = $categoryPage->getListProductBlock();
$this->assertFalse($productListBlock->isProductVisible($product->getName()));
}
示例10: testForgotPassword
/**
* Reset password on frontend
*/
public function testForgotPassword()
{
// Create Customer
$customer = $this->objectManager->getInstance()->create('Magento\\Customer\\Test\\Fixture\\Customer', ['dataSet' => 'customer_US_1']);
$customer->persist();
$customerAccountLoginPage = Factory::getPageFactory()->getCustomerAccountLogin();
$forgotPasswordPage = Factory::getPageFactory()->getCustomerAccountForgotpassword();
$forgotPasswordPage->open();
$forgotPasswordPage->getForgotPasswordForm()->resetForgotPassword($customer);
//Verifying
$message = sprintf('If there is an account associated with %s you will receive an email with a link to reset your password.', $customer->getEmail());
$this->assertContains($message, $customerAccountLoginPage->getMessages()->getSuccessMessages());
}
示例11: persist
/**
* Execute handler
*
* @param FixtureInterface $fixture [optional]
* @return mixed
*/
public function persist(FixtureInterface $fixture = null)
{
/** @var \Magento\Customer\Test\Fixture\Address $fixture */
// Pages
$loginPage = Factory::getPageFactory()->getCustomerAccountLogin();
$addressPage = Factory::getPageFactory()->getCustomerAddressEdit();
$loginPage->open();
if ($loginPage->getLoginBlock()->isVisible()) {
$loginPage->getLoginBlock()->login($fixture->getCustomer());
}
$addressPage->open();
$addressPage->getEditForm()->editCustomerAddress($fixture);
}
示例12: persist
/**
* Login admin user
*
* @param FixtureInterface $fixture [optional]
* @return void|mixed
*/
public function persist(FixtureInterface $fixture = null)
{
if (null === $fixture) {
$fixture = Factory::getFixtureFactory()->getMagentoBackendAdminSuperAdmin();
}
$loginPage = Factory::getPageFactory()->getAdminAuthLogin();
$loginForm = $loginPage->getLoginBlock();
$adminHeaderPanel = $loginPage->getHeaderBlock();
if (!$adminHeaderPanel || !$adminHeaderPanel->isVisible()) {
$loginPage->open();
if ($adminHeaderPanel->isVisible()) {
return;
}
$loginForm->fill($fixture);
$loginForm->submit();
$loginPage->waitForHeaderBlock();
}
}
示例13: assertProductOnFrontend
/**
* Assert simple product on Frontend
*
* @param SimpleProduct $product
* @return void
*/
protected function assertProductOnFrontend(SimpleProduct $product)
{
//Pages
$frontendHomePage = Factory::getPageFactory()->getCmsIndexIndex();
$categoryPage = Factory::getPageFactory()->getCatalogCategoryView();
$productPage = Factory::getPageFactory()->getCatalogProductView();
$frontendHomePage->open();
$frontendHomePage->getTopmenu()->selectCategoryByName($product->getNewCategoryName());
//Verification on category product list
$productListBlock = $categoryPage->getListProductBlock();
$this->assertTrue($productListBlock->isProductVisible($product->getName()), 'Product is absent on category page.');
//Verification on product detail page
$productViewBlock = $productPage->getViewBlock();
$productListBlock->openProductViewPage($product->getName());
$this->assertEquals($product->getName(), $productViewBlock->getProductName());
$price = $productViewBlock->getPriceBlock()->getPrice();
$this->assertEquals(number_format($product->getProductPrice(), 2), $price);
}
示例14: testCreateCustomer
/**
* New customer creation in backend
*
* @ZephyrId MAGETWO-12516
*/
public function testCreateCustomer()
{
//Data
$customerFixture = Factory::getFixtureFactory()->getMagentoCustomerCustomer();
$customerFixture->switchData('backend_customer');
$searchData = ['email' => $customerFixture->getEmail()];
//Pages
$customerPage = Factory::getPageFactory()->getCustomerIndex();
$customerCreatePage = Factory::getPageFactory()->getCustomerIndexNew();
//Steps
$customerPage->open();
$customerPage->getPageActionsBlock()->addNew();
$customerCreatePage->getCustomerForm()->fillCustomer($customerFixture);
$customerCreatePage->getPageActionsBlock()->saveAndContinue();
$customerCreatePage->getMessagesBlock()->waitSuccessMessage();
//Verifying
$customerPage->open();
$this->assertTrue($customerPage->getCustomerGridBlock()->isRowVisible($searchData), 'Customer email "' . $searchData['email'] . '" not found in the grid');
}
示例15: assertOnTheFrontEnd
/**
* @param Product $product
* @param Product[] $assigned
* @return void
*/
protected function assertOnTheFrontEnd(Product $product, array $assigned)
{
/** @var Product $simple2 */
/** @var Product $configurable */
list($simple2, $configurable) = $assigned;
//Open up simple1 product page
$productPage = Factory::getPageFactory()->getCatalogProductView();
Factory::getClientBrowser()->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
$this->assertEquals($product->getName(), $productPage->getViewBlock()->getProductName());
/** @var \Magento\Catalog\Test\Block\Product\ProductList\Upsell $upsellBlock */
$upsellBlock = $productPage->getUpsellBlock();
//Verify upsell simple2 and configurable on Simple1 product page
$this->assertTrue($upsellBlock->isUpsellProductVisible($simple2->getName()));
$this->assertTrue($upsellBlock->isUpsellProductVisible($configurable->getName()));
//Open and verify configurable page
$upsellBlock->openUpsellProduct($configurable->getName());
$this->assertEquals($configurable->getName(), $productPage->getViewBlock()->getProductName());
//Verify upsell simple2 on Configurable product page and open it
$upsellBlock = $productPage->getUpsellBlock();
$this->assertTrue($upsellBlock->isUpsellProductVisible($simple2->getName()));
$upsellBlock->openUpsellProduct($simple2->getName());
$this->assertEquals($simple2->getName(), $productPage->getViewBlock()->getProductName());
$this->assertFalse($productPage->getUpsellBlock()->isVisible());
}