Completed
Push — master ( 06c1ce...67d37c )
by Jeroen
06:20
created

Tests/unit/Services/RepositoryResolverTest.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\VotingBundle\Tests\Services;
4
5
use Kunstmaan\VotingBundle\Services\RepositoryResolver;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * Unit test for repository resolver
10
 */
11
class RepositoryResolverTest extends TestCase
12
{
13
    /**
14
     * @dataProvider dataRepositoryEvent
15
     */
16
    public function testGetRepositoryForEvent($event, $repositoryname)
17
    {
18
        $mockEm = $this->createMock('Doctrine\ORM\EntityManager');
19
20
        $mockEm->expects($this->once())
21
                 ->method('getRepository')
22
                 ->with($this->equalTo($repositoryname));
23
24
        $resolver = new RepositoryResolver($mockEm);
0 ignored issues
show
$mockEm 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...
25
26
        $resolver->getRepositoryForEvent($event);
27
    }
28
29
    public function dataRepositoryEvent()
30
    {
31
        return array(
32
            array($this->createMock('\Kunstmaan\VotingBundle\Event\UpDown\DownVoteEvent'), 'Kunstmaan\VotingBundle\Entity\UpDown\DownVote'),
33
            array($this->createMock('\Kunstmaan\VotingBundle\Event\UpDown\UpVoteEvent'), 'Kunstmaan\VotingBundle\Entity\UpDown\UpVote'),
34
            array($this->createMock('\Kunstmaan\VotingBundle\Event\Facebook\FacebookLikeEvent'), 'Kunstmaan\VotingBundle\Entity\Facebook\FacebookLike'),
35
            array($this->createMock('\Kunstmaan\VotingBundle\Event\Facebook\FacebookSendEvent'), 'Kunstmaan\VotingBundle\Entity\Facebook\FacebookSend'),
36
            array($this->createMock('\Kunstmaan\VotingBundle\Event\LinkedIn\LinkedInShareEvent'), 'Kunstmaan\VotingBundle\Entity\LinkedIn\LinkedInShare'),
37
        );
38
    }
39
}
40