Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LogLastLogoutAtObserverTest.php
Go to the documentation of this file.
1 <?php
7 
12 
16 class LogLastLogoutAtObserverTest extends \PHPUnit\Framework\TestCase
17 {
22 
26  protected $loggerMock;
27 
31  protected function setUp()
32  {
33  $this->loggerMock = $this->createMock(\Magento\Customer\Model\Logger::class);
34  $this->logLastLogoutAtObserver = new LogLastLogoutAtObserver($this->loggerMock);
35  }
36 
40  public function testLogLastLogoutAt()
41  {
42  $id = 1;
43 
44  $observerMock = $this->createMock(\Magento\Framework\Event\Observer::class);
45  $eventMock = $this->createPartialMock(\Magento\Framework\Event::class, ['getCustomer']);
46  $customerMock = $this->createMock(\Magento\Customer\Model\Customer::class);
47 
48  $observerMock->expects($this->once())
49  ->method('getEvent')
50  ->willReturn($eventMock);
51  $eventMock->expects($this->once())
52  ->method('getCustomer')
53  ->willReturn($customerMock);
54  $customerMock->expects($this->once())
55  ->method('getId')
56  ->willReturn($id);
57 
58  $this->loggerMock->expects($this->once())
59  ->method('log');
60 
61  $this->logLastLogoutAtObserver->execute($observerMock);
62  }
63 }
$id
Definition: fieldset.phtml:14