7
7
8
8
use Magento \Setup \Model \Cron \JobSetCache ;
9
9
use Symfony \Component \Console \Input \ArrayInput ;
10
+ use Symfony \Component \Console \Input \InputDefinition ;
11
+ use Symfony \Component \Console \Input \InputArgument ;
10
12
11
13
class JobSetCacheTest extends \PHPUnit_Framework_TestCase
12
14
{
@@ -15,8 +17,9 @@ class JobSetCacheTest extends \PHPUnit_Framework_TestCase
15
17
* @param string $commandClass
16
18
* @param string $commandName
17
19
* @param string $jobName
20
+ * @param array $params
18
21
*/
19
- public function testSetCache ($ commandClass , $ commandName , $ jobName )
22
+ public function testSetCache ($ commandClass , $ commandName , $ jobName, $ params )
20
23
{
21
24
$ objectManagerProvider = $ this ->getMock ('Magento\Setup\Model\ObjectManagerProvider ' , [], [], '' , false );
22
25
$ objectManager = $ this ->getMockForAbstractClass ('Magento\Framework\ObjectManagerInterface ' , [], '' , false );
@@ -32,12 +35,17 @@ public function testSetCache($commandClass, $commandName, $jobName)
32
35
$ output = $ this ->getMockForAbstractClass ('Symfony\Component\Console\Output\OutputInterface ' , [], '' , false );
33
36
$ status = $ this ->getMock ('Magento\Setup\Model\Cron\Status ' , [], [], '' , false );
34
37
$ command = $ this ->getMock ($ commandClass , [], [], '' , false );
35
- $ command ->expects ($ this ->once ())->method ('getName ' )->willReturn ($ commandName );
36
38
$ command ->expects ($ this ->once ())
37
39
->method ('run ' )
38
- ->with (new ArrayInput (['command ' => $ commandName ]), $ output );
40
+ ->with (new ArrayInput (['command ' => $ commandName, ' types ' => $ params ]), $ output );
39
41
40
- $ model = new JobSetCache ($ command , $ objectManagerProvider , $ output , $ status , $ jobName , []);
42
+ $ definition = new InputDefinition ([
43
+ new InputArgument ('types ' , InputArgument::REQUIRED ),
44
+ new InputArgument ('command ' , InputArgument::REQUIRED ),
45
+ ]);
46
+ $ command ->expects ($ this ->any ())->method ('setDefinition ' )->with ($ definition );
47
+
48
+ $ model = new JobSetCache ($ command , $ objectManagerProvider , $ output , $ status , $ jobName , $ params );
41
49
$ model ->execute ();
42
50
}
43
51
@@ -47,8 +55,8 @@ public function testSetCache($commandClass, $commandName, $jobName)
47
55
public function setCacheDataProvider ()
48
56
{
49
57
return [
50
- ['Magento\Backend\Console\Command\CacheEnableCommand ' , 'cache:enable ' , 'setup:cache:enable ' ],
51
- ['Magento\Backend\Console\Command\CacheDisableCommand ' , 'cache:disable ' , 'setup:cache:disable ' ],
58
+ ['Magento\Backend\Console\Command\CacheEnableCommand ' , 'cache:enable ' , 'setup:cache:enable ' , [ ' cache1 ' ] ],
59
+ ['Magento\Backend\Console\Command\CacheDisableCommand ' , 'cache:disable ' , 'setup:cache:disable ' , [] ],
52
60
];
53
61
}
54
62
}
0 commit comments