Skip to content

Commit

Permalink
Clean-up template test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-teck committed Oct 21, 2020
1 parent 31a0dbc commit 6b3ed0f
Showing 1 changed file with 47 additions and 16 deletions.
63 changes: 47 additions & 16 deletions tests/dcg/Generator/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,55 @@

namespace DrupalCodeGenerator\Tests\Generator;

use DrupalCodeGenerator\Command\Template;
use DrupalCodeGenerator\Test\GeneratorTest;

/**
* Test for template command.
*/
final class TemplateTest extends BaseGeneratorTest {

protected $class = 'Template';

protected $interaction = [
'Module name [%default_name%]:' => 'Example',
'Module machine name [example]:' => 'example',
'Template name [example]:' => 'foo',
'Create theme hook? [Yes]:' => 'Yes',
'Create preprocess hook? [Yes]:' => 'Yes',
];

protected $fixtures = [
'example.module' => '/_template.module',
'templates/foo.html.twig' => '/_template.twig',
];
final class TemplateTest extends GeneratorTest {

protected $fixtureDir = __DIR__;

/**
* Test callback.
*/
public function testGenerator(): void {

$user_input = ['Example', 'example', 'foo', 'Yes', 'Yes'];
$this->execute(new Template(), $user_input);

$expected_display = <<< 'TXT'
Welcome to template generator!
––––––––––––––––––––––––––––––––
Module name [%default_name%]:
Module machine name [example]:
Template name [example]:
Create theme hook? [Yes]:
Create preprocess hook? [Yes]:
The following directories and files have been created or updated:
–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
• example.module
• templates/foo.html.twig
TXT;
$this->assertDisplay($expected_display);

$this->assertGeneratedFile('example.module', '_template.module');
$this->assertGeneratedFile('templates/foo.html.twig', '_template.twig');
}

}

0 comments on commit 6b3ed0f

Please sign in to comment.