本文整理匯總了PHP中Magento\TestFramework\Helper\Bootstrap::getInstance方法的典型用法代碼示例。如果您正苦於以下問題:PHP Bootstrap::getInstance方法的具體用法?PHP Bootstrap::getInstance怎麽用?PHP Bootstrap::getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\TestFramework\Helper\Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setUp
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: testAll
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: testSend
/**
* @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: setUp
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: setUpBeforeClass
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: getCacheStates
/**
* 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: setUp
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: testSendPerSubscriberProblem
/**
* @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());
}
示例9: testCreate
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: setUp
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: tearDownAfterClass
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: _emulateFixtureTheme
/**
* 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: getModel
/**
* @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: testEnvironmentEmulation
/**
* @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: _emulateFixtureTheme
/**
* 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');
}