52 $this->config = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Config::class)
53 ->disableOriginalConstructor()
54 ->setMethods([
'isNewRelicEnabled'])
56 $this->backendAuthSession = $this->getMockBuilder(\
Magento\Backend\Model\Auth\Session::class)
57 ->disableOriginalConstructor()
58 ->setMethods([
'isLoggedIn',
'getUser'])
60 $this->usersFactory = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\UsersFactory::class)
61 ->disableOriginalConstructor()
62 ->setMethods([
'create'])
64 $this->usersModel = $this->getMockBuilder(\
Magento\NewRelicReporting\Model\Users::class)
65 ->disableOriginalConstructor()
67 $this->jsonEncoder = $this->getMockBuilder(\
Magento\Framework\Json\EncoderInterface::class)
70 $this->usersFactory->expects($this->any())
72 ->willReturn($this->usersModel);
76 $this->backendAuthSession,
87 public function testReportConcurrentAdminsModuleDisabledFromConfig()
90 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
91 ->disableOriginalConstructor()
94 $this->config->expects($this->once())
95 ->method(
'isNewRelicEnabled')
98 $this->model->execute($eventObserver);
106 public function testReportConcurrentAdminsUserIsNotLoggedIn()
109 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
110 ->disableOriginalConstructor()
113 $this->config->expects($this->once())
114 ->method(
'isNewRelicEnabled')
116 $this->backendAuthSession->expects($this->once())
117 ->method(
'isLoggedIn')
120 $this->model->execute($eventObserver);
128 public function testReportConcurrentAdmins()
130 $testAction =
'JSON string';
133 $eventObserver = $this->getMockBuilder(\
Magento\Framework\Event\Observer::class)
134 ->disableOriginalConstructor()
137 $this->config->expects($this->once())
138 ->method(
'isNewRelicEnabled')
140 $this->backendAuthSession->expects($this->once())
141 ->method(
'isLoggedIn')
143 $userMock = $this->getMockBuilder(\
Magento\User\Model\User::class)->disableOriginalConstructor()->getMock();
144 $this->backendAuthSession->expects($this->once())
146 ->willReturn($userMock);
147 $this->jsonEncoder->expects($this->once())
149 ->willReturn($testAction);
150 $this->usersModel->expects($this->once())
152 ->with([
'type' =>
'admin_activity',
'action' => $testAction])
154 $this->usersModel->expects($this->once())
157 $this->model->execute($eventObserver);