Beispiel #1
0
 /**
  * @magentoDataFixture Magento/Customer/_files/customer.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  * @magentoAppIsolation enabled
  * @magentoDbIsolation enabled
  */
 public function testGetCustomerWishlist()
 {
     $customerIdFromFixture = 1;
     $productIdFromFixture = 1;
     /** @var \Magento\Backend\Model\Session\Quote $session */
     $session = Bootstrap::getObjectManager()->create('Magento\\Backend\\Model\\Session\\Quote');
     $session->setCustomerId($customerIdFromFixture);
     /** Test new wishlist creation for the customer specified above */
     /** @var \Magento\Wishlist\Model\Wishlist $wishlist */
     $wishlist = $this->_model->getCustomerWishlist(true);
     $this->assertInstanceOf('Magento\\Wishlist\\Model\\Wishlist', $wishlist, 'New Wish List is expected to be created if existing Customer does not have one yet.');
     $this->assertEquals(0, $wishlist->getItemsCount(), 'New Wish List must be empty just after creation.');
     /** Add new item to wishlist and try to get it using getCustomerWishlist once again */
     $wishlist->addNewItem($productIdFromFixture)->save();
     $updatedWishlist = $this->_model->getCustomerWishlist(true);
     $this->assertEquals(1, $updatedWishlist->getItemsCount(), 'Wish List must contain a Product which was added to it earlier.');
     /** Try to load wishlist from cache in the class after it is deleted from DB */
     $wishlist->delete();
     $this->assertSame($updatedWishlist, $this->_model->getCustomerWishlist(false), 'Wish List cached in class variable is expected to be returned.');
     $this->assertNotSame($updatedWishlist, $this->_model->getCustomerWishlist(true), 'New Wish List is expected to be created when cache is forced to be refreshed.');
 }