Skip to content

Commit 50c2077

Browse files
committed
add template class detail assertions
1 parent e605c5c commit 50c2077

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

tests/Util/TemplateClassDetailsTest.php

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,43 @@ public function testDetails(): void
2424
{
2525
$details = new TemplateClassDetails(MakerBundle::class, false);
2626

27-
self::assertSame('use Symfony\Bundle\MakerBundle\MakerBundle;', $details->getUseStatement());
28-
self::assertSame(' private $makerBundle;', $details->getPropertyStatement());
27+
self::assertSame(sprintf('use Symfony\Bundle\MakerBundle\MakerBundle;%s', "\n"), $details->getUseStatement());
28+
self::assertSame(sprintf(' private $makerBundle;%s', "\n"), $details->getPropertyStatement());
29+
self::assertSame(sprintf(' $this->makerBundle = $makerBundle;%s', "\n"), $details->getConstructorArgument());
2930
self::assertSame('MakerBundle $makerBundle', $details->getMethodArgument());
31+
self::assertSame('$this->makerBundle', $details->getProperty());
3032
self::assertSame('$makerBundle', $details->getVariable());
3133
}
3234

3335
public function testDetailsTypedProperties(): void
3436
{
3537
$details = new TemplateClassDetails(MakerBundle::class, true);
3638

37-
self::assertSame('private MakerBundle $makerBundle;', $details->getPropertyStatement());
39+
self::assertSame(sprintf(' private MakerBundle $makerBundle;%s', "\n"), $details->getPropertyStatement());
40+
}
41+
42+
public function testUseStatementWithoutTrailingNewLine(): void
43+
{
44+
$details = new TemplateClassDetails(MakerBundle::class, false);
45+
46+
self::assertSame('use Symfony\Bundle\MakerBundle\MakerBundle;', $details->getUseStatement(false));
47+
}
48+
49+
public function testGetPropertyStatementArguments(): void
50+
{
51+
$details = new TemplateClassDetails(MakerBundle::class, false);
52+
53+
self::assertSame(' private $makerBundle;', $details->getPropertyStatement(false));
54+
self::assertSame(sprintf('private $makerBundle;%s', "\n"), $details->getPropertyStatement(true, false));
55+
self::assertSame('private $makerBundle;', $details->getPropertyStatement(false, false));
56+
}
57+
58+
public function testGetConstructorArgumentArguments(): void
59+
{
60+
$details = new TemplateClassDetails(MakerBundle::class, false);
61+
62+
self::assertSame(' $this->makerBundle = $makerBundle;', $details->getConstructorArgument(false, true));
63+
self::assertSame(sprintf('$this->makerBundle = $makerBundle;%s', "\n"), $details->getConstructorArgument(true, false));
64+
self::assertSame('$this->makerBundle = $makerBundle;', $details->getConstructorArgument(false, false));
3865
}
3966
}

0 commit comments

Comments
 (0)