本文整理汇总了PHP中Magento\TestFramework\Helper\Bootstrap类的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap类的具体用法?PHP Bootstrap怎么用?PHP Bootstrap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bootstrap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @magentoDataFixture Magento/Sales/_files/quote.php
*/
protected function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$quote = $this->_objectManager->create('Magento\\Quote\\Model\\Quote')->load(1);
$sessionQuoteMock = $this->getMockBuilder('Magento\\Backend\\Model\\Session\\Quote')->disableOriginalConstructor()->setMethods(['getCustomerId', 'getStore', 'getStoreId', 'getQuote'])->getMock();
$sessionQuoteMock->expects($this->any())->method('getCustomerId')->will($this->returnValue(1));
$sessionQuoteMock->expects($this->any())->method('getQuote')->will($this->returnValue($quote));
/** @var \Magento\Framework\View\LayoutInterface $layout */
$layout = $this->_objectManager->get('Magento\\Framework\\View\\LayoutInterface');
$this->_accountBlock = $layout->createBlock('Magento\\Sales\\Block\\Adminhtml\\Order\\Create\\Form\\Account', 'address_block' . rand(), ['sessionQuote' => $sessionQuoteMock]);
parent::setUp();
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:15,代码来源:AccountTest.php
示例2: setUp
protected function setUp()
{
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Theme\\Model\\Design\\Backend\\Exceptions');
$this->_model->setScope('default');
$this->_model->setScopeId(0);
$this->_model->setPath('design/theme/ua_regexp');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:ExceptionsTest.php
示例3: get
/**
* {@inheritdoc}
*/
public function get($filename, $scope)
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$readDirectory = $objectManager->create('Magento\\Framework\\Filesystem\\Directory\\Read', ['config' => ['path' => realpath(__DIR__ . '/../../_files/etc')], 'driver' => $objectManager->create('Magento\\Framework\\Filesystem\\Driver\\File')]);
$paths = ['data_object.xml'];
return new \Magento\Framework\Config\FileIterator($readDirectory, $paths);
}
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:FileResolverStub.php
示例4: setUp
protected function setUp()
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->filterBuilder = $this->objectManager->create('Magento\\Framework\\Api\\FilterBuilder');
$this->sortOrderBuilder = $this->objectManager->create('Magento\\Framework\\Api\\SortOrderBuilder');
$this->searchCriteriaBuilder = $this->objectManager->create('Magento\\Framework\\Api\\SearchCriteriaBuilder');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:CartRepositoryTest.php
示例5: testUpdateProduct
/**
* @magentoDbIsolation disabled
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
*/
public function testUpdateProduct()
{
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attr **/
$attr = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Eav\\Model\\Config')->getAttribute('catalog_product', 'weight');
$attr->setIsFilterable(1)->save();
$this->assertTrue($attr->isIndexable());
$repository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\ProductRepository');
$product = $repository->get('simple');
$product->setWeight(11);
$product->save();
$categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\CategoryFactory');
/** @var \Magento\Catalog\Block\Product\ListProduct $listProduct */
$listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Block\\Product\\ListProduct');
$category = $categoryFactory->create()->load(2);
$layer = $listProduct->getLayer();
$layer->setCurrentCategory($category);
$productCollection = $layer->getProductCollection();
$productCollection->addAttributeToSelect('weight');
$this->assertCount(1, $productCollection);
/** @var $product \Magento\Catalog\Model\Product */
foreach ($productCollection as $product) {
$this->assertEquals('Simple Product', $product->getName());
$this->assertEquals('Short description', $product->getShortDescription());
$this->assertEquals(11, $product->getWeight());
}
}
开发者ID:koliaGI,项目名称:magento2,代码行数:31,代码来源:RowTest.php
示例6: testToHtml
/**
* @covers \Magento\Framework\View\Element\AbstractBlock::toHtml
* @see testAssign()
*/
public function testToHtml()
{
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\State')->setAreaCode('any area');
$this->assertEmpty($this->_block->toHtml());
$this->_block->setTemplate(uniqid('invalid_filename.phtml'));
$this->assertEmpty($this->_block->toHtml());
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:TemplateTest.php
示例7: testSaveFailure
/**
* @magentoDataFixture Magento/Bundle/_files/product.php
* @magentoDbIsolation enabled
*/
public function testSaveFailure()
{
$this->markTestSkipped("When MAGETWO-36510 is fixed, need to change Dbisolation to disabled");
$bundleProductSku = 'bundle-product';
$product = $this->productRepository->get($bundleProductSku);
$bundleExtensionAttributes = $product->getExtensionAttributes()->getBundleProductOptions();
$bundleOption = $bundleExtensionAttributes[0];
$this->assertEquals(true, $bundleOption->getRequired());
$bundleOption->setRequired(false);
//set an incorrect option id to trigger exception
$bundleOption->setOptionId(-1);
$description = "hello";
$product->setDescription($description);
$product->getExtensionAttributes()->setBundleProductOptions([$bundleOption]);
$caughtException = false;
try {
$this->productRepository->save($product);
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$caughtException = true;
}
$this->assertTrue($caughtException);
/** @var \Magento\Catalog\Model\Product $product */
$product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product')->load($product->getId());
$this->assertEquals(null, $product->getDescription());
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:29,代码来源:BundleSaveOptionsTest.php
示例8: setUp
protected function setUp()
{
parent::setUp();
$productMetadataMock = $this->getMockBuilder('Magento\\Framework\\App\\ProductMetadata')->setMethods(['getVersion'])->disableOriginalConstructor()->getMock();
$productMetadataMock->expects($this->once())->method('getVersion')->willReturn($this::TEST_PRODUCT_VERSION);
$this->block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Backend\\Block\\Page\\Footer', '', ['productMetadata' => $productMetadataMock]);
}
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:FooterTest.php
示例9: testGetCollectionBase
/**
* Test getCollection None images
* 1) Check that image attributes were not loaded
* 2) Check no images were loaded
* 3) Check thumbnails when no thumbnail selected
*
* @magentoConfigFixture default_store sitemap/product/image_include base
*/
public function testGetCollectionBase()
{
$model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Sitemap\\Model\\Resource\\Catalog\\Product');
$products = $model->getCollection(\Magento\Store\Model\Store::DISTRO_STORE_ID);
$this->_checkProductCollection($products, 3, [1, 4, 5]);
// Check name attribute was loaded
foreach ($products as $product) {
$this->assertNotEmpty($product->getName(), 'name attribute was not loaded');
}
// Check thumbnail attribute
$this->assertEmpty($products[1]->getImage(), 'image attribute was loaded');
$this->assertEmpty($products[4]->getThumbnail(), 'thumbnail attribute was loaded');
$this->assertEquals('/s/e/second_image.png', $products[4]->getImage(), 'Incorrect image attribute');
// Check images loading
$this->assertEmpty($products[1]->getImages(), 'Images were loaded');
$this->assertNotEmpty($products[4]->getImages(), 'Images were not loaded');
$this->assertEquals('Simple Images', $products[4]->getImages()->getTitle(), 'Incorrect title');
$this->assertEquals('catalog/product/s/e/second_image.png', $products[4]->getImages()->getThumbnail(), 'Incorrect thumbnail');
$this->assertCount(1, $products[4]->getImages()->getCollection(), 'Number of loaded images is incorrect');
$imagesCollection = $products[4]->getImages()->getCollection();
$this->assertEquals('catalog/product/s/e/second_image.png', $imagesCollection[0]->getUrl(), 'Incorrect image url');
$this->assertEmpty($imagesCollection[0]->getCaption(), 'Caption not empty');
// Check no selection
$this->assertEmpty($products[5]->getThumbnail(), 'thumbnail is not empty');
$this->assertEquals('no_selection', $products[5]->getImage(), 'image is incorrect');
$this->assertEmpty($products[5]->getImages(), 'Product images were loaded');
}
开发者ID:vasiljok,项目名称:magento2,代码行数:35,代码来源:ProductTest.php
示例10: testGetResultingIds
/**
* @magentoDataFixture Magento/Review/_files/different_reviews.php
*/
public function testGetResultingIds()
{
$collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Review\\Model\\ResourceModel\\Review\\Product\\Collection');
$collection->addStatusFilter(\Magento\Review\Model\Review::STATUS_APPROVED);
$actual = $collection->getResultingIds();
$this->assertCount(2, $actual);
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:10,代码来源:CollectionTest.php
示例11: setUp
protected function setUp()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->storeManager = $objectManager->get('Magento\\Store\\Model\\StoreManagerInterface');
$this->storeManager->reinitStores();
$this->pathProcessor = $objectManager->get('Magento\\Webapi\\Controller\\PathProcessor');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:PathProcessorTest.php
示例12: tearDown
protected function tearDown()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
/** @var \Magento\Customer\Model\AddressRegistry $addressRegistry */
$customerRegistry = $objectManager->get('Magento\\Customer\\Model\\CustomerRegistry');
$customerRegistry->remove(1);
}
开发者ID:aiesh,项目名称:magento2,代码行数:7,代码来源:CustomerAddressServiceTest.php
示例13: testPrepareForm
/**
* @magentoAppIsolation enabled
*/
public function testPrepareForm()
{
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$objectManager->get('Magento\\Framework\\View\\DesignInterface')->setArea(\Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)->setDefaultDesignTheme();
$objectManager->get('Magento\\Framework\\Registry')->register('current_promo_quote_rule', $objectManager->create('Magento\\SalesRule\\Model\\Rule'));
$layout = $objectManager->create('Magento\\Framework\\View\\Layout');
$block = $layout->createBlock('Magento\\SalesRule\\Block\\Adminhtml\\Promo\\Quote\\Edit\\Tab\\Main');
$prepareFormMethod = new \ReflectionMethod('Magento\\SalesRule\\Block\\Adminhtml\\Promo\\Quote\\Edit\\Tab\\Main', '_prepareForm');
$prepareFormMethod->setAccessible(true);
$prepareFormMethod->invoke($block);
$form = $block->getForm();
foreach (['from_date', 'to_date'] as $id) {
$element = $form->getElement($id);
$this->assertNotNull($element);
$this->assertNotEmpty($element->getDateFormat());
}
// assert Customer Groups field
$customerGroupsField = $form->getElement('customer_group_ids');
/** @var \Magento\Customer\Api\GroupRepositoryInterface $groupRepository */
$groupRepository = $objectManager->create('Magento\\Customer\\Api\\GroupRepositoryInterface');
/** @var \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteria */
$searchCriteria = $objectManager->create('Magento\\Framework\\Api\\SearchCriteriaBuilder');
$objectConverter = $objectManager->get('Magento\\Framework\\Convert\\DataObject');
$groups = $groups = $groupRepository->getList($searchCriteria->create())->getItems();
$expected = $objectConverter->toOptionArray($groups, 'id', 'code');
$this->assertEquals($expected, $customerGroupsField->getValues());
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:30,代码来源:MainTest.php
示例14: setUp
public function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->_customerRepository = $this->_objectManager->get('Magento\\Customer\\Api\\CustomerRepositoryInterface');
$storeManager = $this->_objectManager->get('Magento\\Store\\Model\\StoreManager');
$this->_context = $this->_objectManager->get('Magento\\Backend\\Block\\Template\\Context', ['storeManager' => $storeManager]);
}
开发者ID:nja78,项目名称:magento2,代码行数:7,代码来源:CartsTest.php
示例15: setUp
/**
* Execute per test initialization.
*/
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$objectManager->get('Magento\\Framework\\App\\State')->setAreaCode('adminhtml');
$this->coreRegistry = $objectManager->get('Magento\\Framework\\Registry');
$this->block = $objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Customer\\Block\\Adminhtml\\Edit\\Tab\\Newsletter', '', ['registry' => $this->coreRegistry])->setTemplate('tab/newsletter.phtml');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:10,代码来源:NewsletterTest.php
示例16: setUp
/**
* {@inheritDoc}
*/
protected function setUp()
{
parent::setUp();
$objectManager = Bootstrap::getObjectManager();
$this->dataProvider = $objectManager->create(DataProvider::class, ['name' => 'category_form_data_source', 'primaryFieldName' => 'entity_id', 'requestFieldName' => 'id']);
$this->entityType = $objectManager->create(EavConfig::class)->getEntityType('catalog_category');
}
开发者ID:Doability,项目名称:magento2dev,代码行数:10,代码来源:DataProviderTest.php
示例17: getFixtureIntegration
/**
* @return Integration
*/
protected function getFixtureIntegration()
{
/** @var $integration Integration */
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$integration = $objectManager->create('Magento\\Integration\\Model\\Integration');
return $integration->load('Fixture Integration', 'name');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:10,代码来源:WebapiTest.php
示例18: testAvailableContainers
/**
* Test verify that theme contains available containers for widget
*/
public function testAvailableContainers()
{
$themeToTest = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('\\Magento\\Theme\\Model\\Theme');
$themeId = $themeToTest->load('Magento/blank', 'code')->getId();
$this->block->setTheme($themeId);
$this->assertContains('<option value="before.body.end" >', $this->block->toHtml());
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:ContainerTest.php
示例19: setUp
protected function setUp()
{
$this->_config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Config\\MutableScopeConfigInterface');
$data = ['access_list' => 'localhost', 'backend_host' => 'localhost', 'backend_port' => 8080, 'ttl' => 120];
$this->_config->setValue('system/full_page_cache/default', $data);
$this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\PageCache\\Model\\System\\Config\\Backend\\Varnish');
}
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:VarnishTest.php
示例20: setUp
protected function setUp()
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->builder = $this->objectManager->create('Magento\\Tax\\Service\\V1\\Data\\QuoteDetailsBuilder');
$this->itemBuilder = $this->objectManager->create('Magento\\Tax\\Service\\V1\\Data\\QuoteDetails\\ItemBuilder');
$this->addressBuilder = $this->objectManager->create('\\Magento\\Customer\\Service\\V1\\Data\\AddressBuilder');
}
开发者ID:Atlis,项目名称:docker-magento2,代码行数:7,代码来源:QuoteDetailsBuilderTest.php
注:本文中的Magento\TestFramework\Helper\Bootstrap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论