forked from magento/magento2
/
IndexTest.php
85 lines (76 loc) · 2.58 KB
/
IndexTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Contact\Test\Unit\Controller;
class IndexTest extends \PHPUnit_Framework_TestCase
{
/**
* Controller instance
*
* @var \Magento\Contact\Controller\Index
*/
protected $_controller;
/**
* Scope config instance
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $_scopeConfig;
protected function setUp()
{
$this->_scopeConfig = $this->getMockForAbstractClass(
\Magento\Framework\App\Config\ScopeConfigInterface::class,
['isSetFlag'],
'',
false
);
$context = $this->getMock(
\Magento\Framework\App\Action\Context::class,
['getRequest', 'getResponse'],
[],
'',
false
);
$context->expects($this->any())
->method('getRequest')
->will(
$this->returnValue(
$this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false)
)
);
$context->expects($this->any())
->method('getResponse')
->will(
$this->returnValue(
$this->getMockForAbstractClass(\Magento\Framework\App\ResponseInterface::class, [], '', false)
)
);
$this->_controller = new \Magento\Contact\Test\Unit\Controller\Stub\IndexStub(
$context,
$this->getMock(\Magento\Framework\Mail\Template\TransportBuilder::class, [], [], '', false),
$this->getMockForAbstractClass(\Magento\Framework\Translate\Inline\StateInterface::class, [], '', false),
$this->_scopeConfig,
$this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class, [], '', false)
);
}
/**
* Dispatch test
*
* @expectedException \Magento\Framework\Exception\NotFoundException
*/
public function testDispatch()
{
$this->_scopeConfig->expects($this->once())
->method('isSetFlag')
->with(
\Magento\Contact\Controller\Index::XML_PATH_ENABLED,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
->will($this->returnValue(false));
$this->_controller->dispatch(
$this->getMockForAbstractClass(\Magento\Framework\App\RequestInterface::class, [], '', false)
);
}
}