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\Entity; |
||
4 | |||
5 | use DateTime; |
||
6 | use Doctrine\ORM\EntityManager; |
||
7 | use Doctrine\ORM\EntityRepository; |
||
8 | use Kunstmaan\PagePartBundle\Entity\PagePartRef; |
||
9 | use PHPUnit\Framework\TestCase; |
||
10 | |||
11 | /** |
||
12 | * Class PagePartRefTest |
||
13 | */ |
||
14 | class PagePartRefTest extends TestCase |
||
15 | { |
||
16 | public function testGetSet() |
||
17 | { |
||
18 | $part = new PagePartRef(); |
||
19 | $part->setId(1); |
||
20 | $part->setPageId(2); |
||
21 | $part->setPageEntityname(PagePartRef::class); |
||
22 | $part->setCreated(new DateTime()); |
||
23 | $part->setUpdated(new DateTime()); |
||
24 | $part->setUpdatedValue(); |
||
25 | $part->setContext('a string'); |
||
26 | $part->setSequencenumber(3); |
||
27 | $part->setPagePartId('4'); |
||
28 | $part->setPagePartEntityname(PagePartRef::class); |
||
29 | |||
30 | $em = $this->getMockBuilder(EntityManager::class) |
||
31 | ->disableOriginalConstructor() |
||
32 | ->getMock(); |
||
33 | |||
34 | $repo = $this->getMockBuilder(EntityRepository::class) |
||
35 | ->disableOriginalConstructor() |
||
36 | ->getMock(); |
||
37 | |||
38 | $repo->expects($this->any()) |
||
39 | ->method('find') |
||
40 | ->will($this->returnValue(new PagePart())); |
||
41 | |||
42 | $em->expects($this->any()) |
||
43 | ->method('getRepository') |
||
44 | ->will($this->returnValue($repo)); |
||
45 | |||
46 | $this->assertEquals(1, $part->getId()); |
||
47 | $this->assertEquals(2, $part->getPageId()); |
||
48 | $this->assertEquals(PagePartRef::class, $part->getPageEntityname()); |
||
49 | $this->assertInstanceOf(DateTime::class, $part->getCreated()); |
||
50 | $this->assertInstanceOf(DateTime::class, $part->getUpdated()); |
||
51 | $this->assertEquals('a string', $part->getContext()); |
||
52 | $this->assertEquals(3, $part->getSequencenumber()); |
||
53 | $this->assertEquals('4', $part->getPagePartId()); |
||
54 | $this->assertEquals(PagePartRef::class, $part->getPagePartEntityname()); |
||
55 | $this->assertEquals('pagepartref in context a string', $part->__toString()); |
||
56 | $this->assertInstanceOf(PagePart::class, $part->getPagePart($em)); |
||
0 ignored issues
–
show
|
|||
57 | } |
||
58 | } |
||
59 |
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: