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