本文整理汇总了PHP中Magento\Mtf\ObjectManager::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectManager::getInstance方法的具体用法?PHP ObjectManager::getInstance怎么用?PHP ObjectManager::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Mtf\ObjectManager
的用法示例。
在下文中一共展示了ObjectManager::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @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;
}
}
示例2: __construct
/**
* @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;
}
示例3: prepareData
/**
* 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;
}
示例4: open
/**
* 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);
}
示例5: prepareData
/**
* 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;
}
示例6: getClassBlock
/**
* 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)]);
}
示例7: tearDownAfterClass
/**
* 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();
}
示例8: createNewVariationSet
/**
* 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);
}
示例9: tearDownAfterClass
/**
* 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();
}
示例10: getCartItemClass
/**
* 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]);
}
示例11: tearDown
/**
* Delete attribute after test.
*
* @return void
*/
public function tearDown()
{
ObjectManager::getInstance()->create('Magento\\Catalog\\Test\\TestStep\\DeleteAttributeStep', ['attribute' => $this->attribute])->run();
}
示例12: loginCustomer
/**
* 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();
}
示例13: fillCondition
/**
* 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 ');
}
}
示例14: addToCart
/**
* 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();
}
示例15: getTemplateBlock
/**
* 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)]);
}