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