Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IgnoreTaxNotificationTest.php
Go to the documentation of this file.
1 <?php
7 
10 
11 class IgnoreTaxNotificationTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testExecute()
14  {
15  $objectManager = new ObjectManager($this);
16  $cacheTypeList = $this->getMockBuilder(\Magento\Framework\App\Cache\TypeList::class)
17  ->disableOriginalConstructor()
18  ->setMethods(['cleanType'])
19  ->getMock();
20  $cacheTypeList->expects($this->once())
21  ->method('cleanType')
22  ->with('config')
23  ->willReturn(null);
24 
25  $request = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
26  ->disableOriginalConstructor()
27  ->setMethods(['getParam'])
28  ->getMock();
29  $request->expects($this->once())
30  ->method('getParam')
31  ->willReturn('tax');
32 
33  $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
34  ->disableOriginalConstructor()
35  ->getMock();
36  $resultRedirect->expects($this->once())
37  ->method('setRefererUrl')
38  ->willReturnSelf();
39 
40  $resultFactory = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
41  ->disableOriginalConstructor()
42  ->setMethods(['create'])
43  ->getMock();
44  $resultFactory->expects($this->once())
45  ->method('create')
46  ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
47  ->willReturn($resultRedirect);
48 
49  $config = $this->getMockBuilder(\Magento\Config\Model\ResourceModel\Config::class)
50  ->disableOriginalConstructor()
51  ->setMethods(['saveConfig'])
52  ->getMock();
53  $config->expects($this->once())
54  ->method('saveConfig')
55  ->with('tax/notification/ignore_tax', 1, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, 0)
56  ->willReturn(null);
57 
58  $manager = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
59  ->disableOriginalConstructor()
60  ->setMethods(['get', 'create', 'configure'])
61  ->getMock();
62  $manager->expects($this->any())
63  ->method('get')
64  ->willReturn($config);
65 
66  $notification = $objectManager->getObject(
67  \Magento\Tax\Controller\Adminhtml\Tax\IgnoreTaxNotification::class,
68  [
69  'objectManager' => $manager,
70  'cacheTypeList' => $cacheTypeList,
71  'request' => $request,
72  'resultFactory' => $resultFactory
73  ]
74  );
75 
76  // No exception thrown
77  $this->assertSame($resultRedirect, $notification->execute());
78  }
79 }
$objectManager
Definition: bootstrap.php:17
$config
Definition: fraud_order.php:17