From 9418ba4ee721370a0516ff10ff3bdfc964cbe1f6 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 9 Feb 2020 13:55:11 +0000 Subject: [PATCH] Generate a .module file --- fixtures/drupal7_module/drupal7_module.module | 6 ++++++ src/Command/GenerateDrupal7Command.php | 2 +- .../GenerateDrupal7ModuleCommandTest.php | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 fixtures/drupal7_module/drupal7_module.module diff --git a/fixtures/drupal7_module/drupal7_module.module b/fixtures/drupal7_module/drupal7_module.module new file mode 100644 index 0000000..4ba3d13 --- /dev/null +++ b/fixtures/drupal7_module/drupal7_module.module @@ -0,0 +1,6 @@ +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()); file_put_contents( diff --git a/tests/Command/GenerateDrupal7ModuleCommandTest.php b/tests/Command/GenerateDrupal7ModuleCommandTest.php index a67f2a4..4156a61 100644 --- a/tests/Command/GenerateDrupal7ModuleCommandTest.php +++ b/tests/Command/GenerateDrupal7ModuleCommandTest.php @@ -63,4 +63,22 @@ class GenerateDrupal7ModuleCommandTest extends TestCase $this->assertStringContainsString('name = 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); + } }