diff --git a/templates/crud/test/Test.EntityManager.tpl.php b/templates/crud/test/Test.EntityManager.tpl.php index 288c2093a..2451c5794 100644 --- a/templates/crud/test/Test.EntityManager.tpl.php +++ b/templates/crud/test/Test.EntityManager.tpl.php @@ -61,7 +61,7 @@ public function testShow(): void $this->markTestIncomplete(); $fixture = new (); $typeOptions): ?> - $fixture->set('My Title'); + $fixture->set('My Title'); $this->manager->persist($fixture); @@ -80,7 +80,7 @@ public function testEdit(): void $this->markTestIncomplete(); $fixture = new (); $typeOptions): ?> - $fixture->set('Value'); + $fixture->set('Value'); $this->manager->persist($fixture); @@ -99,7 +99,7 @@ public function testEdit(): void $fixture = $this->Repository->findAll(); $typeOptions): ?> - self::assertSame('Something New', $fixture[0]->get()); + self::assertSame('Something New', $fixture[0]->get()); } @@ -108,7 +108,7 @@ public function testRemove(): void $this->markTestIncomplete(); $fixture = new (); $typeOptions): ?> - $fixture->set('Value'); + $fixture->set('Value'); $this->manager->persist($fixture); diff --git a/tests/Maker/MakeCrudTest.php b/tests/Maker/MakeCrudTest.php index 46c63f975..7eee6e52a 100644 --- a/tests/Maker/MakeCrudTest.php +++ b/tests/Maker/MakeCrudTest.php @@ -87,6 +87,28 @@ public function getTestDetails(): \Generator }), ]; + yield 'it_generates_correct_class_methods' => [$this->createMakerTest() + ->addExtraDependencies('symfony/test-pack') + ->run(function (MakerTestRunner $runner) { + $runner->copy( + 'make-crud/Foo.php', + 'src/Entity/Foo.php' + ); + + $output = $runner->runMaker([ + 'Foo', // Entity Class Name + '', // Default Controller, + 'y', // Generate Tests + ]); + + $this->assertStringContainsString('src/Controller/FooController.php', $output); + $this->assertStringContainsString('src/Form/FooType.php', $output); + $this->assertStringContainsString('tests/Controller/FooControllerTest.php', $output); + + $this->runCrudTest($runner, 'it_generates_correct_class_methods.php'); + }), + ]; + yield 'it_generates_crud_custom_repository_with_test' => [$this->createMakerTest() ->addExtraDependencies('symfony/test-pack') ->run(function (MakerTestRunner $runner) { diff --git a/tests/fixtures/make-crud/Foo.php b/tests/fixtures/make-crud/Foo.php new file mode 100644 index 000000000..713ca37be --- /dev/null +++ b/tests/fixtures/make-crud/Foo.php @@ -0,0 +1,49 @@ +id; + } + + public function getFoo(): string + { + return $this->foo; + } + + public function setFoo(string $foo): self + { + $this->foo = $foo; + + return $this; + } + + public function getFooBar(): string + { + return $this->foo_bar; + } + + public function setFooBar(string $foo_bar): self + { + $this->foo_bar = $foo_bar; + + return $this; + } +} diff --git a/tests/fixtures/make-crud/tests/it_generates_correct_class_methods.php b/tests/fixtures/make-crud/tests/it_generates_correct_class_methods.php new file mode 100644 index 000000000..78f5ba82e --- /dev/null +++ b/tests/fixtures/make-crud/tests/it_generates_correct_class_methods.php @@ -0,0 +1,25 @@ +rootFolder . '/tests/Controller/FooControllerTest.php'); + + $this->assertStringContainsString("getFooBar()", $testFileContent); + $this->assertMatchesRegularExpression("/setFooBar(.*)/", $testFileContent); + $this->assertStringNotContainsString("getFoo_bar()", $testFileContent); + } +}