Example #1
0
 /**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
  * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testReindexFull()
 {
     $this->prepareProducts();
     $this->indexerBuilder->reindexFull();
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, $this->product->getId()));
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, $this->productSecond->getId()));
     $this->assertFalse($this->resourceRule->getRulePrice(new \DateTime(), 1, 1, $this->productThird->getId()));
 }
 /**
  * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
  * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  * @magentoAppArea adminhtml
  */
 public function testReindexAfterSuitableProductSaving()
 {
     /** @var \Magento\Catalog\Model\ProductRepository $productRepository */
     $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\ProductRepository');
     $product = $productRepository->get('simple');
     $product->setData('test_attribute', 'test_attribute_value')->save();
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, $product->getId()));
 }
 /**
  * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testReindexAfterRuleCreation()
 {
     $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save();
     $this->assertFalse($this->resourceRule->getRulePrice(new \DateTime(), 1, 1, 1));
     $this->saveRule();
     // apply all rules
     $this->indexBuilder->reindexFull();
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, 1));
 }
 /**
  * @magentoDbIsolation enabled
  * @dataProvider dataProvider
  */
 public function testPriceForSmallBatch($batchCount, $price, $expectedPrice)
 {
     $productIds = $this->prepareProducts($price);
     /**
      * @var IndexBuilder $indexerBuilder
      */
     $indexerBuilder = Bootstrap::getObjectManager()->create('Magento\\CatalogRule\\Model\\Indexer\\IndexBuilder', ['batchCount' => $batchCount]);
     $indexerBuilder->reindexFull();
     foreach ([0, 1] as $customerGroupId) {
         foreach ($productIds as $productId) {
             $this->assertEquals($expectedPrice, $this->resourceRule->getRulePrice(new \DateTime(), 1, $customerGroupId, $productId));
         }
     }
 }
 /**
  * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
  * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  * @magentoAppArea adminhtml
  */
 public function testReindexAfterSuitableProductSaving()
 {
     $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save();
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, 1));
 }