Beispiel #1
0
 /**
  * Retrieve subject
  *
  * @return \Magento\Backend\Model\Config\Structure\SearchInterface
  */
 protected function _getSubject()
 {
     if (!$this->_subject) {
         $this->_subject = $this->_objectManager->get('Magento\\Backend\\Model\\Config\\Structure');
     }
     return $this->_subject;
 }
 public function testGetGridParentHtml()
 {
     $this->_block = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Cart', '', array());
     $mockCollection = $this->getMockBuilder('\\Magento\\Framework\\Data\\Collection')->disableOriginalConstructor()->getMock();
     $this->_block->setCollection($mockCollection);
     $this->assertContains("<div class=\"grid-actions\">", $this->_block->getGridParentHtml());
 }
Beispiel #3
0
 public function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_persistentSession = $this->_objectManager->get('Magento\\Persistent\\Helper\\Session');
     $this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
     $this->_model = $this->_objectManager->create('Magento\\Persistent\\Model\\Observer\\Session', ['persistentSession' => $this->_persistentSession, 'customerSession' => $this->_customerSession]);
 }
Beispiel #4
0
 /**
  * Modify price
  *
  * @param mixed $price
  * @param Product $product
  * @return mixed
  */
 public function modifyPrice($price, Product $product)
 {
     foreach ($this->modifiers as $modifierClass) {
         $price = $this->objectManager->get($modifierClass)->modifyPrice($price, $product);
     }
     return $price;
 }
Beispiel #5
0
 protected function setUp()
 {
     $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->helper = $this->objectManager->get('Magento\\Catalog\\Helper\\Data');
     $this->taxRuleFixtureFactory = new TaxRuleFixtureFactory();
     $this->scopeConfig = $this->objectManager->get('Magento\\Framework\\App\\MutableScopeConfig');
 }
Beispiel #6
0
 /**
  * Create cache model
  *
  * @return CacheInterface
  */
 protected function _getCache()
 {
     if (null == $this->_cache) {
         $this->_cache = $this->_objectManager->get('Magento\\Framework\\App\\Cache');
     }
     return $this->_cache;
 }
Beispiel #7
0
 /**
  * Get Installer Db type instance
  *
  * @param string $type
  * @return \Magento\Install\Model\Installer\Db\AbstractDb | bool
  * @throws \InvalidArgumentException
  */
 public function get($type)
 {
     if (!empty($type) && isset($this->_types[(string) $type])) {
         return $this->_objectManager->get($this->_types[(string) $type]);
     }
     return false;
 }
 public function __wakeup()
 {
     $this->pluginLocator = \Magento\Framework\App\ObjectManager::getInstance();
     $this->pluginList = $this->pluginLocator->get('Magento\\Framework\\Interception\\PluginList');
     $this->chain = $this->pluginLocator->get('Magento\\Framework\\Interception\\Chain');
     $this->subjectType = get_parent_class($this);
 }
Beispiel #9
0
 public function testApplyAllDataUpdates()
 {
     /*reset versions*/
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Module\\ResourceInterface')->setDbVersion('adminnotification_setup', false);
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Module\\ResourceInterface')->setDataVersion('adminnotification_setup', false);
     $this->_model->deleteTableRow('core_resource', 'code', 'adminnotification_setup');
     $this->_model->getConnection()->dropTable($this->_model->getTable('adminnotification_inbox'));
     $this->_model->getConnection()->dropTable($this->_model->getTable('admin_system_messages'));
     /** @var \Magento\Framework\Cache\FrontendInterface $cache */
     $cache = $this->_objectManager->get('Magento\\Framework\\App\\Cache\\Type\\Config');
     $cache->clean();
     try {
         /* This triggers plugin to be executed */
         $this->dispatch('index/index');
     } catch (\Exception $e) {
         $this->fail("Impossible to continue other tests, because database is broken: {$e}");
     }
     try {
         $tableData = $this->_model->getConnection()->describeTable($this->_model->getTable('adminnotification_inbox'));
         $this->assertNotEmpty($tableData);
     } catch (\Exception $e) {
         $this->fail("Impossible to continue other tests, because database is broken: {$e}");
     }
     $this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'version'));
     $this->assertNotEmpty($this->_model->getTableRow('core_resource', 'code', 'adminnotification_setup', 'data_version'));
 }
Beispiel #10
0
 public function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_persistentSession = $this->_objectManager->get('Magento\\Persistent\\Helper\\Session');
     $this->_cookieMock = $this->getMock('Magento\\Framework\\Stdlib\\Cookie', array('set'), array(), '', false);
     $this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
     $this->_model = $this->_objectManager->create('Magento\\Persistent\\Model\\Observer\\Session', array('persistentSession' => $this->_persistentSession, 'cookie' => $this->_cookieMock, 'customerSession' => $this->_customerSession));
 }
Beispiel #11
0
 /**
  * Create specification instance
  *
  * @param string $specificationClass
  * @return SpecificationInterface
  * @throws \InvalidArgumentException
  */
 public function create($specificationClass)
 {
     $specification = $this->objectManager->get($specificationClass);
     if (!$specification instanceof SpecificationInterface) {
         throw new \InvalidArgumentException('Specification must implement SpecificationInterface');
     }
     return $specification;
 }
Beispiel #12
0
 /**
  * Provide custom price model with basic validation
  *
  * @param string $name
  * @return \Magento\Catalog\Model\Product\CatalogPriceInterface
  * @throws \UnexpectedValueException
  */
 public function create($name)
 {
     $customPriceModel = $this->objectManager->get($name);
     if (!$customPriceModel instanceof \Magento\Catalog\Model\Product\CatalogPriceInterface) {
         throw new \UnexpectedValueException('Class ' . $name . ' should be an instance of \\Magento\\Catalog\\Model\\Product\\CatalogPriceInterface');
     }
     return $customPriceModel;
 }
Beispiel #13
0
 /**
  * Get cache instance model
  *
  * @param string $instanceName
  * @return \Magento\Framework\Cache\FrontendInterface
  * @throws \UnexpectedValueException
  */
 public function get($instanceName)
 {
     $instance = $this->_objectManager->get($instanceName);
     if (!$instance instanceof \Magento\Framework\Cache\FrontendInterface) {
         throw new \UnexpectedValueException("Cache type class '{$instanceName}' has to be a cache frontend.");
     }
     return $instance;
 }
Beispiel #14
0
 /**
  * Gets product of particular type
  *
  * @param string $className
  * @param array $data
  * @return \Magento\Catalog\Model\Product\Type\AbstractType
  * @throws \Magento\Framework\Model\Exception
  */
 public function get($className, array $data = array())
 {
     $product = $this->_objectManager->get($className, $data);
     if (!$product instanceof \Magento\Catalog\Model\Product\Type\AbstractType) {
         throw new \Magento\Framework\Model\Exception($className . ' doesn\'t extends \\Magento\\Catalog\\Model\\Product\\Type\\AbstractType');
     }
     return $product;
 }
Beispiel #15
0
 public function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     /** @var \Magento\Persistent\Helper\Session $persistentSessionHelper */
     $this->_persistentSessionHelper = $this->_objectManager->create('Magento\\Persistent\\Helper\\Session');
     $this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
     $this->_block = $this->_objectManager->create('Magento\\Persistent\\Block\\Header\\Additional');
 }
Beispiel #16
0
 protected function setUp()
 {
     \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_block = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Multishipping\\Block\\Checkout\\Overview', 'checkout_overview', array('data' => array('renderer_template' => 'Magento_Multishipping::checkout/item/default.phtml', 'row_renderer_template' => 'Magento_Multishipping::checkout/overview/item.phtml')));
     $this->_block->addChild('renderer.list', '\\Magento\\Framework\\View\\Element\\RendererList');
     $this->_block->getChildBlock('renderer.list')->addChild('default', '\\Magento\\Checkout\\Block\\Cart\\Item\\Renderer', array('template' => 'cart/item/default.phtml'));
 }
 public function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
     $this->_customerAccountService = $this->_objectManager->create('Magento\\Customer\\Service\\V1\\CustomerAccountServiceInterface');
     $this->_persistentSessionHelper = $this->_objectManager->create('Magento\\Persistent\\Helper\\Session');
     $this->_observer = $this->_objectManager->create('Magento\\Persistent\\Model\\Observer\\EmulateCustomer', ['customerAccountService' => $this->_customerAccountService, 'persistentSession' => $this->_persistentSessionHelper]);
 }
Beispiel #18
0
 /**
  * Get renderer for Mime-Type specified in Accept header of request.
  *
  * @return \Magento\Webapi\Controller\Rest\Response\RendererInterface
  * @throws \Magento\Webapi\Exception
  * @throws \LogicException
  */
 public function get()
 {
     $renderer = $this->_objectManager->get($this->_getRendererClass());
     if (!$renderer instanceof \Magento\Webapi\Controller\Rest\Response\RendererInterface) {
         throw new \LogicException('The renderer must implement "Magento\\Webapi\\Controller\\Rest\\Response\\RendererInterface".');
     }
     return $renderer;
 }
Beispiel #19
0
 /**
  * Return newly created instance of a view file list
  *
  * @param string $instanceName
  * @return \Magento\Framework\View\File\FileList
  * @throws \UnexpectedValueException
  */
 public function create($instanceName = self::FILE_LIST_COLLATOR)
 {
     $collator = $this->objectManager->get($instanceName);
     if (!$collator instanceof CollateInterface) {
         throw new \UnexpectedValueException("{$instanceName} has to implement the collate interface.");
     }
     return $this->objectManager->create('Magento\\Framework\\View\\File\\FileList', array('collator' => $collator));
 }
Beispiel #20
0
 /**
  * Get action class instance by class name
  *
  * @param string $className
  * @throws \InvalidArgumentException
  * @return ActionInterface
  */
 public function get($className)
 {
     $action = $this->objectManager->get($className);
     if (!$action instanceof ActionInterface) {
         throw new \InvalidArgumentException($className . ' doesn\'t implement \\Magento\\Framework\\Mview\\ActionInterface');
     }
     return $action;
 }
Beispiel #21
0
 /**
  * Get array optioned object
  *
  * @param string $model
  * @throws \InvalidArgumentException
  * @return \Magento\Framework\Option\ArrayInterface
  */
 public function get($model)
 {
     $modelInstance = $this->_objectManager->get($model);
     if (false == $modelInstance instanceof \Magento\Framework\Option\ArrayInterface) {
         throw new \InvalidArgumentException($model . 'doesn\'t implement \\Magento\\Framework\\Option\\ArrayInterface');
     }
     return $modelInstance;
 }
Beispiel #22
0
 protected function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $customerTaxClassSourceMock = $this->getMockBuilder('Magento\\Tax\\Model\\TaxClass\\Source\\Customer')->setMethods(['getAllOptions'])->disableOriginalConstructor()->getMock();
     $customerTaxClassSourceMock->expects($this->any())->method('getAllOptions')->will($this->returnValue([['value' => '1', 'name' => 'Retail Customer'], ['value' => '2', 'name' => 'Guest']]));
     $productTaxClassSourceMock = $this->getMockBuilder('Magento\\Tax\\Model\\TaxClass\\Source\\Product')->setMethods(['getAllOptions'])->disableOriginalConstructor()->getMock();
     $productTaxClassSourceMock->expects($this->any())->method('getAllOptions')->will($this->returnValue([['value' => '1', 'name' => 'Taxable Goods'], ['value' => '2', 'name' => 'Shipping']]));
     $this->_block = $this->_objectManager->create('Magento\\Tax\\Block\\Adminhtml\\Rule\\Edit\\Form', ['registry' => $this->_objectManager->get('Magento\\Framework\\Registry'), 'customerTaxClassSource' => $customerTaxClassSourceMock, 'productTaxClassSource' => $productTaxClassSourceMock]);
 }
Beispiel #23
0
 public function setUp()
 {
     $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->resource = $this->objectManager->get('Magento\\Framework\\App\\Resource');
     $this->connection = $this->resource->getConnection('core_write');
     $this->model = $this->objectManager->create('Magento\\Framework\\Mview\\View\\Changelog', array('resource' => $this->resource));
     $this->model->setViewId('test_view_id_1');
     $this->model->create();
 }
 public function setUp()
 {
     $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_customerSession = $this->_objectManager->get('Magento\\Customer\\Model\\Session');
     $this->_customerAccountService = $this->_objectManager->create('Magento\\Customer\\Service\\V1\\CustomerAccountServiceInterface');
     $this->_checkoutSession = $this->getMockBuilder('Magento\\Checkout\\Model\\Session')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->_persistentSessionHelper = $this->_objectManager->create('Magento\\Persistent\\Helper\\Session');
     $this->_observer = $this->_objectManager->create('Magento\\Persistent\\Model\\Observer\\EmulateQuote', ['customerAccountService' => $this->_customerAccountService, 'checkoutSession' => $this->_checkoutSession, 'persistentSession' => $this->_persistentSessionHelper]);
 }
Beispiel #25
0
 /**
  * Get method
  *
  * @param string $type
  * @return RenderInterface
  * @throws \InvalidArgumentException
  */
 public function get($type)
 {
     $className = 'Magento\\Framework\\View\\Render\\' . ucfirst($type);
     $model = $this->objectManager->get($className);
     if ($model instanceof RenderInterface === false) {
         throw new \InvalidArgumentException(sprintf('Type "%s" is not instance on Magento\\Framework\\View\\RenderInterface', $type));
     }
     return $model;
 }
Beispiel #26
0
 /**
  * Invoke an updater, passing an input value to it, and return invocation result
  *
  * @param mixed $value
  * @param string $updaterClass
  * @return mixed
  * @throws \UnexpectedValueException
  */
 protected function applyUpdater($value, $updaterClass)
 {
     /** @var \Magento\Framework\View\Layout\Argument\UpdaterInterface $updaterInstance */
     $updaterInstance = $this->objectManager->get($updaterClass);
     if (!$updaterInstance instanceof \Magento\Framework\View\Layout\Argument\UpdaterInterface) {
         throw new \UnexpectedValueException(sprintf('Instance of layout argument updater is expected, got %s instead.', get_class($updaterInstance)));
     }
     return $updaterInstance->update($value);
 }
Beispiel #27
0
 /**
  * Generate Handlers
  */
 public function launch()
 {
     $this->block->launch();
     $this->fixture->launch();
     $this->handler->launch();
     $this->page->launch();
     $this->repository->launch();
     return $this->objectManager->get('Magento\\Framework\\App\\ResponseInterface');
 }
Beispiel #28
0
 /**
  * @magentoConfigFixture current_store catalog/productalert/allow_price 1
  *
  * @magentoDataFixture Magento/ProductAlert/_files/product_alert.php
  */
 public function testProcess()
 {
     $this->_objectManager->configure(['Magento\\ProductAlert\\Model\\Observer' => ['arguments' => ['transportBuilder' => ['instance' => 'Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock']]], 'Magento\\ProductAlert\\Model\\Email' => ['arguments' => ['transportBuilder' => ['instance' => 'Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock']]], 'preferences' => ['Magento\\Framework\\Mail\\TransportInterface' => 'Magento\\TestFramework\\Mail\\TransportInterfaceMock', 'Magento\\TestFramework\\Mail\\Template\\TransportBuilder' => 'Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock']]);
     \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND);
     $observer = $this->_objectManager->get('Magento\\ProductAlert\\Model\\Observer');
     $observer->process();
     /** @var \Magento\TestFramework\Mail\Template\TransportBuilderMock $transportBuilder */
     $transportBuilder = $this->_objectManager->get('Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock');
     $this->assertStringMatchesFormat('%AHello %A' . $this->_customerViewHelper->getCustomerName($this->_customerSession->getCustomerDataObject()) . ',%A', $transportBuilder->getSentMessage()->getBodyHtml()->getContent());
 }
Beispiel #29
0
 /**
  * Get carrier instance
  *
  * @param string $carrierCode
  * @return bool|Carrier\AbstractCarrier
  */
 public function get($carrierCode)
 {
     $className = $this->_scopeConfig->getValue('carriers/' . $carrierCode . '/model', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
     if (!$className) {
         return false;
     }
     $carrier = $this->_objectManager->get($className);
     $carrier->setId($carrierCode);
     return $carrier;
 }
Beispiel #30
0
 public function testGetCustomerMissingCustomer()
 {
     $moduleManager = $this->objectManager->get('Magento\\Framework\\Module\\Manager');
     if ($moduleManager->isEnabled('Magento_PageCache')) {
         $customerDataFactory = $this->objectManager->create('Magento\\Customer\\Api\\Data\\CustomerInterfaceFactory');
         $customerData = $customerDataFactory->create()->setGroupId($this->_customerSession->getCustomerGroupId());
         $this->assertEquals($customerData, $this->_block->getCustomer());
     } else {
         $this->assertNull($this->_block->getCustomer());
     }
 }