10 public function testAroundDispatch()
13 $subject = $this->createMock(\
Magento\Backend\
App\AbstractAction::class);
24 $request->expects($this->atLeastOnce())->method(
'getControllerName')->will($this->returnValue(
'feed'));
25 $request->expects($this->atLeastOnce())->method(
'getActionName')->will($this->returnValue(
'index'));
26 $request->expects($this->once())->method(
'getParam')->with(
'type')->will($this->returnValue(
'notifystock'));
29 $session = $this->createMock(\
Magento\Backend\Model\Auth\StorageInterface::class);
30 $session->expects($this->at(0))->method(
'isLoggedIn')->will($this->returnValue(
false));
31 $session->expects($this->at(1))->method(
'isLoggedIn')->will($this->returnValue(
true));
34 $password =
'123123qa';
35 $auth = $this->createMock(\
Magento\Backend\Model\Auth::class);
36 $auth->expects($this->once())->method(
'getAuthStorage')->will($this->returnValue(
$session));
37 $auth->expects($this->once())->method(
'login')->with($username, $password);
40 $httpAuthentication = $this->createMock(\
Magento\Framework\HTTP\Authentication::class);
41 $httpAuthentication->expects($this->once())->method(
'getCredentials')
42 ->will($this->returnValue([$username, $password]));
43 $httpAuthentication->expects($this->once())->method(
'setAuthenticationFailed')->with(
'RSS Feeds');
45 $authorization = $this->createMock(\
Magento\Framework\AuthorizationInterface::class);
46 $authorization->expects($this->at(0))->method(
'isAllowed')->with(
'Magento_Rss::rss')
47 ->will($this->returnValue(
true));
48 $authorization->expects($this->at(1))->method(
'isAllowed')->with(
'Magento_Catalog::catalog_inventory')
49 ->will($this->returnValue(
false));
52 'feed' =>
'Magento_Rss::rss',
53 'notifystock' =>
'Magento_Catalog::catalog_inventory',
54 'new_order' =>
'Magento_Sales::actions_view',
55 'review' =>
'Magento_Reports::review_product' 59 $plugin = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
61 \
Magento\Rss\
App\Action\Plugin\BackendAuthentication::class,
64 'httpAuthentication' => $httpAuthentication,
66 'authorization' => $authorization,
67 'aclResources' => $aclResources
72 $plugin->aroundDispatch($subject, $proceed,
$request)