Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IndexTest.php
Go to the documentation of this file.
1 <?php
8 
12 
13 class IndexTest extends \PHPUnit\Framework\TestCase
14 {
20  private $controller;
21 
27  private $configMock;
28 
29  protected function setUp()
30  {
31  $this->configMock = $this->getMockBuilder(ConfigInterface::class)->getMockForAbstractClass();
32 
33  $context = $this->getMockBuilder(
34  \Magento\Framework\App\Action\Context::class
35  )->setMethods(
36  ['getRequest', 'getResponse']
37  )->disableOriginalConstructor(
38  )->getMock();
39 
40  $context->expects($this->any())
41  ->method('getRequest')
42  ->will(
43  $this->returnValue(
44  $this->getMockBuilder(RequestInterface::class)->getMockForAbstractClass()
45  )
46  );
47 
48  $context->expects($this->any())
49  ->method('getResponse')
50  ->will(
51  $this->returnValue(
52  $this->getMockBuilder(ResponseInterface::class)->getMockForAbstractClass()
53  )
54  );
55 
56  $this->controller = new \Magento\Contact\Test\Unit\Controller\Stub\IndexStub(
57  $context,
58  $this->configMock
59  );
60  }
61 
67  public function testDispatch()
68  {
69  $this->configMock->method('isEnabled')->willReturn(false);
70 
71  $this->controller->dispatch(
72  $this->getMockBuilder(RequestInterface::class)->getMockForAbstractClass()
73  );
74  }
75 }