From 0d6bd4e070da32f56904c0b65d96afb330503eae Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Sun, 9 Feb 2020 21:28:46 +0000
Subject: [PATCH] Populate more of the test stub

---
 .../src/Tests/Functional/ExampleTest.php      | 20 +++++++++++++++++--
 src/Command/GenerateDrupal7Command.php        |  1 +
 .../GenerateDrupal7ModuleCommandTest.php      |  6 ++++++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/fixtures/drupal7_module/src/Tests/Functional/ExampleTest.php b/fixtures/drupal7_module/src/Tests/Functional/ExampleTest.php
index 6bd1635..8bb1da1 100644
--- a/fixtures/drupal7_module/src/Tests/Functional/ExampleTest.php
+++ b/fixtures/drupal7_module/src/Tests/Functional/ExampleTest.php
@@ -1,5 +1,21 @@
 <?php
 
-namespace Drupal\{{ name }}\Tests\Functional;
+namespace Drupal\{{ machine_name }}\Tests\Functional;
 
-final class {{ test_name }} extends \DrupalWebTestCase {}
+final class {{ test_name }} extends \DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => '{{ name }}',
+      'description' => '{{ name }} tests.',
+      'group' => '{{ name }}',
+    );
+  }
+
+  public function test_that_the_front_page_loads() {
+    $this->drupalGet('<front>');
+
+    $this->assertResponse(200);
+  }
+
+}
diff --git a/src/Command/GenerateDrupal7Command.php b/src/Command/GenerateDrupal7Command.php
index e102507..79217c6 100644
--- a/src/Command/GenerateDrupal7Command.php
+++ b/src/Command/GenerateDrupal7Command.php
@@ -120,6 +120,7 @@ final class GenerateDrupal7Command extends Command
 
     private function updateFileContents($contents)
     {
+        $contents = str_replace('{{ machine_name }}', $this->machineName, $contents);
         $contents = str_replace('{{ name }}', $this->moduleName, $contents);
         $contents = str_replace('{{ test_name }}', $this->testName, $contents);
 
diff --git a/tests/Command/GenerateDrupal7ModuleCommandTest.php b/tests/Command/GenerateDrupal7ModuleCommandTest.php
index 5a3c4ff..26f0aaf 100644
--- a/tests/Command/GenerateDrupal7ModuleCommandTest.php
+++ b/tests/Command/GenerateDrupal7ModuleCommandTest.php
@@ -109,6 +109,12 @@ final class GenerateDrupal7ModuleCommandTest extends TestCase
 
         $contents = file_get_contents('test_module/src/Tests/Functional/TestModuleTest.php');
 
+        $this->assertStringContainsString('namespace Drupal\\test_module\\Tests\\Functional', $contents);
+
         $this->assertStringContainsString('final class TestModuleTest', $contents);
+
+        $this->assertStringContainsString("'name' => 'Test Module'", $contents);
+        $this->assertStringContainsString("'description' => 'Test Module tests.'", $contents);
+        $this->assertStringContainsString("'group' => 'Test Module'", $contents);
     }
 }