1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kunstmaan\PagePartBundle\Tests\Entity; |
4
|
|
|
|
5
|
|
|
use Codeception\Stub; |
6
|
|
|
use Doctrine\ORM\EntityManager; |
7
|
|
|
use Doctrine\ORM\EntityRepository; |
8
|
|
|
use Kunstmaan\NodeBundle\Entity\AbstractPage; |
9
|
|
|
use Kunstmaan\PagePartBundle\Entity\PageTemplateConfiguration; |
10
|
|
|
use Kunstmaan\PagePartBundle\PageTemplate\PageTemplate; |
11
|
|
|
use PHPUnit\Framework\TestCase; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class LinkPagePartTest |
15
|
|
|
*/ |
16
|
|
|
class PageTemplateConfigurationTest extends TestCase |
17
|
|
|
{ |
18
|
|
|
public function testGetSet() |
19
|
|
|
{ |
20
|
|
|
$config = new PageTemplateConfiguration(); |
21
|
|
|
$config->setPageId(5); |
22
|
|
|
$config->setPageEntityName(PageTemplate::class); |
23
|
|
|
$config->setPageTemplate('string!'); |
24
|
|
|
|
25
|
|
|
$this->assertEquals(5, $config->getPageId()); |
26
|
|
|
$this->assertEquals(PageTemplate::class, $config->getPageEntityName()); |
27
|
|
|
$this->assertEquals('string!', $config->getPageTemplate()); |
28
|
|
|
|
29
|
|
|
$em = $this->getMockBuilder(EntityManager::class) |
30
|
|
|
->disableOriginalConstructor() |
31
|
|
|
->getMock(); |
32
|
|
|
|
33
|
|
|
$repo = $this->getMockBuilder(EntityRepository::class) |
34
|
|
|
->disableOriginalConstructor() |
35
|
|
|
->getMock(); |
36
|
|
|
|
37
|
|
|
$testNode = Stub::makeEmpty(AbstractPage::class); |
38
|
|
|
|
39
|
|
|
$repo->expects($this->any()) |
40
|
|
|
->method('find') |
41
|
|
|
->will($this->returnValue($testNode)); |
42
|
|
|
|
43
|
|
|
$em->expects($this->any()) |
44
|
|
|
->method('getRepository') |
45
|
|
|
->will($this->returnValue($repo)); |
46
|
|
|
|
47
|
|
|
$this->assertInstanceOf(get_class($testNode), $config->getPage($em)); |
|
|
|
|
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
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: