Ejemplo n.º 1
0
 protected function setUp()
 {
     $this->registry = $this->getMock('Magento\\Framework\\Registry');
     $this->session = $this->getMockBuilder('Magento\\Customer\\Model\\Session')->disableOriginalConstructor()->setMethods(['getSessionId', 'getVisitorData', 'setVisitorData'])->getMock();
     $this->objectManagerHelper = new ObjectManagerHelper($this);
     $this->resource = $this->getMockBuilder('Magento\\Customer\\Model\\Resource\\Visitor')->setMethods(['beginTransaction', '__sleep', '__wakeup', 'getIdFieldName', 'save', 'addCommitCallback', 'commit'])->disableOriginalConstructor()->getMock();
     $this->resource->expects($this->any())->method('getIdFieldName')->will($this->returnValue('visitor_id'));
     $this->resource->expects($this->any())->method('addCommitCallback')->will($this->returnSelf());
     $arguments = $this->objectManagerHelper->getConstructArguments('Magento\\Customer\\Model\\Visitor', ['registry' => $this->registry, 'session' => $this->session, 'resource' => $this->resource]);
     $this->visitor = $this->objectManagerHelper->getObject('Magento\\Customer\\Model\\Visitor', $arguments);
 }
Ejemplo n.º 2
0
 public function testLogVisitorActivity()
 {
     $visitor = $this->getMockBuilder('Magento\\Customer\\Model\\Visitor')->disableOriginalConstructor()->getMock();
     $visitor->expects($this->once())->method('setData')->will($this->returnSelf());
     $visitor->expects($this->once())->method('getData')->will($this->returnValue(['visitor_id' => 1]));
     $this->resource->expects($this->once())->method('save')->will($this->returnSelf());
     $this->resource->expects($this->never())->method('beginTransaction');
     $event = new \Magento\Framework\Object(['visitor' => $visitor]);
     $observer = new \Magento\Framework\Object(['event' => $event]);
     $this->assertSame($this->visitor, $this->visitor->logVisitorActivity($observer));
 }
Ejemplo n.º 3
0
 public function testClean()
 {
     $this->resource->expects($this->once())->method('clean')->with($this->visitor)->will($this->returnSelf());
     $this->visitor->clean();
 }