5
5
*/
6
6
namespace Magento \Indexer \Test \Unit \Console \Command ;
7
7
8
+ use Magento \Backend \App \Area \FrontNameResolver ;
8
9
use Magento \Indexer \Console \Command \IndexerSetModeCommand ;
9
10
use Symfony \Component \Console \Tester \CommandTester ;
10
11
@@ -22,7 +23,7 @@ class IndexerSetModeCommandTest extends IndexerCommandCommonTestSetup
22
23
23
24
public function testGetOptions ()
24
25
{
25
- $ this ->stateMock ->expects ($ this ->never ())->method ('setAreaCode ' )->with (' adminmhtml ' );
26
+ $ this ->stateMock ->expects ($ this ->never ())->method ('setAreaCode ' )->with (FrontNameResolver:: AREA_CODE );
26
27
$ this ->command = new IndexerSetModeCommand ($ this ->objectManagerFactory );
27
28
$ optionsList = $ this ->command ->getInputList ();
28
29
$ this ->assertSame (3 , sizeof ($ optionsList ));
@@ -37,7 +38,7 @@ public function testGetOptions()
37
38
*/
38
39
public function testExecuteInvalidArgument ()
39
40
{
40
- $ this ->stateMock ->expects ($ this ->never ())->method ('setAreaCode ' )->with (' adminmhtml ' );
41
+ $ this ->stateMock ->expects ($ this ->never ())->method ('setAreaCode ' )->with (FrontNameResolver:: AREA_CODE );
41
42
$ this ->command = new IndexerSetModeCommand ($ this ->objectManagerFactory );
42
43
$ commandTester = new CommandTester ($ this ->command );
43
44
$ commandTester ->execute ([]);
@@ -49,15 +50,15 @@ public function testExecuteInvalidArgument()
49
50
*/
50
51
public function testExecuteInvalidMode ()
51
52
{
52
- $ this ->stateMock ->expects ($ this ->never ())->method ('setAreaCode ' )->with (' adminmhtml ' );
53
+ $ this ->stateMock ->expects ($ this ->never ())->method ('setAreaCode ' )->with (FrontNameResolver:: AREA_CODE );
53
54
$ this ->command = new IndexerSetModeCommand ($ this ->objectManagerFactory );
54
55
$ commandTester = new CommandTester ($ this ->command );
55
56
$ commandTester ->execute (['mode ' => 'wrong_mode ' ]);
56
57
}
57
58
58
59
public function testExecuteAll ()
59
60
{
60
- $ this ->stateMock -> expects ( $ this -> once ())-> method ( ' setAreaCode ' )-> with ( ' adminmhtml ' );
61
+ $ this ->configureAdminArea ( );
61
62
$ collection = $ this ->getMock ('Magento\Indexer\Model\Indexer\Collection ' , [], [], '' , false );
62
63
$ indexerOne = $ this ->getMock ('Magento\Indexer\Model\Indexer ' , [], [], '' , false );
63
64
@@ -91,7 +92,7 @@ public function testExecuteAll()
91
92
*/
92
93
public function testExecuteWithIndex ($ isScheduled , $ previous , $ current , $ mode , $ expectedValue )
93
94
{
94
- $ this ->stateMock -> expects ( $ this -> once ())-> method ( ' setAreaCode ' )-> with ( ' adminmhtml ' );
95
+ $ this ->configureAdminArea ( );
95
96
$ indexerOne = $ this ->getMock ('Magento\Indexer\Model\Indexer ' , [], [], '' , false );
96
97
$ indexerOne ->expects ($ this ->once ())->method ('getTitle ' )->willReturn ('Title_indexerOne ' );
97
98
$ indexerOne ->expects ($ this ->once ())->method ('load ' )->with ('id_indexerOne ' )->willReturn ($ indexerOne );
@@ -152,7 +153,7 @@ public function executeWithIndexDataProvider()
152
153
153
154
public function testExecuteWithLocalizedException ()
154
155
{
155
- $ this ->stateMock -> expects ( $ this -> once ())-> method ( ' setAreaCode ' )-> with ( ' adminmhtml ' );
156
+ $ this ->configureAdminArea ( );
156
157
$ indexerOne = $ this ->getMock ('Magento\Indexer\Model\Indexer ' , [], [], '' , false );
157
158
$ localizedException = new \Magento \Framework \Exception \LocalizedException (__ ('Some Exception Message ' ));
158
159
$ indexerOne ->expects ($ this ->once ())->method ('setScheduled ' )->will ($ this ->throwException ($ localizedException ));
@@ -167,7 +168,7 @@ public function testExecuteWithLocalizedException()
167
168
168
169
public function testExecuteWithException ()
169
170
{
170
- $ this ->stateMock -> expects ( $ this -> once ())-> method ( ' setAreaCode ' )-> with ( ' adminmhtml ' );
171
+ $ this ->configureAdminArea ( );
171
172
$ indexerOne = $ this ->getMock ('Magento\Indexer\Model\Indexer ' , [], [], '' , false );
172
173
$ exception = new \Exception ();
173
174
$ indexerOne ->expects ($ this ->once ())->method ('setScheduled ' )->will ($ this ->throwException ($ exception ));
0 commit comments