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 League\Fractal\Test; |
||
4 | |||
5 | use League\Fractal\Manager; |
||
6 | use League\Fractal\Resource\ResourceInterface; |
||
7 | use League\Fractal\Scope; |
||
8 | use League\Fractal\ScopeFactory; |
||
9 | use PHPUnit\Framework\TestCase; |
||
10 | |||
11 | class ScopeFactoryTest extends TestCase |
||
12 | { |
||
13 | public function testItImplementsScopeFactoryInterface() |
||
14 | { |
||
15 | $this->assertInstanceOf('League\\Fractal\\ScopeFactoryInterface', $this->createSut()); |
||
16 | } |
||
17 | |||
18 | public function testItCreatesScopes() |
||
19 | { |
||
20 | $sut = $this->createSut(); |
||
21 | |||
22 | $manager = $this->createManager(); |
||
23 | $resource = $this->createResource(); |
||
24 | $scopeIdentifier = 'foo_identifier'; |
||
25 | |||
26 | $scope = $sut->createScopeFor($manager, $resource, $scopeIdentifier); |
||
0 ignored issues
–
show
$resource is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<League\Fractal\Resource\ResourceInterface> .
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...
|
|||
27 | |||
28 | $this->assertInstanceOf('League\\Fractal\\Scope', $scope); |
||
29 | $this->assertSame($resource, $scope->getResource()); |
||
30 | $this->assertSame($scopeIdentifier, $scope->getScopeIdentifier()); |
||
31 | } |
||
32 | |||
33 | public function testItCreatesScopesWithParent() |
||
34 | { |
||
35 | $manager = $this->createManager(); |
||
36 | |||
37 | $scope = new Scope($manager, $this->createResource(), 'parent_identifier'); |
||
0 ignored issues
–
show
$manager is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<League\Fractal\Manager> .
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...
$this->createResource() is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<League\Fractal\Resource\ResourceInterface> .
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 | $scope->setParentScopes([ |
||
39 | 'parent_scope', |
||
40 | ]); |
||
41 | |||
42 | $resource = $this->createResource(); |
||
43 | $scopeIdentifier = 'foo_identifier'; |
||
44 | |||
45 | $expectedParentScopes = [ |
||
46 | 'parent_scope', |
||
47 | 'parent_identifier', |
||
48 | ]; |
||
49 | |||
50 | $sut = $this->createSut(); |
||
51 | $scope = $sut->createChildScopeFor($manager, $scope, $resource, $scopeIdentifier); |
||
0 ignored issues
–
show
$manager is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<League\Fractal\Manager> .
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...
$resource is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<League\Fractal\Resource\ResourceInterface> .
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...
|
|||
52 | |||
53 | $this->assertInstanceOf('League\\Fractal\\Scope', $scope); |
||
54 | $this->assertSame($resource, $scope->getResource()); |
||
55 | $this->assertSame($scopeIdentifier, $scope->getScopeIdentifier()); |
||
56 | $this->assertEquals($expectedParentScopes, $scope->getParentScopes()); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return ScopeFactory |
||
61 | */ |
||
62 | private function createSut() |
||
63 | { |
||
64 | return new ScopeFactory(); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return Manager |
||
69 | */ |
||
70 | private function createManager() |
||
71 | { |
||
72 | return $this->getMockBuilder('League\\Fractal\\Manager')->getMock(); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return ResourceInterface |
||
77 | */ |
||
78 | private function createResource() |
||
79 | { |
||
80 | return $this->getMockBuilder('League\\Fractal\\Resource\\ResourceInterface')->getMock(); |
||
81 | } |
||
82 | } |
||
83 |
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: