/** * Retrieves customer log model * * @return \Magento\Customer\Model\Log */ protected function getCustomerLog() { if (!$this->customerLog) { $this->customerLog = $this->customerLogger->get($this->getCustomer()->getId()); } return $this->customerLog; }
/** * @param int $customerId * @param array $data * @dataProvider testGetDataProvider * @return void */ public function testGet($customerId, $data) { $logArguments = ['customerId' => $data['customer_id'], 'lastLoginAt' => $data['last_login_at'], 'lastLogoutAt' => $data['last_logout_at'], 'lastVisitAt' => $data['last_visit_at']]; $select = $this->getMock('Magento\\Framework\\DB\\Select', [], [], '', false); $select->expects($this->any())->method('from')->willReturnSelf(); $select->expects($this->any())->method('joinLeft')->willReturnSelf(); $select->expects($this->any())->method('where')->willReturnSelf(); $select->expects($this->any())->method('order')->willReturnSelf(); $select->expects($this->any())->method('limit')->willReturnSelf(); $this->adapter->expects($this->any())->method('select')->willReturn($select); $this->resource->expects($this->once())->method('getConnection')->with('read')->willReturn($this->adapter); $this->adapter->expects($this->any())->method('fetchRow')->with($select)->willReturn($data); $log = $this->getMock('Magento\\Customer\\Model\\Log', [], $logArguments); $this->logFactory->expects($this->any())->method('create')->with($logArguments)->willReturn($log); $this->assertEquals($log, $this->logger->get($customerId)); }