12
12
namespace Symfony \Bundle \MakerBundle \Tests \Util ;
13
13
14
14
use PHPUnit \Framework \TestCase ;
15
- use Symfony \Bundle \MakerBundle \Util \PhpCompatUtil ;
16
15
use Symfony \Bundle \MakerBundle \Util \TemplateComponentGenerator ;
17
16
18
17
/**
@@ -22,7 +21,7 @@ class TemplateComponentGeneratorTest extends TestCase
22
21
{
23
22
public function testRouteAttributes (): void
24
23
{
25
- $ generator = new TemplateComponentGenerator ($ this -> createMock (PhpCompatUtil::class) );
24
+ $ generator = new TemplateComponentGenerator (false , false );
26
25
27
26
$ expected = " #[Route('/', name: 'app_home')] \n" ;
28
27
@@ -34,7 +33,7 @@ public function testRouteAttributes(): void
34
33
*/
35
34
public function testRouteMethods (string $ expected , array $ methods ): void
36
35
{
37
- $ generator = new TemplateComponentGenerator ($ this -> createMock (PhpCompatUtil::class) );
36
+ $ generator = new TemplateComponentGenerator (false , false );
38
37
39
38
self ::assertSame ($ expected , $ generator ->generateRouteForControllerMethod (
40
39
'/ ' ,
@@ -54,7 +53,7 @@ public function routeMethodDataProvider(): \Generator
54
53
*/
55
54
public function testRouteIndentation (string $ expected ): void
56
55
{
57
- $ generator = new TemplateComponentGenerator ($ this -> createMock (PhpCompatUtil::class) );
56
+ $ generator = new TemplateComponentGenerator (false , false );
58
57
59
58
self ::assertSame ($ expected , $ generator ->generateRouteForControllerMethod (
60
59
'/ ' ,
@@ -74,7 +73,7 @@ public function routeIndentationDataProvider(): \Generator
74
73
*/
75
74
public function testRouteTrailingNewLine (string $ expected ): void
76
75
{
77
- $ generator = new TemplateComponentGenerator ($ this -> createMock (PhpCompatUtil::class) );
76
+ $ generator = new TemplateComponentGenerator (false , false );
78
77
79
78
self ::assertSame ($ expected , $ generator ->generateRouteForControllerMethod (
80
79
'/ ' ,
@@ -89,4 +88,26 @@ public function routeTrailingNewLineDataProvider(): \Generator
89
88
{
90
89
yield ["#[Route('/', name: 'app_home')] " , true ];
91
90
}
91
+
92
+ /**
93
+ * @dataProvider finalClassDataProvider
94
+ */
95
+ public function testGetFinalClassDeclaration (bool $ finalClass , bool $ finalEntity , bool $ isEntity , string $ expectedResult ): void
96
+ {
97
+ $ generator = new TemplateComponentGenerator ($ finalClass , $ finalEntity );
98
+
99
+ self ::assertSame ($ expectedResult , $ generator ->getFinalDeclaration ($ isEntity ));
100
+ }
101
+
102
+ public function finalClassDataProvider (): \Generator
103
+ {
104
+ yield 'Not Final Class ' => [false , false , false , '' ];
105
+ yield 'Not Final Class w/ Entity ' => [false , true , false , '' ];
106
+ yield 'Final Class ' => [true , false , false , 'final ' ];
107
+ yield 'Final Class w/ Entity ' => [true , true , false , 'final ' ];
108
+ yield 'Not Final Entity ' => [false , false , true , '' ];
109
+ yield 'Not Final Entity w/ Class ' => [true , false , true , '' ];
110
+ yield 'Final Entity ' => [false , true , true , 'final ' ];
111
+ yield 'Final Entity w/ Class ' => [true , true , true , 'final ' ];
112
+ }
92
113
}
0 commit comments