Completed
Pull Request — master (#1131)
by Karel
14:41 queued 09:35
created

testSetGroupsFailsWithInvalidSerializer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace FOS\ElasticaBundle\Tests\Serializer;
4
5
use FOS\ElasticaBundle\Serializer\Callback;
6
7
class CallbackTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testSerializerMustHaveSerializeMethod()
10
    {
11
        $callback = new Callback();
12
        $this->setExpectedException('RuntimeException', 'The serializer must have a "serialize" method.');
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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...
13
        $callback->setSerializer(new \stdClass());
14
    }
15
16
    public function testSetGroupsWorksWithValidSerializer()
17
    {
18
        $callback = new Callback();
19
        $serializer = $this->getMockBuilder('Symfony\Component\Serializer\Serializer')->disableOriginalConstructor()->getMock();
20
        $callback->setSerializer($serializer);
21
22
        $callback->setGroups(array('foo'));
23
    }
24
25
    public function testSetGroupsFailsWithInvalidSerializer()
26
    {
27
        $callback = new Callback();
28
        $serializer = $this->getMockBuilder('FakeSerializer')->setMethods(array('serialize'))->getMock();
29
        $callback->setSerializer($serializer);
30
31
        $this->setExpectedException(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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...
32
            'RuntimeException',
33
            'Setting serialization groups requires using "JMS\Serializer\Serializer" or '
34
                . '"Symfony\Component\Serializer\Serializer"'
35
        );
36
37
        $callback->setGroups(array('foo'));
38
    }
39
}
40