961988d130907d7c7e512d5b083b336b19fe042d
[yaffs-website] / vendor / drupal / console / Test / Command / GeneratorPluginTypeAnnotationCommandTest.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\Console\Test\Command\GeneratorPluginTypeAnnotationCommandTest.
5  */
6
7 namespace Drupal\Console\Test\Command;
8
9 use Drupal\Console\Command\Generate\PluginTypeAnnotationCommand;
10 use Symfony\Component\Console\Tester\CommandTester;
11 use Drupal\Console\Test\DataProvider\PluginTypeYamlDataProviderTrait;
12
13 class GeneratorPluginTypeAnnotationCommandTest extends GenerateCommandTest
14 {
15     use PluginTypeYamlDataProviderTrait;
16
17     /**
18      * Plugin type yaml generator test
19      *
20      * @param $module
21      * @param $class_name
22      * @param $machine_name
23      * @param $label
24      *
25      * @dataProvider commandData
26      */
27     public function testGeneratePluginTypeYaml(
28         $module,
29         $class_name,
30         $machine_name,
31         $label
32     ) {
33         $command = new PluginTypeAnnotationCommand($this->getHelperSet());
34         $command->setHelperSet($this->getHelperSet());
35         $command->setGenerator($this->getGenerator());
36
37         $commandTester = new CommandTester($command);
38
39         $code = $commandTester->execute(
40             [
41               '--module'            => $module,
42               '--class'        => $class_name,
43               '--machine-name'      => $machine_name,
44               '--label'             => $label
45             ],
46             ['interactive' => false]
47         );
48
49         $this->assertEquals(0, $code);
50     }
51
52     private function getGenerator()
53     {
54         return $this
55             ->getMockBuilder('Drupal\Console\Generator\PluginTypeYamlGenerator')
56             ->disableOriginalConstructor()
57             ->setMethods(['generate'])
58             ->getMock();
59     }
60 }