當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Helper\Bootstrap類代碼示例

本文整理匯總了PHP中Magento\TestFramework\Helper\Bootstrap的典型用法代碼示例。如果您正苦於以下問題:PHP Bootstrap類的具體用法?PHP Bootstrap怎麽用?PHP Bootstrap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Bootstrap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的Magento\TestFramework\Helper\Bootstrap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。