Version 1
[yaffs-website] / vendor / drupal / console / Test / Command / GeneratorPluginConditionCommandTest.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\Console\Test\Command\GeneratorPluginConditionCommandTest.
5  */
6
7 namespace Drupal\Console\Test\Command;
8
9 use Drupal\Console\Command\Generate\PluginConditionCommand;
10 use Symfony\Component\Console\Tester\CommandTester;
11 use Drupal\Console\Test\DataProvider\PluginConditionDataProviderTrait;
12
13 class GeneratorPluginConditionCommandTest extends GenerateCommandTest
14 {
15     use PluginConditionDataProviderTrait;
16     
17     /**
18      * Plugin block generator test
19      *
20      * @param $module
21      * @param $class_name
22      * @param $label
23      * @param $plugin_id
24      * @param $context_definition_id
25      * @param $context_definition_label
26      * @param $context_definition_required
27      *
28      * @dataProvider commandData
29      */
30     public function testGeneratePluginCondition(
31         $module,
32         $class_name,
33         $label,
34         $plugin_id,
35         $context_definition_id,
36         $context_definition_label,
37         $context_definition_required
38     ) {
39         $command = new PluginConditionCommand($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               '--context-definition-id'       => $context_definition_id,
52               '--context-definition-label'    => $context_definition_label,
53               '--context-definition-required' => $context_definition_required
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\PluginConditionGenerator')
65             ->disableOriginalConstructor()
66             ->setMethods(['generate'])
67             ->getMock();
68     }
69 }