當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectManager::create方法代碼示例

本文整理匯總了PHP中Magento\Mtf\ObjectManager::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectManager::create方法的具體用法?PHP ObjectManager::create怎麽用?PHP ObjectManager::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Mtf\ObjectManager的用法示例。


在下文中一共展示了ObjectManager::create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: apply

 /**
  * Apply set up configuration profile.
  *
  * @return void
  */
 public function apply()
 {
     parent::apply();
     if (file_exists(dirname(dirname(dirname(MTF_BP))) . '/app/etc/config.php')) {
         $this->objectManager->create('\\Magento\\Config\\Test\\TestStep\\SetupConfigurationStep', ['configData' => $this->config])->run();
     }
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:12,代碼來源:State1.php

示例2: run

 /**
  * Fill customer addresses and proceed to next step.
  *
  * @return void
  */
 public function run()
 {
     $addresses = $this->customer->getDataFieldConfig('address')['source']->getAddresses();
     $bindings = [];
     foreach ($this->products as $key => $product) {
         $productName = $product->getName();
         $addressRender = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addresses[$key], 'type' => 'oneline']);
         $bindings[$productName] = $addressRender->render();
     }
     $this->addresses->getAddressesBlock()->selectAddresses($bindings);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:16,代碼來源:FillCustomerAddressesStep.php

示例3: run

 /**
  * Review order contents and place order.
  *
  * @return array
  */
 public function run()
 {
     $this->orderReviewExpress->getReviewBlock()->selectShippingMethod($this->shipping);
     foreach ($this->prices as $priceName => $value) {
         $assertName = 'Assert' . ucfirst($priceName) . 'OrderReview';
         $assert = $this->objectManager->create('Magento\\Checkout\\Test\\Constraint\\' . $assertName);
         $assert->processAssert($this->checkoutOnepage, $value);
     }
     $this->orderReviewExpress->getReviewBlock()->placeOrder();
     return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId()];
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:16,代碼來源:ExpressCheckoutOrderPlaceStep.php

示例4: run

 /**
  * Run a Mtf application
  *
  * @param $applicationName
  * @param array $arguments
  * @return mixed
  * @throws \DomainException
  */
 public function run($applicationName, array $arguments = [])
 {
     try {
         if (!$this->_locator) {
             $locatorFactory = new \Magento\Mtf\ObjectManagerFactory();
             $this->_locator = $locatorFactory->create();
         }
         return $this->_locator->create($applicationName, $arguments)->launch();
     } catch (\Exception $exception) {
         $message = "Error happened during application run.\n";
         $message .= $exception->getMessage();
         throw new \DomainException($message);
     }
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:22,代碼來源:EntryPoint.php

示例5: run

 /**
  * @inheritdoc
  *
  * @return array
  */
 public function run()
 {
     $this->objectManager->create(\Magento\Customer\Test\TestStep\LoginCustomerOnFrontendStep::class, ['customer' => $this->customer])->run();
     $this->customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Credit Cards');
     $myCreditCardsBlock = $this->myCreditCardsPage->getCreditCardsBlock();
     $creditCardData = $this->creditCard->getData();
     $creditCardNumber = preg_grep('/([a-z]+)_number/', array_flip($creditCardData));
     $lastFourDigits = substr(key($creditCardNumber), -4, 4);
     $availableCreditCards = $myCreditCardsBlock->getCreditCards();
     if (key_exists($lastFourDigits, $availableCreditCards)) {
         $myCreditCardsBlock->deleteCreditCard($availableCreditCards[$lastFourDigits]);
     }
     $this->assertCreditCardDeletedMessage->processAssert($this->myCreditCardsPage);
     return ['deletedCreditCard' => $lastFourDigits];
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:20,代碼來源:DeleteCreditCardFromMyAccountStep.php

示例6: processCheckout

 /**
  * Process checkout.
  *
  * @param string $checkoutMethod
  * @param Address $billingAddress
  * @param array $shipping
  * @param array $payment
  * @return void
  */
 protected function processCheckout($checkoutMethod, Address $billingAddress, array $shipping, array $payment)
 {
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\SelectCheckoutMethodStep', ['checkoutMethod' => $checkoutMethod])->run();
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\FillBillingInformationStep', ['billingAddress' => $billingAddress])->run();
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\FillShippingMethodStep', ['shipping' => $shipping])->run();
     $this->objectManager->create('Mage\\Checkout\\Test\\TestStep\\SelectPaymentMethodStep', ['payment' => $payment])->run();
 }
開發者ID:QiuLihua83,項目名稱:magento-ee,代碼行數:16,代碼來源:AssertTermOnCheckout.php

示例7: processAssert

 /**
  * Assert order is not visible in customer account on frontend
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param ObjectManager $objectManager
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status)
 {
     $filter = ['id' => $order->getId(), 'status' => $status];
     $customerLogin = $objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer]);
     $customerLogin->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     \PHPUnit_Framework_Assert::assertFalse($orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . implode(', ', $filter) . '\' is present in Orders block on frontend.');
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:19,代碼來源:AssertOrderNotVisibleOnMyAccount.php

示例8: createProducts

 /**
  * Create products.
  *
  * @param array $products
  * @return array
  */
 protected function createProducts(array $products)
 {
     $resultProduct = [];
     foreach ($products as $key => $product) {
         $resultProduct[$key] = $this->objectManager->create('Mage\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => implode(',', $product)])->run()['products'];
     }
     return $resultProduct;
 }
開發者ID:chucky515,項目名稱:Magento-CE-Mirror,代碼行數:14,代碼來源:BundleSelections.php

示例9: processAssert

 /**
  * Assert that order is present in Orders grid on frontend.
  *
  * @param OrderInjectable $order
  * @param Customer $customer
  * @param ObjectManager $objectManager
  * @param CustomerAccountIndex $customerAccountIndex
  * @param OrderHistory $orderHistory
  * @param string $status
  * @param string $orderId
  * @param string|null $statusToCheck
  * @return void
  */
 public function processAssert(OrderInjectable $order, Customer $customer, ObjectManager $objectManager, CustomerAccountIndex $customerAccountIndex, OrderHistory $orderHistory, $status, $orderId = '', $statusToCheck = null)
 {
     $filter = ['id' => $order->hasData('id') ? $order->getId() : $orderId, 'status' => $statusToCheck === null ? $status : $statusToCheck];
     $objectManager->create('Magento\\Customer\\Test\\TestStep\\LoginCustomerOnFrontendStep', ['customer' => $customer])->run();
     $customerAccountIndex->getAccountMenuBlock()->openMenuItem('My Orders');
     $errorMessage = implode(', ', $filter);
     \PHPUnit_Framework_Assert::assertTrue($orderHistory->getOrderHistoryBlock()->isOrderVisible($filter), 'Order with following data \'' . $errorMessage . '\' is absent in Orders block on frontend.');
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:21,代碼來源:AssertOrderInOrdersGridOnFrontend.php

示例10: run

 /**
  * Review order contents and place order.
  *
  * @return array
  */
 public function run()
 {
     $this->orderReviewExpress->getReviewBlock()->selectShippingMethod($this->shipping);
     foreach ($this->prices as $priceName => $value) {
         $assertName = 'Assert' . ucfirst($priceName) . 'OrderReview';
         $assert = $this->objectManager->create('Magento\\Checkout\\Test\\Constraint\\' . $assertName);
         $assert->processAssert($this->checkoutOnepage, $value);
     }
     $this->orderReviewExpress->getReviewBlock()->placeOrder();
     $order = $this->fixtureFactory->createByCode('orderInjectable', ['data' => ['entity_id' => ['products' => $this->products]]]);
     return ['orderId' => $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId(), 'order' => $order];
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:17,代碼來源:ExpressCheckoutOrderPlaceStep.php

示例11: deleteCustomerAddress

 /**
  * Click delete customer address button.
  *
  * @param Address $addressToDelete
  * @return $this
  */
 public function deleteCustomerAddress(Address $addressToDelete)
 {
     $addressRenderer = $this->objectManager->create(\Magento\Customer\Test\Block\Address\Renderer::class, ['address' => $addressToDelete, 'type' => 'html']);
     $addressToDelete = $addressRenderer->render();
     $dataList = explode("\n", $addressToDelete);
     $dataList = implode("') and contains(.,'", $dataList);
     $this->_rootElement->find(sprintf($this->addressSelector, $dataList), Locator::SELECTOR_XPATH)->find($this->deleteAddress)->click();
     $element = $this->browser->find($this->confirmModal);
     /** @var \Magento\Ui\Test\Block\Adminhtml\Modal $modal */
     $modal = $this->blockFactory->create(\Magento\Ui\Test\Block\Adminhtml\Modal::class, ['element' => $element]);
     $modal->acceptAlert();
     return $this;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:19,代碼來源:Addresses.php

示例12: processAssert

 /**
  * Place order and verify there is no checkbox Terms and Conditions.
  *
  * @param FixtureFactory $fixtureFactory
  * @param ObjectManager $objectManager
  * @param string $product
  * @param BrowserInterface $browser
  * @param CatalogProductView $catalogProductView
  * @param CheckoutCart $checkoutCart
  * @param CheckoutOnepage $checkoutOnepage
  * @param CheckoutAgreement $agreement
  * @param array $shipping
  * @param array $payment
  * @return void
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(FixtureFactory $fixtureFactory, ObjectManager $objectManager, $product, BrowserInterface $browser, CatalogProductView $catalogProductView, CheckoutCart $checkoutCart, CheckoutOnepage $checkoutOnepage, CheckoutAgreement $agreement, $shipping, $payment)
 {
     $createProductsStep = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', ['products' => $product]);
     $product = $createProductsStep->run();
     $billingAddress = $fixtureFactory->createByCode('address', ['dataset' => 'default']);
     $browser->open($_ENV['app_frontend_url'] . $product['products'][0]->getUrlKey() . '.html');
     $catalogProductView->getViewBlock()->clickAddToCartButton();
     $catalogProductView->getMessagesBlock()->waitSuccessMessage();
     $checkoutCart->open();
     $checkoutCart->getCartBlock()->getOnepageLinkBlock()->proceedToCheckout();
     $checkoutOnepage->getLoginBlock()->clickContinue();
     $checkoutOnepage->getBillingBlock()->fill($billingAddress);
     $checkoutOnepage->getBillingBlock()->clickContinue();
     $checkoutOnepage->getShippingMethodBlock()->selectShippingMethod($shipping);
     $checkoutOnepage->getShippingMethodBlock()->clickContinue();
     $checkoutOnepage->getPaymentBlock()->selectPaymentMethod($payment);
     \PHPUnit_Framework_Assert::assertFalse($checkoutOnepage->getAgreementReview()->checkAgreement($agreement), 'Checkout Agreement \'' . $agreement->getName() . '\' is present in the Place order step.');
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:35,代碼來源:AssertTermAbsentOnCheckout.php

示例13: setConfiguration

 /**
  * Set integration data to configuration file.
  *
  * @param Integration $integration
  * @return void
  */
 protected function setConfiguration(Integration $integration)
 {
     $fileConfig = MTF_BP . '/etc/config.xml';
     $dom = new \DOMDocument();
     if (!file_exists($fileConfig)) {
         copy(MTF_BP . '/etc/config.xml.dist', $fileConfig);
     }
     $dom->load($fileConfig);
     $webapiToken = (new \DOMXPath($dom))->query('//config/handler/webapi/token')->item(0);
     if ($webapiToken) {
         $webapiToken->nodeValue = $integration->getToken();
     } else {
         $webapi = (new \DOMXPath($dom))->query('//config/handler/webapi')->item(0);
         $webapi->appendChild($dom->createElement('token', $integration->getToken()));
     }
     $dom->save($fileConfig);
     $this->configuration = $this->objectManager->create('Magento\\Mtf\\Config\\DataInterface');
 }
開發者ID:tingyeeh,項目名稱:magento2,代碼行數:24,代碼來源:WebapiDecorator.php

示例14: processAssert

 /**
  * Verify Terms and Conditions checkbox is absent on checkout page.
  *
  * @param ObjectManager $objectManager
  * @param $products
  * @param CheckoutOnepage $checkoutOnepage
  * @param $shipping
  * @param $payment
  * @param CheckoutAgreement $agreement
  *
  * @SuppressWarnings(PHPMD.ExcessiveParameterList)
  */
 public function processAssert(ObjectManager $objectManager, $products, CheckoutOnepage $checkoutOnepage, $shipping, $payment, CheckoutAgreement $agreement)
 {
     $shippingAddressData = ['shippingAddress' => ['dataSet' => 'US_address_1']];
     $productsData = ['products' => $products];
     $shippingMethodData = ['shipping' => $shipping];
     $paymentData = ['payment' => $payment];
     $products = $objectManager->create('Magento\\Catalog\\Test\\TestStep\\CreateProductsStep', $productsData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\AddProductsToTheCartStep', $products)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\ProceedToCheckoutStep')->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingAddressStep', $shippingAddressData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\FillShippingMethodStep', $shippingMethodData)->run();
     $objectManager->create('Magento\\Checkout\\Test\\TestStep\\SelectPaymentMethodStep', $paymentData)->run();
     \PHPUnit_Framework_Assert::assertFalse($checkoutOnepage->getAgreementReview()->checkAgreement($agreement), 'Checkout Agreement \'' . $agreement->getName() . '\' is present in the Place order step.');
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:26,代碼來源:AssertTermAbsentOnCheckout.php

示例15: find

 /**
  * Find element on the page
  *
  * @param string $selector
  * @param string $strategy
  * @param string $type = select|multiselect|checkbox|null OR custom class with full namespace
  * @param ElementInterface $context
  * @return ElementInterface
  * @throws \Exception
  */
 public function find($selector, $strategy = Locator::SELECTOR_CSS, $type = null, ElementInterface $context = null)
 {
     $locator = new Locator($selector, $strategy);
     $this->eventManager->dispatchEvent(['find'], [__METHOD__, $locator]);
     $className = 'Magento\\Mtf\\Client\\ElementInterface';
     if (null !== $type) {
         if (strpos($type, '\\') === false) {
             $type = ucfirst(strtolower($type));
             if (class_exists('Magento\\Mtf\\Client\\Element\\' . $type . 'Element')) {
                 $className = 'Magento\\Mtf\\Client\\Element\\' . $type . 'Element';
             }
         } else {
             if (!class_exists($type) && !interface_exists($type)) {
                 throw new \Exception(sprintf('Requested interface or class "%s" does not exists!', $type));
             }
             $className = $type;
         }
     }
     return $this->objectManager->create($className, ['driver' => $this, 'locator' => $locator, 'context' => $context]);
 }
開發者ID:hientruong90,項目名稱:ee_14_installer,代碼行數:30,代碼來源:Driver.php


注:本文中的Magento\Mtf\ObjectManager::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。