Version 1
[yaffs-website] / vendor / drupal / console / Test / Command / GeneratorCommandCommandTest.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\Console\Test\Command\GeneratorCommandCommandTest.
5  */
6
7 namespace Drupal\Console\Test\Command;
8
9 use Drupal\Console\Command\Generate\CommandCommand;
10 use Symfony\Component\Console\Tester\CommandTester;
11 use Drupal\Console\Test\DataProvider\CommandDataProviderTrait;
12
13 class GeneratorCommandCommandTest extends GenerateCommandTest
14 {
15     use CommandDataProviderTrait;
16     
17     /**
18      * Command generator test
19      *
20      * @param $module
21      * @param $name
22      * @param $class
23      * @param $containerAware
24      *
25      * @dataProvider commandData
26      */
27     public function testGenerateCommand(
28         $module,
29         $name,
30         $class,
31         $containerAware
32     ) {
33         $command = new CommandCommand($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               '--name'            => $name,
43               '--class'           => $class,
44               '--container-aware' => $containerAware
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\CommandGenerator')
56             ->disableOriginalConstructor()
57             ->setMethods(['generate'])
58             ->getMock();
59     }
60 }