protected function setUp() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize([Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [DirectoryList::THEMES => ['path' => dirname(dirname(__DIR__)) . '/Theme/Model/_files/design']]]); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setAreaCode('frontend'); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\FileSystem'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme('Test/default'); }
public function testAll() { /** @var $objectManager \Magento\TestFramework\ObjectManager */ $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ $productRepository = $objectManager->create('Magento\\Catalog\\Api\\ProductRepositoryInterface'); $product = $productRepository->get('simple'); $productWithCross = $productRepository->get('simple_with_cross'); $objectManager->get('Magento\\Framework\\Registry')->register('product', $productWithCross); /** @var $block \Magento\Catalog\Block\Product\ProductList\Related */ $block = $objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Catalog\\Block\\Product\\ProductList\\Related'); $block->setLayout($objectManager->get('Magento\\Framework\\View\\LayoutInterface')); $block->setTemplate('Magento_Catalog::product/list/items.phtml'); $block->setType('related'); $block->addChild('addto', '\\Magento\\Catalog\\Block\\Product\\ProductList\\Item\\Container'); $block->getChildBlock('addto')->addChild('compare', '\\Magento\\Catalog\\Block\\Product\\ProductList\\Item\\AddTo\\Compare', ['template' => 'Magento_Catalog::product/list/addto/compare.phtml']); $html = $block->toHtml(); $this->assertNotEmpty($html); $this->assertContains('Simple Related Product', $html); /* name */ $this->assertContains('"product":"' . $product->getId() . '"', $html); /* part of url */ $this->assertInstanceOf('Magento\\Catalog\\Model\\ResourceModel\\Product\\Link\\Product\\Collection', $block->getItems()); }
/** * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Catalog/_files/product_simple.php * @dataProvider customerFunctionDataProvider * * @param bool isCustomerIdUsed */ public function testSend($isCustomerIdUsed) { \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); $this->_emailModel = $this->_objectManager->create('Magento\\ProductAlert\\Model\\Email'); /** @var \Magento\Store\Model\Website $website */ $website = $this->_objectManager->create('Magento\\Store\\Model\\Website'); $website->load(1); $this->_emailModel->setWebsite($website); /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */ $customerRepository = $this->_objectManager->create('Magento\\Customer\\Api\\CustomerRepositoryInterface'); $customer = $customerRepository->getById(1); if ($isCustomerIdUsed) { $this->_emailModel->setCustomerId(1); } else { $this->_emailModel->setCustomerData($customer); } /** @var \Magento\Catalog\Model\Product $product */ $product = $this->_objectManager->create('Magento\\Catalog\\Model\\Product'); $product->load(1); $this->_emailModel->addPriceProduct($product); $this->_emailModel->send(); /** @var \Magento\TestFramework\Mail\Template\TransportBuilderMock $transportBuilder */ $transportBuilder = $this->_objectManager->get('Magento\\TestFramework\\Mail\\Template\\TransportBuilderMock'); $this->assertContains('John Smith,', $transportBuilder->getSentMessage()->getBodyHtml()->getRawContent()); }
protected function setUp() { parent::setUp(); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Backend\\Model\\Auth'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\Config\\ScopeInterface')->setCurrentScope(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); }
public static function setUpBeforeClass() { self::$_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); if (\Magento\TestFramework\Helper\Bootstrap::getInstance()->getDbVendorName() != 'mysql') { self::markTestIncomplete('Bug MAGETWO-8513'); } }
/** * Retrieve cache states (enabled/disabled) information * * Access configuration file directly as it is not possible to re-include modified file under HHVM * @link https://github.com/facebook/hhvm/issues/1447 * * @return array * @SuppressWarnings(PHPMD.EvalExpression) */ protected function getCacheStates() { $configFilePool = new ConfigFilePool(); $configPath = Bootstrap::getInstance()->getAppTempDir() . '/' . DirectoryList::CONFIG . '/' . $configFilePool->getPath($configFilePool::APP_ENV); $configData = eval(str_replace('<?php', '', file_get_contents($configPath))); return $configData[State::CACHE_KEY]; }
protected function setUp() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array(\Magento\Framework\App\Filesystem::PARAM_APP_DIRS => array(\Magento\Framework\App\Filesystem::THEMES_DIR => array('path' => dirname(dirname(__DIR__)) . '/Core/Model/_files/design')))); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setAreaCode('frontend'); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\FileSystem'); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme('test_default'); }
/** * @magentoDataFixture Magento/Newsletter/_files/queue.php * @magentoAppIsolation enabled */ public function testSendPerSubscriberProblem() { $errorMsg = md5(microtime()); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface'); $transport->expects($this->any())->method('sendMessage')->willThrowException(new \Magento\Framework\Exception\MailException(__($errorMsg))); $builder = $this->getMock('\\Magento\\Newsletter\\Model\\Queue\\TransportBuilder', ['getTransport', 'setFrom', 'addTo', 'setTemplateOptions', 'setTemplateVars'], [], '', false); $builder->expects($this->any())->method('getTransport')->will($this->returnValue($transport)); $builder->expects($this->any())->method('setTemplateOptions')->will($this->returnSelf()); $builder->expects($this->any())->method('setTemplateVars')->will($this->returnSelf()); $builder->expects($this->any())->method('setFrom')->will($this->returnSelf()); $builder->expects($this->any())->method('addTo')->will($this->returnSelf()); /** @var $queue \Magento\Newsletter\Model\Queue */ $queue = $objectManager->create('Magento\\Newsletter\\Model\\Queue', ['transportBuilder' => $builder]); $queue->load('Subject', 'newsletter_subject'); // fixture $problem = $objectManager->create('Magento\\Newsletter\\Model\\Problem'); $problem->load($queue->getId(), 'queue_id'); $this->assertEmpty($problem->getId()); $queue->sendPerSubscriber(); $problem->load($queue->getId(), 'queue_id'); $this->assertNotEmpty($problem->getId()); $this->assertEquals($errorMsg, $problem->getProblemErrorText()); }
public function testCreate() { $dbInstance = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap()->getApplication()->getDbInstance(); $dbConfig = ['host' => $dbInstance->getHost(), 'username' => $dbInstance->getUser(), 'password' => $dbInstance->getPassword(), 'dbname' => $dbInstance->getSchema(), 'active' => true]; $connection = $this->model->create($dbConfig); $this->assertInstanceOf('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface', $connection); }
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', ['data' => ['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', ['template' => 'cart/item/default.phtml']); }
public static function tearDownAfterClass() { $db = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap()->getApplication()->getDbInstance(); if (!$db->isDbDumpExists()) { throw new \LogicException('DB dump does not exist.'); } $db->restoreFromDbDump(); }
/** * Emulate fixture design theme * * @param string $themePath */ protected function _emulateFixtureTheme($themePath = 'Test_FrameworkThemeTest/default') { \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend'); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $objectManager->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme($themePath); $this->_viewFileSystem = $objectManager->create('Magento\\Framework\\View\\FileSystem'); $this->_viewConfig = $objectManager->create('Magento\\Framework\\View\\ConfigInterface'); }
/** * @return \Magento\Catalog\Model\Webapi\Product\Option\Type\File\Processor */ private function getModel($pathConfig) { $rootPath = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getAppTempDir(); $dirList = $this->objectManager->create('\\Magento\\Framework\\App\\Filesystem\\DirectoryList', ['root' => $rootPath, 'config' => $pathConfig]); $fileSystem = $this->objectManager->create('\\Magento\\Framework\\Filesystem', ['directoryList' => $dirList]); $model = $this->objectManager->create('\\Magento\\Catalog\\Model\\Webapi\\Product\\Option\\Type\\File\\Processor', ['filesystem' => $fileSystem]); return $model; }
/** * @covers \Magento\Store\Model\App\Emulation::startEnvironmentEmulation * @covers \Magento\Store\Model\App\Emulation::stopEnvironmentEmulation */ public function testEnvironmentEmulation() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Store\\Model\\App\\Emulation'); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface'); $this->_model->startEnvironmentEmulation(1); $this->_model->stopEnvironmentEmulation(); $this->assertEquals(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, $design->getArea()); }
/** * Emulate fixture design theme * * @param string $themePath */ protected function _emulateFixtureTheme($themePath = 'test_default') { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array(\Magento\Framework\App\Filesystem::PARAM_APP_DIRS => array(\Magento\Framework\App\Filesystem::THEMES_DIR => array('path' => realpath(__DIR__ . '/../_files/design'))))); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend'); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $objectManager->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme($themePath); $this->_viewFileSystem = $objectManager->create('Magento\\Framework\\View\\FileSystem'); $this->_viewConfig = $objectManager->create('Magento\\Framework\\View\\ConfigInterface'); }
/** * Initialize base models */ protected function setUp() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array(\Magento\Framework\App\Filesystem::PARAM_APP_DIRS => array(\Magento\Framework\App\Filesystem::THEMES_DIR => array('path' => dirname(__DIR__) . '/_files/design')))); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $objectManager->get('Magento\\Framework\\App\\AreaList')->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)->load(\Magento\Framework\App\Area::PART_CONFIG); $objectManager->get('Magento\\Framework\\App\\State')->setAreaCode(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->_theme = $objectManager->create('Magento\\Framework\\View\\Design\\ThemeInterface'); $this->_model = $objectManager->create('Magento\\Core\\Model\\Theme\\Registration'); }
/** * @magentoConfigFixture current_store catalog/productalert/allow_price 1 * * @magentoDataFixture Magento/ProductAlert/_files/product_alert.php */ public function testProcess() { \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->assertContains('John Smith,', $transportBuilder->getSentMessage()->getBodyHtml()->getRawContent()); }
/** * @param string $type * @param string $expectedFile * @return string * * @dataProvider getPlaceholderImageUrlDataProvider * @magentoAppIsolation enabled */ public function testGetPlaceholderImageUrl($type, $expectedFile) { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $objectManager->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme('Magento/backend'); $expectedFilePath = "/adminhtml/Magento/backend/en_US/{$expectedFile}"; $url = $this->_model->getPlaceholderImageUrl($type); $this->assertStringEndsWith($expectedFilePath, $url); }
/** * Initialize base models */ protected function setUp() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize([Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [DirectoryList::THEMES => ['path' => dirname(__DIR__) . '/_files/design']]]); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $objectManager->get('Magento\\Framework\\App\\AreaList')->getArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)->load(\Magento\Framework\App\Area::PART_CONFIG); $objectManager->get('Magento\\Framework\\App\\State')->setAreaCode(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $this->_theme = $objectManager->create('Magento\\Framework\\View\\Design\\ThemeInterface'); $this->_model = $objectManager->create('Magento\\Theme\\Model\\Theme\\Registration'); }
/** * Emulate fixture design theme * * @param string $themePath */ protected function _emulateFixtureTheme($themePath = 'Test/default') { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize([Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [DirectoryList::THEMES => ['path' => realpath(__DIR__ . '/../_files/design')]]]); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea('frontend'); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $objectManager->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme($themePath); $this->_viewFileSystem = $objectManager->create('Magento\\Framework\\View\\FileSystem'); $this->_viewConfig = $objectManager->create('Magento\\Framework\\View\\ConfigInterface'); }
/** * @magentoDataFixture Magento/Catalog/_files/product_with_image.php */ public function testThumbnail() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->load(1); $size = $this->_block->getThumbnailSize(); $this->assertGreaterThan(1, $size); $this->assertContains('/' . $size, $this->_block->getThumbnailUrl($product)); $this->assertStringEndsWith('magento_image.jpg', $this->_block->getThumbnailUrl($product)); }
/** * @return \Magento\Backend\Model\Menu\Config */ protected function prepareMenuConfig() { $this->loginAdminUser(); \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize([Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [DirectoryList::MODULES => ['path' => __DIR__ . '/_files/menu']]]); /* @var $validationState \Magento\Framework\App\Arguments\ValidationState */ $validationState = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Arguments\\ValidationState', ['appMode' => State::MODE_DEFAULT]); /* @var $configReader \Magento\Backend\Model\Menu\Config\Reader */ $configReader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Backend\\Model\\Menu\\Config\\Reader', ['validationState' => $validationState]); return \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Backend\\Model\\Menu\\Config', ['configReader' => $configReader, 'configCacheType' => $this->configCacheType]); }
/** * @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()); }
protected function setUp() { /** * @var \Magento\Customer\Api\GroupManagementInterface $groupManagement */ $groupManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Customer\\Api\\GroupManagementInterface'); $notLoggedInId = $groupManagement->getNotLoggedInGroup()->getId(); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\Http\\Context')->setValue(\Magento\Customer\Model\Context::CONTEXT_GROUP, $notLoggedInId, $notLoggedInId); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Catalog\\Block\\Product\\NewProduct'); }
protected function setUp() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); $this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Checkout\\Block\\Cart\\Item\\Renderer'); /** @var $item \Magento\Sales\Model\Quote\Item */ $item = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Quote\\Item'); $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->load(1); $item->setProduct($product); $this->_block->setItem($item); }
/** * @magentoAppIsolation enabled * @magentoDataFixture Magento/Catalog/_files/product_with_image.php */ public function testImage() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface')->setDefaultDesignTheme(); $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->load(1); $size = $this->_block->getImageSize(); $this->assertGreaterThan(1, $size); $this->assertContains('/' . $size, $this->_block->getImageUrl($product)); $this->assertStringEndsWith('magento_image.jpg', $this->_block->getImageUrl($product)); }
public function testGetConnection() { $db = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap()->getApplication()->getDbInstance(); $config = ['profiler' => ['class' => '\\Magento\\Framework\\DB\\Profiler', 'enabled' => true], 'type' => 'pdo_mysql', 'host' => $db->getHost(), 'username' => $db->getUser(), 'password' => $db->getPassword(), 'dbname' => $db->getSchema(), 'active' => true]; /** @var \Magento\Framework\Model\ResourceModel\Type\Db\Pdo\Mysql $object */ $object = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Model\\ResourceModel\\Type\\Db\\Pdo\\Mysql', ['config' => $config]); $connection = $object->getConnection(\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\DB\\LoggerInterface')); $this->assertInstanceOf('\\Magento\\Framework\\DB\\Adapter\\Pdo\\Mysql', $connection); $profiler = $connection->getProfiler(); $this->assertInstanceOf('\\Magento\\Framework\\DB\\Profiler', $profiler); }
protected function setUp() { parent::setUp(); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface')->setDefaultDesignTheme()->getDesignTheme(); $type = 'Magento\\Cms\\Block\\Widget\\Page\\Link'; /** @var $model \Magento\Widget\Model\Widget\Instance */ $model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Widget\\Model\\Widget\\Instance'); $code = $model->setType($type)->getWidgetReference('type', $type, 'code'); $this->getRequest()->setParam('code', $code); $this->getRequest()->setParam('theme_id', $theme->getId()); }
/** * @covers \Magento\Core\Model\App\Emulation::startEnvironmentEmulation * @covers \Magento\Core\Model\App\Emulation::stopEnvironmentEmulation */ public function testEnvironmentEmulation() { $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Core\\Model\\App\\Emulation'); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE); $design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\DesignInterface'); $initialEnvInfo = $this->_model->startEnvironmentEmulation(1); $initialDesign = $initialEnvInfo->getInitialDesign(); $this->assertEquals(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, $initialDesign['area']); $this->assertEquals(\Magento\Framework\App\Area::AREA_FRONTEND, $design->getDesignTheme()->getData('area')); $this->_model->stopEnvironmentEmulation($initialEnvInfo); $this->assertEquals(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, $design->getArea()); }
public function testTest() { $reindexCommand = Bootstrap::getObjectManager()->get('Magento\\Indexer\\Console\\Command\\IndexerReindexCommand'); $parser = Bootstrap::getObjectManager()->get('Magento\\Framework\\Xml\\Parser'); $itfApplication = \Magento\TestFramework\Helper\Bootstrap::getInstance()->getBootstrap()->getApplication(); $model = new FixtureModel($reindexCommand, $parser, $itfApplication->getInitParams()); $model->loadConfig(__DIR__ . '/_files/small.xml'); $model->initObjectManager(); foreach ($model->loadFixtures()->getFixtures() as $fixture) { $fixture->execute(); } }