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