예제 #1
0
 /**
  * @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));
 }
예제 #2
0
 /**
  * Load log by Customer Id.
  *
  * @param int $customerId
  * @return Log
  */
 public function get($customerId = null)
 {
     $data = null !== $customerId ? $this->loadLogData($customerId) : [];
     return $this->logFactory->create(['customerId' => isset($data['customer_id']) ? $data['customer_id'] : null, 'lastLoginAt' => isset($data['last_login_at']) ? $data['last_login_at'] : null, 'lastLogoutAt' => isset($data['last_logout_at']) ? $data['last_logout_at'] : null, 'lastVisitAt' => isset($data['last_visit_at']) ? $data['last_visit_at'] : null]);
 }