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\NodeBundle\Tests\Entity; |
||
4 | |||
5 | use Codeception\Stub; |
||
6 | use Doctrine\ORM\EntityManager; |
||
7 | use Doctrine\ORM\EntityRepository; |
||
8 | use Kunstmaan\NodeBundle\Entity\HasNodeInterface; |
||
9 | use Kunstmaan\NodeBundle\Entity\NodeTranslation; |
||
10 | use Kunstmaan\NodeBundle\Entity\NodeVersion; |
||
11 | use PHPUnit\Framework\TestCase; |
||
12 | |||
13 | /** |
||
14 | * Class NodeVersionTest |
||
15 | */ |
||
16 | class NodeVersionTest extends TestCase |
||
17 | { |
||
18 | /** |
||
19 | * @var NodeVersion |
||
20 | */ |
||
21 | protected $object; |
||
22 | |||
23 | /** |
||
24 | * Sets up the fixture, for example, opens a network connection. |
||
25 | * This method is called before a test is executed. |
||
26 | */ |
||
27 | protected function setUp() |
||
28 | { |
||
29 | $this->object = new NodeVersion(); |
||
30 | } |
||
31 | |||
32 | public function testSetGetNodeTranslation() |
||
33 | { |
||
34 | $nodeTrans = new NodeTranslation(); |
||
35 | $this->object->setNodeTranslation($nodeTrans); |
||
36 | $this->assertEquals($nodeTrans, $this->object->getNodeTranslation()); |
||
37 | } |
||
38 | |||
39 | public function testSetGetType() |
||
40 | { |
||
41 | $this->object->setType(NodeVersion::DRAFT_VERSION); |
||
42 | $this->assertEquals(NodeVersion::DRAFT_VERSION, $this->object->getType()); |
||
43 | } |
||
44 | |||
45 | public function testSetGetOwner() |
||
46 | { |
||
47 | $this->object->setOwner('owner'); |
||
48 | $this->assertEquals('owner', $this->object->getOwner()); |
||
49 | } |
||
50 | |||
51 | public function testSetGetCreated() |
||
52 | { |
||
53 | $created = new \DateTime(); |
||
54 | $this->object->setCreated($created); |
||
55 | $this->assertEquals($created, $this->object->getCreated()); |
||
56 | } |
||
57 | |||
58 | public function testSetGetUpdated() |
||
59 | { |
||
60 | $updated = new \DateTime(); |
||
61 | $this->object->setUpdated($updated); |
||
62 | $this->assertEquals($updated, $this->object->getUpdated()); |
||
63 | } |
||
64 | |||
65 | public function testGetSetRef() |
||
66 | { |
||
67 | /** @var HasNodeInterface $entity */ |
||
68 | $entity = Stub::makeEmpty(HasNodeInterface::class, [ |
||
69 | 'getId' => 1, |
||
70 | ]); |
||
71 | |||
72 | $em = $this->getMockBuilder(EntityManager::class) |
||
73 | ->disableOriginalConstructor() |
||
74 | ->getMock(); |
||
75 | |||
76 | $repo = $this->getMockBuilder(EntityRepository::class) |
||
77 | ->disableOriginalConstructor() |
||
78 | ->getMock(); |
||
79 | |||
80 | $repo->expects($this->any()) |
||
81 | ->method('find') |
||
82 | ->will($this->returnValue($entity)); |
||
83 | |||
84 | $em->expects($this->any()) |
||
85 | ->method('getRepository') |
||
86 | ->will($this->returnValue($repo)); |
||
87 | |||
88 | $this->object->setRef($entity); |
||
89 | $this->assertEquals(1, $this->object->getRefId()); |
||
90 | $this->assertEquals(get_class($entity), $this->object->getRefEntityName()); |
||
91 | $this->assertInstanceOf(get_class($entity), $this->object->getRef($em)); |
||
0 ignored issues
–
show
|
|||
92 | } |
||
93 | |||
94 | public function testGetDefaultAdminType() |
||
95 | { |
||
96 | $this->assertNull($this->object->getDefaultAdminType()); |
||
97 | } |
||
98 | |||
99 | public function testGetSetOrigin() |
||
100 | { |
||
101 | $entity = new NodeVersion(); |
||
102 | $this->object->setOrigin($entity); |
||
103 | $this->assertInstanceOf(NodeVersion::class, $this->object->getOrigin()); |
||
104 | } |
||
105 | |||
106 | public function testIsPublic() |
||
107 | { |
||
108 | $this->object->setType(NodeVersion::PUBLIC_VERSION); |
||
109 | $this->assertTrue($this->object->isPublic()); |
||
110 | } |
||
111 | } |
||
112 |
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: