abae0498d8f2a608c7365bbb67baa1edc54d3e92
[yaffs-website] / GeneratorPluginRulesActionCommandTest.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\Console\Test\Command\GeneratorPluginRulesActionCommandTest.
5  */
6
7 namespace Drupal\Console\Test\Command;
8
9 use Drupal\Console\Command\Generate\PluginRulesActionCommand;
10 use Symfony\Component\Console\Tester\CommandTester;
11 use Drupal\Console\Test\DataProvider\PluginRulesActionDataProviderTrait;
12
13 class GeneratorPluginRulesActionCommandTest extends GenerateCommandTest
14 {
15     use PluginRulesActionDataProviderTrait;
16
17     /**
18      * Plugin rules action generator test
19      *
20      * @param $module
21      * @param $class_name
22      * @param $label
23      * @param $plugin_id
24      * @param $category
25      * @param $context
26      * @param $type
27      *
28      * @dataProvider commandData
29      */
30     public function testGeneratePluginRulesAction(
31         $module,
32         $class_name,
33         $label,
34         $plugin_id,
35         $category,
36         $context,
37         $type
38     ) {
39         $command = new PluginRulesActionCommand($this->getHelperSet());
40         $command->setHelperSet($this->getHelperSet());
41         $command->setGenerator($this->getGenerator());
42
43         $commandTester = new CommandTester($command);
44
45         $code = $commandTester->execute(
46             [
47               '--module'        => $module,
48               '--class'    => $class_name,
49               '--label'         => $label,
50               '--plugin-id'     => $plugin_id,
51               '--category'      => $category,
52               '--context'       => $context,
53               '--type'          => $type
54             ],
55             ['interactive' => false]
56         );
57
58         $this->assertEquals(0, $code);
59     }
60
61     private function getGenerator()
62     {
63         return $this
64             ->getMockBuilder('Drupal\Console\Generator\PluginRulesActionGenerator')
65             ->disableOriginalConstructor()
66             ->setMethods(['generate'])
67             ->getMock();
68     }
69 }