示例#1
0
 /**
  * @return void
  */
 public function testAfterClean()
 {
     $this->eventMock->expects($this->once())->method('clean');
     $this->comparedMock->expects($this->once())->method('clean');
     $this->viewedMock->expects($this->once())->method('clean');
     $this->assertEquals($this->logResourceMock, $this->log->afterClean($this->subjectMock, $this->logResourceMock));
 }
示例#2
0
 /**
  * Clean events by old visitors after plugin for clean method
  *
  * @param \Magento\Customer\Model\ResourceModel\Visitor $subject
  * @param \Magento\Customer\Model\ResourceModel\Visitor $logResourceModel
  *
  * @return \Magento\Customer\Model\ResourceModel\Visitor
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  *
  * @see Global Log Clean Settings
  */
 public function afterClean(\Magento\Customer\Model\ResourceModel\Visitor $subject, $logResourceModel)
 {
     $this->_reportEvent->clean();
     $this->_comparedProductIdx->clean();
     $this->_viewedProductIdx->clean();
     return $logResourceModel;
 }
 /**
  * @return void
  */
 public function testCustomerLogout()
 {
     $observerMock = $this->getObserverMock(111);
     $this->productCompModelMock->expects($this->once())->method('purgeVisitorByCustomer')->willReturnSelf();
     $this->productCompModelMock->expects($this->once())->method('calculate')->willReturnSelf();
     $this->productIndexMock->expects($this->once())->method('purgeVisitorByCustomer')->willReturnSelf();
     $this->productIndexMock->expects($this->once())->method('calculate')->willReturnSelf();
     $this->observer->execute($observerMock);
 }
 /**
  * @param bool $isLoggedIn
  * @param string $userKey
  * @param int $userId
  * @dataProvider catalogProductCompareAddProductDataProvider
  * @return void
  */
 public function testCatalogProductCompareAddProduct($isLoggedIn, $userKey, $userId)
 {
     $productId = 111;
     $customerId = 222;
     $visitorId = 333;
     $viewData = ['product_id' => $productId, $userKey => $userId];
     $observerMock = $this->getObserverMock($productId);
     $this->customerSessionMock->expects($this->any())->method('isLoggedIn')->willReturn($isLoggedIn);
     $this->customerSessionMock->expects($this->any())->method('getCustomerId')->willReturn($customerId);
     $this->customerVisitorMock->expects($this->any())->method('getId')->willReturn($visitorId);
     $this->productCompModelMock->expects($this->any())->method('setData')->with($viewData)->willReturnSelf();
     $this->productCompModelMock->expects($this->any())->method('save')->willReturnSelf();
     $this->productCompModelMock->expects($this->any())->method('calculate')->willReturnSelf();
     $this->eventSaverMock->expects($this->once())->method('save');
     $this->observer->execute($observerMock);
 }
示例#5
0
 /**
  * @return void
  */
 public function testGetExcludeProductIds()
 {
     $collection = $this->getMockBuilder('Magento\\Catalog\\Model\\ResourceModel\\Product\\Compare\\Item\\Collection')->disableOriginalConstructor()->setMethods(['getEntityId'])->getMock();
     $collection->expects($this->once())->method('getEntityId')->willReturn(1);
     $product = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->setMethods(['getId'])->getMock();
     $product->expects($this->once())->method('getId')->willReturn(2);
     $this->catalogProductHelperMock->expects($this->once())->method('hasItems')->willReturn(true);
     $this->catalogProductHelperMock->expects($this->once())->method('getItemCollection')->willReturn([$collection]);
     $this->registryMock->expects($this->any())->method('registry')->willReturn($product);
     $this->assertEquals([1, 2], $this->compared->getExcludeProductIds());
 }
 /**
  * @return void
  */
 public function testCustomerLoginLoggedInFalse()
 {
     $observerMock = $this->getObserverMock(111);
     $this->customerSessionMock->expects($this->once())->method('isLoggedIn')->willReturn(false);
     $this->customerSessionMock->expects($this->never())->method('getCustomerId');
     $this->customerVisitorMock->expects($this->never())->method('getId');
     $this->productCompModelMock->expects($this->never())->method('updateCustomerFromVisitor')->willReturnSelf();
     $this->productCompModelMock->expects($this->never())->method('calculate')->willReturnSelf();
     $this->productIndexMock->expects($this->never())->method('updateCustomerFromVisitor')->willReturnSelf();
     $this->productIndexMock->expects($this->never())->method('calculate')->willReturnSelf();
     $this->observer->execute($observerMock);
 }