From 0582c667956094fb65c9d90f35f8bb7c43731357 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Wed, 12 Dec 2018 21:07:45 +0000 Subject: [PATCH] Fix issues with weird code formatting of generated test. --- lib/Templates/test-class.html.twig | 7 ++++--- tests/TestClass.php | 4 ++++ tests/TestClassGeneratorTest.php | 15 ++++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/Templates/test-class.html.twig b/lib/Templates/test-class.html.twig index 263a422..85df74a 100644 --- a/lib/Templates/test-class.html.twig +++ b/lib/Templates/test-class.html.twig @@ -20,7 +20,6 @@ class {{ shortName }} extends TestCase private ${{ property.propertyName }}; {% endfor %} - {% for testMethod in testClassMetadata.testMethods %} public function test{{ testMethod.methodName|slice(0, 1)|upper }}{{ testMethod.methodName|slice(1) }}() : void { @@ -36,10 +35,11 @@ class {{ shortName }} extends TestCase $this->{{ body.parameterName }}->{{ body.methodName }}( {% for parameter in body.parameters %} ${{ parameter }}{% if not loop.last %},{% endif %} + {% endfor %} - ); + ); {% endif %} -{%endfor %} +{% endfor %} } @@ -52,6 +52,7 @@ class {{ shortName }} extends TestCase {% for setUpDependency in testClassMetadata.setUpDependencies if setUpDependency.type == 'normal' %} $this->{{ setUpDependency.propertyName }} = {{ setUpDependency.propertyValue }}; {% endfor %} + {% for setUpDependency in testClassMetadata.setUpDependencies if setUpDependency.type == 'sut' %} {% if setUpDependency.parameters|length > 0 %} $this->{{ setUpDependency.propertyName }} = new {{ setUpDependency.propertyType }}( diff --git a/tests/TestClass.php b/tests/TestClass.php index 61d83fb..e986c55 100644 --- a/tests/TestClass.php +++ b/tests/TestClass.php @@ -50,6 +50,10 @@ public function getTestStringArgument() : string return $this->testStringArgument; } + public function getTestMethodWithArguments(string $a, float $b, int $c) : void + { + } + public function getSomething() : string { return 'something'; diff --git a/tests/TestClassGeneratorTest.php b/tests/TestClassGeneratorTest.php index d34ee76..48c9e60 100644 --- a/tests/TestClassGeneratorTest.php +++ b/tests/TestClassGeneratorTest.php @@ -39,7 +39,6 @@ class TestClassTest extends TestCase /** @var TestClass */ private $testClass; - public function testGetTestDependency() : void { $this->testClass->getTestDependency(); @@ -60,6 +59,19 @@ public function testGetTestStringArgument() : void $this->testClass->getTestStringArgument(); } + public function testGetTestMethodWithArguments() : void + { + $a = ''; + $b = ''; + $c = ''; + $this->testClass->getTestMethodWithArguments( + $a, + $b, + $c + ); + + } + public function testGetSomething() : void { $this->testClass->getSomething(); @@ -71,6 +83,7 @@ protected function setUp() : void $this->testFloatArgument = 1.0; $this->testIntegerArgument = 1; $this->testStringArgument = ''; + $this->testClass = new TestClass( $this->testDependency, $this->testFloatArgument,