Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ActivityTest.php
Go to the documentation of this file.
1 <?php
8 
12 
18 class ActivityTest extends \PHPUnit\Framework\TestCase
19 {
23  protected $controller;
24 
28  protected $contextMock;
29 
33  protected $viewMock;
34 
38  protected $objectManager;
39 
44  public function setUp()
45  {
46  $this->objectManager = new ObjectManager($this);
47  $this->contextMock = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class)
48  ->disableOriginalConstructor()
49  ->getMock();
50  $this->viewMock = $this->createMock(\Magento\Framework\App\ViewInterface::class);
51  $this->contextMock->expects($this->any())
52  ->method('getView')
53  ->will($this->returnValue($this->viewMock));
54 
55  $this->controller = $this->objectManager->getObject(
56  \Magento\Security\Controller\Adminhtml\Session\Activity::class,
57  [
58  'context' => $this->contextMock
59  ]
60  );
61  }
62 
66  public function testExecute()
67  {
68  $titleMock = $this->getMockBuilder(\Magento\Framework\View\Page\Title::class)
69  ->disableOriginalConstructor()
70  ->getMock();
71  $titleMock
72  ->expects($this->once())
73  ->method('prepend')
74  ->with(new Phrase('Account Activity'));
75  $this->viewMock
76  ->expects($this->any())
77  ->method('getPage')
78  ->willReturn(
79  new DataObject(
80  ['config' => new DataObject(
81  ['title' => $titleMock]
82  )]
83  )
84  );
85  $this->controller->execute();
86  }
87 }