Completed
Push — master ( 1de9b7...830752 )
by Kristof
38:46 queued 24:09
created

unit/Entity/PageTemplateConfigurationTest.php (1 issue)

Upgrade to new PHP Analysis Engine

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 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));
0 ignored issues
show
$em is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Doctrine\ORM\EntityManager>.

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
    }
49
}
50