Generate a .module file

This commit is contained in:
Oliver Davies 2020-02-09 13:55:11 +00:00
parent 55ca3647c4
commit 9418ba4ee7
3 changed files with 25 additions and 1 deletions

View file

@ -0,0 +1,6 @@
<?php
/**
* @file
* The main module file for {{ name }}.
*/

View file

@ -88,7 +88,7 @@ class GenerateDrupal7Command extends Command
$createdFiles = []; $createdFiles = [];
/** @var SplFileInfo $file */ /** @var SplFileInfo $file */
foreach ($this->finder->in('fixtures/drupal7_module')->name('/.info/') as $file) { foreach ($this->finder->in('fixtures/drupal7_module')->name('/.[info,module]/') as $file) {
$contents = $this->updateFileContents($file->getContents()); $contents = $this->updateFileContents($file->getContents());
file_put_contents( file_put_contents(

View file

@ -63,4 +63,22 @@ class GenerateDrupal7ModuleCommandTest extends TestCase
$this->assertStringContainsString('name = test_module', $contents); $this->assertStringContainsString('name = test_module', $contents);
$this->assertStringContainsString('description = The description for test_module.', $contents); $this->assertStringContainsString('description = The description for test_module.', $contents);
} }
/** @test */
public function it_generates_a_module_file()
{
$finder = new Finder();
$command = new GenerateDrupal7Command($finder);
$commandTester = new CommandTester($command);
$commandTester->execute([
'module-name' => 'test_module',
]);
$this->assertTrue(is_file('test_module/test_module.module'));
$contents = file_get_contents('test_module/test_module.module');
$this->assertStringContainsString('The main module file for test_module.', $contents);
}
} }