/** * Test getting orders associated with specified billing agreement. * * Create two identical orders, associate one of them with billing agreement and invoke testGetRelatedOrders() * * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Paypal/_files/billing_agreement.php * @magentoDataFixture Magento/Sales/_files/order.php * @magentoDbIsolation enabled * @magentoAppIsolation enabled */ public function testGetRelatedOrders() { /** Customer ID declared in the fixture */ $customerId = 1; /** Assign first order to the active customer */ /** @var \Magento\Sales\Model\Order $orderA */ $orderA = Bootstrap::getObjectManager()->create('Magento\\Sales\\Model\\Order'); $orderA->loadByIncrementId('100000001'); $orderA->setCustomerIsGuest(false)->setCustomerId($customerId)->save(); /** @var \Magento\Customer\Model\Session $customerSession */ $customerSession = Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Session'); $customerSession->setCustomerId($customerId); /** Assign second order to the active customer */ $orderB = clone $orderA; $orderB->setId(null)->setIncrementId('100000002')->setCustomerIsGuest(false)->setCustomerId($customerId)->save(); /** @var \Magento\Customer\Model\Session $customerSession */ $customerSession = Bootstrap::getObjectManager()->create('Magento\\Customer\\Model\\Session'); $customerSession->setCustomerId($customerId); /** @var \Magento\Paypal\Model\ResourceModel\Billing\Agreement\Collection $billingAgreementCollection */ $billingAgreementCollection = Bootstrap::getObjectManager()->create('Magento\\Paypal\\Model\\ResourceModel\\Billing\\Agreement\\Collection'); /** @var \Magento\Paypal\Model\Billing\Agreement $billingAgreement */ $billingAgreement = $billingAgreementCollection->getFirstItem(); $billingAgreement->addOrderRelation($orderA->getId())->save(); $registry = Bootstrap::getObjectManager()->get('Magento\\Framework\\Registry'); $registry->register('current_billing_agreement', $billingAgreement); $relatedOrders = $this->_block->getRelatedOrders(); $this->assertEquals(1, $relatedOrders->count(), "Only one order must be returned."); $this->assertEquals($orderA->getId(), $relatedOrders->getFirstItem()->getId(), "Invalid order returned as associated with billing agreement."); }
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'); }
/** * {@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); }
/** * @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()); }
/** * @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()); } }
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]); }
/** * @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()); }
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'); }
/** * @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); }
/** * @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()); }
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); }
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]); }
/** * 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'); }
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'); }
/** * {@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'); }
/** * 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'); }
/** * @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'); }
/** * 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()); }
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'); }
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'); }
/** * @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()); }
/** * 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'); }
/** * @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); }
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(); }
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'); }
/** * @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()); } }
/** * 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(); }
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]); }
/** * 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); }
public function setUp() { $directoryList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\App\\Filesystem\\DirectoryList', ['root' => DirectoryList::ROOT]); $filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Filesystem', ['directoryList' => $directoryList]); $this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_model = $this->_objectManager->create('Magento\\Persistent\\Model\\Persistent\\Config', ['filesystem' => $filesystem]); }