예제 #1
0
 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');
 }
예제 #2
0
 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());
 }
예제 #3
0
 /**
  * @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());
 }
예제 #4
0
 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);
 }
예제 #5
0
 public static function setUpBeforeClass()
 {
     self::$_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     if (\Magento\TestFramework\Helper\Bootstrap::getInstance()->getDbVendorName() != 'mysql') {
         self::markTestIncomplete('Bug MAGETWO-8513');
     }
 }
예제 #6
0
 /**
  * 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];
 }
예제 #7
0
 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');
 }
예제 #8
0
 /**
  * @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);
 }
예제 #10
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', ['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']);
 }
예제 #11
0
 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();
 }
예제 #12
0
 /**
  * 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');
 }
예제 #13
0
 /**
  * @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;
 }
예제 #14
0
 /**
  * @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());
 }
예제 #15
0
 /**
  * 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');
 }
예제 #16
0
 /**
  * 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');
 }
예제 #17
0
 /**
  * @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());
 }
예제 #18
0
 /**
  * @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);
 }
예제 #19
0
 /**
  * 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');
 }
예제 #20
0
 /**
  * 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');
 }
예제 #21
0
 /**
  * @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));
 }
예제 #22
0
 /**
  * @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]);
 }
예제 #23
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());
 }
예제 #24
0
 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');
 }
예제 #25
0
 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);
 }
예제 #26
0
 /**
  * @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));
 }
예제 #27
0
 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);
 }
예제 #28
0
 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());
 }
예제 #29
0
 /**
  * @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());
 }
예제 #30
0
 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();
     }
 }