These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\PagePartBundle\Tests\PagePartConfigurationReader; |
||
4 | |||
5 | use Kunstmaan\PagePartBundle\PagePartConfigurationReader\PagePartConfigurationParser; |
||
6 | use Kunstmaan\PagePartBundle\Tests\unit\PagePartConfigurationReader\LocatingKernelStub; |
||
7 | use PHPUnit_Framework_TestCase; |
||
8 | |||
9 | class PagePartConfigurationParserTest extends PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | View Code Duplication | public function testParserKnowsAboutPresets() |
|
0 ignored issues
–
show
|
|||
12 | { |
||
13 | $parser = new PagePartConfigurationParser(new LocatingKernelStub(), [ |
||
14 | 'foo' => [ |
||
15 | 'name' => 'Foo preset', |
||
16 | 'context' => 'main', |
||
17 | |||
18 | ] |
||
19 | ]); |
||
20 | |||
21 | $value = $parser->parse('foo'); |
||
22 | |||
23 | $this->assertSame('Foo preset', $value->getName()); |
||
24 | } |
||
25 | |||
26 | public function testExtendsWithinBundleWorks() |
||
27 | { |
||
28 | $parser = new PagePartConfigurationParser(new LocatingKernelStub); |
||
29 | |||
30 | $value = $parser->parse('Bundle:main-extended'); |
||
31 | |||
32 | $this->assertCount(3, $value->getPossiblePagePartTypes()); |
||
33 | |||
34 | } |
||
35 | |||
36 | View Code Duplication | public function testPresetExtendsBundle() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
37 | { |
||
38 | $parser = new PagePartConfigurationParser(new LocatingKernelStub, [ |
||
39 | 'foo' => [ |
||
40 | 'name' => 'Foo preset', |
||
41 | 'context' => 'main', |
||
42 | 'extends' => 'Bundle:main' |
||
43 | ] |
||
44 | ]); |
||
45 | |||
46 | $value = $parser->parse('foo'); |
||
47 | |||
48 | $this->assertCount(3, $value->getPossiblePagePartTypes()); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @expectedException \RuntimeException |
||
53 | */ |
||
54 | public function testCircularReferenceIsDetected() |
||
55 | { |
||
56 | $parser = new PagePartConfigurationParser(new LocatingKernelStub, [ |
||
57 | 'foo' => [ |
||
58 | 'name' => 'Foo preset', |
||
59 | 'extends' => 'bar', |
||
60 | ], |
||
61 | 'bar' => [ |
||
62 | 'name' => 'Bar preset', |
||
63 | 'extends' => 'baz', |
||
64 | ], |
||
65 | 'baz' => [ |
||
66 | 'name' => 'Baz preset', |
||
67 | 'extends' => 'foo', |
||
68 | ] |
||
69 | ]); |
||
70 | |||
71 | $parser->parse('foo'); |
||
72 | } |
||
73 | } |
||
74 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.