Completed
Push — master ( 4e4cd8...063296 )
by Maksim
16s
created

PostPersistEventTest::testShouldFinal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace FOS\ElasticaBundle\Tests\Persister\Event;
3
4
use FOS\ElasticaBundle\Persister\Event\PostPersistEvent;
5
use FOS\ElasticaBundle\Persister\ObjectPersisterInterface;
6
use FOS\ElasticaBundle\Provider\PagerInterface;
7
use Symfony\Component\EventDispatcher\Event;
8
9
final class PostPersistEventTest extends \PHPUnit_Framework_TestCase
10
{
11
    public function testShouldBeSubClassOfEventClass()
12
    {
13
        $rc = new \ReflectionClass(PostPersistEvent::class);
14
15
        $this->assertTrue($rc->isSubclassOf(Event::class));
16
    }
17
18
    public function testShouldFinal()
19
    {
20
        $rc = new \ReflectionClass(PostPersistEvent::class);
21
22
        $this->assertTrue($rc->isFinal());
23
    }
24
25
    public function testCouldBeConstructedWithPagerAndObjectPersisterAndOptions()
26
    {
27
        new PostPersistEvent($this->createPagerMock(), $this->createObjectPersisterMock(), []);
0 ignored issues
show
Bug introduced by
It seems like $this->createPagerMock() targeting FOS\ElasticaBundle\Tests...Test::createPagerMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, FOS\ElasticaBundle\Persi...istEvent::__construct() does only seem to accept object<FOS\ElasticaBundl...rovider\PagerInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Bug introduced by
It seems like $this->createObjectPersisterMock() targeting FOS\ElasticaBundle\Tests...teObjectPersisterMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, FOS\ElasticaBundle\Persi...istEvent::__construct() does only seem to accept object<FOS\ElasticaBundl...jectPersisterInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
28
    }
29
30
    public function testShouldAllowGetPagerSetInConstructor()
31
    {
32
        $expectedPager = $this->createPagerMock();
33
34
        $event = new PostPersistEvent($expectedPager, $this->createObjectPersisterMock(), []);
0 ignored issues
show
Bug introduced by
It seems like $this->createObjectPersisterMock() targeting FOS\ElasticaBundle\Tests...teObjectPersisterMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, FOS\ElasticaBundle\Persi...istEvent::__construct() does only seem to accept object<FOS\ElasticaBundl...jectPersisterInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
35
36
        $this->assertSame($expectedPager, $event->getPager());
37
    }
38
39
    public function testShouldAllowGetObjectPersisterSetInConstructor()
40
    {
41
        $expectedPersister = $this->createObjectPersisterMock();
42
43
        $event = new PostPersistEvent($this->createPagerMock(), $expectedPersister, []);
0 ignored issues
show
Bug introduced by
It seems like $this->createPagerMock() targeting FOS\ElasticaBundle\Tests...Test::createPagerMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, FOS\ElasticaBundle\Persi...istEvent::__construct() does only seem to accept object<FOS\ElasticaBundl...rovider\PagerInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
44
45
        $this->assertSame($expectedPersister, $event->getObjectPersister());
46
    }
47
48
    public function testShouldAllowGetOptionsSetInConstructor()
49
    {
50
        $expectedOptions = ['foo' => 'fooVal', 'bar' => 'barVal'];
51
52
        $event = new PostPersistEvent($this->createPagerMock(), $this->createObjectPersisterMock(), $expectedOptions);
0 ignored issues
show
Bug introduced by
It seems like $this->createPagerMock() targeting FOS\ElasticaBundle\Tests...Test::createPagerMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, FOS\ElasticaBundle\Persi...istEvent::__construct() does only seem to accept object<FOS\ElasticaBundl...rovider\PagerInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Bug introduced by
It seems like $this->createObjectPersisterMock() targeting FOS\ElasticaBundle\Tests...teObjectPersisterMock() can also be of type object<PHPUnit_Framework_MockObject_MockObject>; however, FOS\ElasticaBundle\Persi...istEvent::__construct() does only seem to accept object<FOS\ElasticaBundl...jectPersisterInterface>, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
53
54
        $this->assertSame($expectedOptions, $event->getOptions());
55
    }
56
57
    /**
58
     * @return ObjectPersisterInterface|\PHPUnit_Framework_MockObject_MockObject
59
     */
60
    private function createObjectPersisterMock()
61
    {
62
        return $this->getMock(ObjectPersisterInterface::class, [], [], '', false);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0; use createMock() or getMockBuilder() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
63
    }
64
65
    /**
66
     * @return PagerInterface|\PHPUnit_Framework_MockObject_MockObject
67
     */
68
    private function createPagerMock()
69
    {
70
        return $this->getMock(PagerInterface::class, [], [], '', false);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0; use createMock() or getMockBuilder() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
71
    }
72
}
73