/**
  * @magentoDataFixture Magento/Catalog/_files/products_crosssell.php
  */
 public function testAddLinkAttributeToFilterNoResults()
 {
     $om = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $link = $om->get('Magento\\Catalog\\Model\\Product\\Link')->useCrossSellLinks();
     $this->collection->setLinkModel($link);
     $this->collection->addLinkAttributeToFilter('position', ['from' => 2, 'to' => 3]);
     $product = $om->get('Magento\\Catalog\\Model\\Product')->load(2);
     $this->collection->setProduct($product);
     $this->collection->load();
     $this->assertCount(0, $this->collection->getItems());
 }
Example #2
0
 /**
  * @magentoDataFixture Magento/Catalog/_files/products.php
  * @magentoAppIsolation enabled
  */
 public function testAddPriceDataOnSave()
 {
     $this->processor->getIndexer()->setScheduled(false);
     $this->assertFalse($this->processor->getIndexer()->isScheduled());
     $productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Api\\ProductRepositoryInterface');
     /** @var \Magento\Catalog\Api\Data\ProductInterface $product */
     $product = $productRepository->get('simple');
     $this->assertNotEquals(15, $product->getPrice());
     $product->setPrice(15);
     $productRepository->save($product);
     $this->collection->addPriceData(0, 1);
     $this->collection->load();
     /** @var \Magento\Catalog\Api\Data\ProductInterface[] $product */
     $items = $this->collection->getItems();
     /** @var \Magento\Catalog\Api\Data\ProductInterface $product */
     $product = reset($items);
     $this->assertCount(2, $items);
     $this->assertEquals(15, $product->getPrice());
 }