Skip to content

Commit

Permalink
Merge pull request #3 from jwage/fix-code-spacing
Browse files Browse the repository at this point in the history
Fix issues with weird code formatting of generated test.
  • Loading branch information
jwage committed Dec 12, 2018
2 parents b561cc5 + 0582c66 commit 27bfa1f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/Templates/test-class.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 %}
}
Expand All @@ -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 }}(
Expand Down
4 changes: 4 additions & 0 deletions tests/TestClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
15 changes: 14 additions & 1 deletion tests/TestClassGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class TestClassTest extends TestCase
/** @var TestClass */
private $testClass;
public function testGetTestDependency() : void
{
$this->testClass->getTestDependency();
Expand All @@ -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();
Expand All @@ -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,
Expand Down

0 comments on commit 27bfa1f

Please sign in to comment.