/** * @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->assertEquals($this->observer, $this->observer->customerLogout($observerMock)); }
/** * @param bool $isLoggedIn * @param string $userKey * @param int $userId * @dataProvider catalogProductCompareAddProductDataProvider */ 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->productCompFactoryMock->expects($this->any())->method('create')->willReturn($this->productCompModelMock); $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->assertEquals($this->observer, $this->observer->catalogProductCompareAddProduct($observerMock)); }