Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / Test / Command / GeneratorPluginFieldCommandTest.php
1 <?php
2 /**
3  * @file
4  * Contains \Drupal\Console\Test\Command\GeneratorPluginFieldCommandTest.
5  */
6
7 namespace Drupal\Console\Test\Command;
8
9 use Drupal\Console\Command\Generate\PluginFieldCommand;
10 use Symfony\Component\Console\Tester\CommandTester;
11 use Drupal\Console\Test\DataProvider\PluginFieldDataProviderTrait;
12
13 class GeneratorPluginFieldCommandTest extends GenerateCommandTest
14 {
15     use PluginFieldDataProviderTrait;
16     
17     /**
18      * Plugin block generator test
19      *
20      * @param $module
21      * @param $type_class_name
22      * @param $type_label
23      * @param $type_plugin_id
24      * @param $type_description
25      * @param $formatter_class_name
26      * @param $formatter_label
27      * @param $formatter_plugin_id
28      * @param $widget_class_name
29      * @param $widget_label
30      * @param $widget_plugin_id
31      * @param $field_type
32      * @param $default_widget
33      * @param $default_formatter
34      *
35      * @dataProvider commandData
36      */
37     public function testGeneratePluginField(
38         $module,
39         $type_class_name,
40         $type_label,
41         $type_plugin_id,
42         $type_description,
43         $formatter_class_name,
44         $formatter_label,
45         $formatter_plugin_id,
46         $widget_class_name,
47         $widget_label,
48         $widget_plugin_id,
49         $field_type,
50         $default_widget,
51         $default_formatter
52     ) {
53         $command = new PluginFieldCommand($this->getHelperSet());
54         $command->setHelperSet($this->getHelperSet());
55         $command->setGenerator($this->getGenerator());
56
57         $commandTester = new CommandTester($command);
58
59         $code = $commandTester->execute(
60             [
61               '--module'                => $module,
62               '--type-class'            => $type_class_name,
63               '--type-label'            => $type_label,
64               '--type-plugin-id'        => $type_plugin_id,
65               '--type-description'      => $type_description,
66               '--formatter-class'       => $formatter_class_name,
67               '--formatter-label'       => $formatter_label,
68               '--formatter-plugin-id'   => $formatter_plugin_id,
69               '--widget-class'          => $widget_class_name,
70               '--widget-label'          => $widget_label,
71               '--widget-plugin-id'      => $widget_plugin_id,
72               '--field-type'            => $field_type,
73               '--default-widget'        => $default_widget,
74               '--default-formatter'     => $default_formatter
75             ],
76             ['interactive' => false]
77         );
78
79         $this->assertEquals(0, $code);
80     }
81
82     private function getGenerator()
83     {
84         return $this
85             ->getMockBuilder('Drupal\Console\Generator\PluginFieldTypeGenerator')
86             ->disableOriginalConstructor()
87             ->setMethods(['generate'])
88             ->getMock();
89     }
90 }