コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 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');
 }
コード例 #3
0
ファイル: FileResolverStub.php プロジェクト: aiesh/magento2
 /**
  * {@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);
 }
コード例 #4
0
 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');
 }
コード例 #5
0
ファイル: RowTest.php プロジェクト: koliaGI/magento2
 /**
  * @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());
     }
 }
コード例 #6
0
 /**
  * @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());
 }
コード例 #7
0
 /**
  * @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());
 }
コード例 #8
0
ファイル: FooterTest.php プロジェクト: Doability/magento2dev
 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]);
 }
コード例 #9
0
ファイル: ProductTest.php プロジェクト: vasiljok/magento2
 /**
  * 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');
 }
コード例 #10
0
 /**
  * @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);
 }
コード例 #11
0
 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');
 }
コード例 #12
0
 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);
 }
コード例 #13
0
ファイル: MainTest.php プロジェクト: pradeep-wagento/magento2
 /**
  * @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());
 }
コード例 #14
0
ファイル: CartsTest.php プロジェクト: nja78/magento2
 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]);
 }
コード例 #15
0
 /**
  * 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');
 }
コード例 #16
0
 /**
  * {@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');
 }
コード例 #17
0
 /**
  * @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');
 }
コード例 #18
0
 /**
  * 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());
 }
コード例 #19
0
 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');
 }
コード例 #20
0
 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');
 }
コード例 #21
0
 /**
  * @magentoApiDataFixture Magento/GiftMessage/_files/quote_with_item_message.php
  */
 public function testSave()
 {
     // sales/gift_options/allow_items must be set to 1 in system configuration
     // @todo remove next statement when \Magento\TestFramework\TestCase\WebapiAbstract::_updateAppConfig is fixed
     $this->markTestIncomplete('This test relies on system configuration state.');
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->objectManager->create('Magento\\Quote\\Model\\Quote');
     $quote->load('test_order_item_with_message', 'reserved_order_id');
     $product = $this->objectManager->create('Magento\\Catalog\\Model\\Product');
     $product->load($product->getIdBySku('simple_with_message'));
     $itemId = $quote->getItemByProduct($product)->getId();
     $cartId = $quote->getId();
     /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
     $quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Quote\\Model\\QuoteIdMaskFactory')->create();
     $quoteIdMask->load($cartId, 'quote_id');
     //Use masked cart Id
     $cartId = $quoteIdMask->getMaskedId();
     $serviceInfo = ['rest' => ['resourcePath' => self::RESOURCE_PATH . $cartId . '/gift-message/' . $itemId, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST], 'soap' => ['service' => self::SERVICE_NAME, 'serviceVersion' => self::SERVICE_VERSION, 'operation' => self::SERVICE_NAME . 'Save']];
     $requestData = ['cartId' => $cartId, 'itemId' => $itemId, 'giftMessage' => ['recipient' => 'John Doe', 'sender' => 'Jane Roe', 'message' => 'Gift Message Text New']];
     $this->assertTrue($this->_webApiCall($serviceInfo, $requestData));
     //        $quote->load('test_order_item_with_message', 'reserved_order_id');
     $messageId = $quote->getItemByProduct($product)->getGiftMessageId();
     /** @var  \Magento\GiftMessage\Model\Message $message */
     $message = $this->objectManager->create('Magento\\GiftMessage\\Model\\Message')->load($messageId);
     $this->assertEquals('John Doe', $message->getRecipient());
     $this->assertEquals('Jane Roe', $message->getSender());
     $this->assertEquals('Gift Message Text New', $message->getMessage());
 }
コード例 #22
0
 /**
  * Set up
  */
 public function setUp()
 {
     $this->objectManager = Bootstrap::getObjectManager();
     $this->accountManagement = $this->objectManager->create('Magento\\Customer\\Api\\AccountManagementInterface');
     $this->securityManager = $this->objectManager->create('Magento\\Security\\Model\\SecurityManager');
     $this->passwordResetRequestEvent = $this->objectManager->get('Magento\\Security\\Model\\PasswordResetRequestEvent');
 }
コード例 #23
0
 /**
  * @magentoAppIsolation enabled
  * @covers \Magento\CatalogRule\Model\Rule::calcProductPriceRule
  */
 public function testCalcProductPriceRule()
 {
     $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product');
     $this->assertEquals($this->_object->calcProductPriceRule($product, 100), 45);
     $product->setParentId(true);
     $this->assertEquals($this->_object->calcProductPriceRule($product, 50), 5);
 }
コード例 #24
0
 protected function setUp()
 {
     /* Called getConfig as workaround for setConfig bug */
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore('default')->getConfig('dev/translate_inline/active');
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\Config\\MutableScopeConfigInterface')->setValue('dev/translate_inline/active', true, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 'default');
     parent::setUp();
 }
コード例 #25
0
 protected function setUp()
 {
     $this->_markTestAsRestOnly('Request Id overriding is a REST based feature.');
     $this->_version = 'V1';
     $this->_restResourcePath = "/{$this->_version}/TestModule5/";
     $this->itemFactory = Bootstrap::getObjectManager()->create('Magento\\TestModule5\\Service\\V1\\Entity\\AllSoapAndRestFactory');
 }
コード例 #26
0
ファイル: RowsTest.php プロジェクト: pradeep-wagento/magento2
 /**
  * @magentoDbIsolation disabled
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testProductUpdate()
 {
     $categoryFactory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\CategoryFactory');
     /** @var \Magento\Catalog\Block\Product\ListProduct $listProduct */
     $listProduct = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Block\\Product\\ListProduct');
     /** @var \Magento\Framework\Api\DataObjectHelper $dataObjectHelper */
     $dataObjectHelper = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('\\Magento\\Framework\\Api\\DataObjectHelper');
     /** @var \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry */
     $stockRegistry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\CatalogInventory\\Api\\StockRegistryInterface');
     /** @var \Magento\CatalogInventory\Api\StockItemRepositoryInterface $stockItemRepository */
     $stockItemRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\CatalogInventory\\Api\\StockItemRepositoryInterface');
     /** @var \Magento\CatalogInventory\Model\ResourceModel\Stock\Item $stockItemResource */
     $stockItemResource = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\CatalogInventory\\Model\\ResourceModel\\Stock\\Item');
     $stockItem = $stockRegistry->getStockItem(1, 1);
     $stockItemData = ['qty' => $stockItem->getQty() + 12];
     $dataObjectHelper->populateWithArray($stockItem, $stockItemData, '\\Magento\\CatalogInventory\\Api\\Data\\StockItemInterface');
     $stockItemResource->setProcessIndexEvents(false);
     $stockItemRepository->save($stockItem);
     $this->_processor->reindexList([1]);
     $category = $categoryFactory->create()->load(2);
     $layer = $listProduct->getLayer();
     $layer->setCurrentCategory($category);
     $productCollection = $layer->getProductCollection();
     $productCollection->joinField('qty', 'cataloginventory_stock_status', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left');
     $this->assertEquals(1, $productCollection->count());
     /** @var $product \Magento\Catalog\Model\Product */
     foreach ($productCollection as $product) {
         $this->assertEquals('Simple Product', $product->getName());
         $this->assertEquals('Short description', $product->getShortDescription());
         $this->assertEquals(112, $product->getQty());
     }
 }
コード例 #27
0
 /**
  * Ensure that fixture customer and his addresses are deleted.
  */
 protected function tearDown()
 {
     /** @var \Magento\Framework\Registry $registry */
     $registry = Bootstrap::getObjectManager()->get('Magento\\Framework\\Registry');
     $registry->unregister('isSecureArea');
     $registry->register('isSecureArea', true);
     try {
         $fixtureFirstAddressId = 1;
         $this->addressRepository->deleteById($fixtureFirstAddressId);
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         /** First address fixture was not used */
     }
     try {
         $fixtureSecondAddressId = 2;
         $this->addressRepository->deleteById($fixtureSecondAddressId);
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         /** Second address fixture was not used */
     }
     try {
         $fixtureCustomerId = 1;
         $this->customerRepository->deleteById($fixtureCustomerId);
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         /** Customer fixture was not used */
     }
     $registry->unregister('isSecureArea');
     $registry->register('isSecureArea', false);
     parent::tearDown();
 }
コード例 #28
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());
 }
コード例 #29
0
ファイル: SourceTest.php プロジェクト: aiesh/magento2
 /**
  *  Test reindex for configurable product with both disabled and enabled variations.
  */
 public function testReindexEntitiesForConfigurableProduct()
 {
     /** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attr **/
     $attr = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Eav\\Model\\Config')->getAttribute('catalog_product', 'test_configurable');
     $attr->setIsFilterable(1)->save();
     $this->_eavIndexerProcessor->reindexAll();
     /** @var \Magento\Eav\Model\Resource\Entity\Attribute\Option\Collection $options **/
     $options = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Eav\\Model\\Resource\\Entity\\Attribute\\Option\\Collection');
     $options->setAttributeFilter($attr->getId())->load();
     $optionIds = $options->getAllIds();
     $adapter = $this->productResource->getReadConnection();
     $select = $adapter->select()->from($this->productResource->getTable('catalog_product_index_eav'))->where('entity_id = ?', 1)->where('attribute_id = ?', $attr->getId())->where('value IN (?)', $optionIds);
     $result = $adapter->fetchAll($select);
     $this->assertCount(2, $result);
     /** @var \Magento\Catalog\Model\Product $product1 **/
     $product1 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\Product');
     $product1 = $product1->load(10);
     $product1->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED)->save();
     /** @var \Magento\Catalog\Model\Product $product2 **/
     $product2 = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Catalog\\Model\\Product');
     $product2 = $product2->load(20);
     $product2->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED)->save();
     $result = $adapter->fetchAll($select);
     $this->assertCount(0, $result);
 }
コード例 #30
0
 protected function setUp()
 {
     parent::setUp();
     $objectManager = Bootstrap::getObjectManager();
     $this->_customerRepository = $objectManager->create('Magento\\Customer\\Api\\CustomerRepositoryInterface');
     $customer = $this->_customerRepository->getById(self::FIXTURE_CUSTOMER_ID);
     $customerSession = $objectManager->get('Magento\\Customer\\Model\\Session');
     $customerSession->setCustomerData($customer);
     $this->_addressRepository = $objectManager->get('Magento\\Customer\\Api\\AddressRepositoryInterface');
     //fetch sample address
     $address = $this->_addressRepository->getById(self::FIXTURE_ADDRESS_ID);
     /** @var \Magento\Quote\Model\ResourceModel\Quote\Collection $quoteCollection */
     $quoteCollection = $objectManager->get('Magento\\Quote\\Model\\ResourceModel\\Quote\\Collection');
     /** @var $quote \Magento\Quote\Model\Quote */
     $quote = $quoteCollection->getLastItem();
     $quote->setCustomer($customer);
     /** @var $quoteAddressFactory \Magento\Quote\Model\Quote\AddressFactory */
     $this->_quoteAddressFactory = $objectManager->get('Magento\\Quote\\Model\\Quote\\AddressFactory');
     $billingAddress = $this->_quoteAddressFactory->create()->importCustomerAddressData($address);
     $quote->setBillingAddress($billingAddress);
     $quote->save();
     /** @var \Magento\Checkout\Model\Session $checkoutSession */
     $checkoutSession = $objectManager->get('Magento\\Checkout\\Model\\Session');
     $checkoutSession->setQuoteId($quote->getId());
     $checkoutSession->setLoadInactive(true);
     $objectManager->get('Magento\\Framework\\App\\Http\\Context')->setValue(Context::CONTEXT_AUTH, true, false);
     $this->_block = $objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Paypal\\Block\\Express\\Review\\Billing', '', ['customerSession' => $customerSession, 'resourceSession' => $checkoutSession]);
 }