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\PagePartAdmin\PagePartAdminConfiguratorInterface; |
||
6 | use Kunstmaan\PagePartBundle\PagePartConfigurationReader\PagePartConfigurationParser; |
||
7 | use PHPUnit\Framework\TestCase; |
||
8 | use Symfony\Component\HttpKernel\KernelInterface; |
||
9 | |||
10 | class PagePartConfigurationParserTest extends TestCase |
||
11 | { |
||
12 | public function testParseSf4Flow() |
||
13 | { |
||
14 | $kernel = $this->createMock(KernelInterface::class); |
||
15 | $pagePartConfigurationParser = new PagePartConfigurationParser($kernel, [ |
||
0 ignored issues
–
show
|
|||
16 | 'main' => [ |
||
17 | 'name' => 'Main content', |
||
18 | 'context' => 'main', |
||
19 | 'types' => [ |
||
20 | ['name' => 'FooBar', 'class' => 'Foo\BarPagePart'], |
||
21 | ['name' => 'Foo', 'class' => 'FooPagePart'], |
||
22 | ['name' => 'Bar', 'class' => 'BarPagePart'], |
||
23 | ], |
||
24 | ], |
||
25 | ]); |
||
26 | |||
27 | $result = $pagePartConfigurationParser->parse('main'); |
||
28 | $this->assertInstanceOf(PagePartAdminConfiguratorInterface::class, $result); |
||
29 | $this->assertEquals('Main content', $result->getName()); |
||
30 | } |
||
31 | |||
32 | View Code Duplication | public function testParseSf3Flow() |
|
33 | { |
||
34 | $kernel = $this->createMock(KernelInterface::class); |
||
35 | $kernel->method('locateResource')->willReturn(__DIR__ . '/Resources/config/pageparts/main.yml'); |
||
36 | |||
37 | $pagePartConfigurationParser = new PagePartConfigurationParser($kernel, []); |
||
0 ignored issues
–
show
$kernel is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...Kernel\KernelInterface> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
38 | |||
39 | $result = $pagePartConfigurationParser->parse('MyWebsiteBundle:main'); |
||
40 | $this->assertInstanceOf(PagePartAdminConfiguratorInterface::class, $result); |
||
41 | $this->assertEquals('Main content', $result->getName()); |
||
42 | } |
||
43 | |||
44 | public function testPresetExtendsBundle() |
||
45 | { |
||
46 | $kernel = $this->createMock(KernelInterface::class); |
||
47 | $pagePartConfigurationParser = new PagePartConfigurationParser($kernel, [ |
||
0 ignored issues
–
show
$kernel is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...Kernel\KernelInterface> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
48 | 'foo' => [ |
||
49 | 'name' => 'Foo content', |
||
50 | 'context' => 'foo', |
||
51 | 'extends' => 'main', |
||
52 | 'types' => [ |
||
53 | ['name' => 'FooBar', 'class' => 'Foo\BarPagePart'], |
||
54 | ['name' => 'Foo', 'class' => 'FooPagePart'], |
||
55 | ['name' => 'Bar', 'class' => 'BarPagePart'], |
||
56 | ], |
||
57 | ], |
||
58 | 'main' => [ |
||
59 | 'name' => 'Main content', |
||
60 | 'context' => 'main', |
||
61 | 'types' => [ |
||
62 | ['name' => 'Header', 'class' => 'HeaderPagePart'], |
||
63 | ], |
||
64 | ], |
||
65 | ] |
||
66 | ); |
||
67 | |||
68 | $value = $pagePartConfigurationParser->parse('foo'); |
||
69 | |||
70 | $this->assertCount(4, $value->getPossiblePagePartTypes()); |
||
0 ignored issues
–
show
$value->getPossiblePagePartTypes() is of type array , but the function expects a object<Countable>|object...nit\Framework\iterable> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @expectedException \RuntimeException |
||
75 | */ |
||
76 | public function testCircularReferenceIsDetected() |
||
77 | { |
||
78 | $kernel = $this->createMock(KernelInterface::class); |
||
79 | |||
80 | $parser = new PagePartConfigurationParser($kernel, [ |
||
0 ignored issues
–
show
$kernel is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...Kernel\KernelInterface> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
81 | 'foo' => [ |
||
82 | 'name' => 'Foo preset', |
||
83 | 'extends' => 'bar', |
||
84 | ], |
||
85 | 'bar' => [ |
||
86 | 'name' => 'Bar preset', |
||
87 | 'extends' => 'baz', |
||
88 | ], |
||
89 | 'baz' => [ |
||
90 | 'name' => 'Baz preset', |
||
91 | 'extends' => 'foo', |
||
92 | ], |
||
93 | ]); |
||
94 | |||
95 | $parser->parse('foo'); |
||
96 | } |
||
97 | } |
||
98 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: