Completed
Pull Request — master (#1333)
by Maksim
04:20
created

testShouldBeSubClassOfEventClass()   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\PersistEvent;
5
use FOS\ElasticaBundle\Persister\Event\PostAsyncInsertObjectsEvent;
6
use FOS\ElasticaBundle\Persister\ObjectPersisterInterface;
7
use FOS\ElasticaBundle\Provider\PagerInterface;
8
use Symfony\Component\EventDispatcher\Event;
9
10
final class PostAsyncInsertObjectsEventTest extends \PHPUnit_Framework_TestCase
11
{
12
    public function testShouldBeSubClassOfEventClass()
13
    {
14
        $rc = new \ReflectionClass(PostAsyncInsertObjectsEvent::class);
15
16
        $this->assertTrue($rc->isSubclassOf(Event::class));
17
    }
18
19
    public function testShouldImplementPersistEventInterface()
20
    {
21
        $rc = new \ReflectionClass(PostAsyncInsertObjectsEvent::class);
22
23
        $this->assertTrue($rc->implementsInterface(PersistEvent::class));
24
    }
25
26
    public function testShouldFinal()
27
    {
28
        $rc = new \ReflectionClass(PostAsyncInsertObjectsEvent::class);
29
30
        $this->assertTrue($rc->isFinal());
31
    }
32
33
    public function testCouldBeConstructedWithPagerAndObjectPersisterAndObjectsCountAndOptions()
34
    {
35
        new PostAsyncInsertObjectsEvent(
36
            $this->createPagerMock(),
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...ctsEvent::__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...
37
            $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...ctsEvent::__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...
38
            123,
39
            $errorMessage = '',
40
            $options = []
41
        );
42
    }
43
44
    public function testShouldAllowGetPagerSetInConstructor()
45
    {
46
        $expectedPager = $this->createPagerMock();
47
48
        $event = new PostAsyncInsertObjectsEvent($expectedPager, $this->createObjectPersisterMock(), 123, '', []);
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...ctsEvent::__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...
49
50
        $this->assertSame($expectedPager, $event->getPager());
51
    }
52
53
    public function testShouldAllowGetObjectPersisterSetInConstructor()
54
    {
55
        $expectedPersister = $this->createObjectPersisterMock();
56
57
        $event = new PostAsyncInsertObjectsEvent($this->createPagerMock(), $expectedPersister, 123, '', []);
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...ctsEvent::__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...
58
59
        $this->assertSame($expectedPersister, $event->getObjectPersister());
60
    }
61
62
    public function testShouldAllowGetOptionsSetInConstructor()
63
    {
64
        $expectedOptions = ['foo' => 'fooVal', 'bar' => 'barVal'];
65
66
        $event = new PostAsyncInsertObjectsEvent($this->createPagerMock(), $this->createObjectPersisterMock(), 123, '', $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...ctsEvent::__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...ctsEvent::__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...
67
68
        $this->assertSame($expectedOptions, $event->getOptions());
69
    }
70
71
    public function testShouldAllowGetObjectsSetInConstructor()
72
    {
73
        $expectedObjectsCount = 321;
74
75
        $event = new PostAsyncInsertObjectsEvent($this->createPagerMock(), $this->createObjectPersisterMock(), $expectedObjectsCount, '', []);
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...ctsEvent::__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...ctsEvent::__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...
76
77
        $this->assertSame($expectedObjectsCount, $event->getObjectsCount());
78
    }
79
80
    public function testShouldAllowGetErrorMessageSetInConstructor()
81
    {
82
        $expectedErrorMessage = 'theErrorMessage';
83
84
        $event = new PostAsyncInsertObjectsEvent($this->createPagerMock(), $this->createObjectPersisterMock(), [], 'theErrorMessage', []);
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...ctsEvent::__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...ctsEvent::__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...
85
86
        $this->assertSame($expectedErrorMessage, $event->getErrorMessage());
87
    }
88
89
    /**
90
     * @return ObjectPersisterInterface|\PHPUnit_Framework_MockObject_MockObject
91
     */
92
    private function createObjectPersisterMock()
93
    {
94
        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...
95
    }
96
97
    /**
98
     * @return PagerInterface|\PHPUnit_Framework_MockObject_MockObject
99
     */
100
    private function createPagerMock()
101
    {
102
        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...
103
    }
104
}
105