Completed
Push — master ( f57fd0...cd9d30 )
by Karel
12:21 queued 02:25
created

CallbackTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 3
c 4
b 0
f 1
lcom 1
cbo 3
dl 0
loc 33
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSerializerMustHaveSerializeMethod() 0 6 1
A testSetGroupsWorksWithValidSerializer() 0 8 1
A testSetGroupsFailsWithInvalidSerializer() 0 14 1
1
<?php
2
3
use \FOS\ElasticaBundle\Serializer\Callback;
4
5
class CallbackTest extends PHPUnit_Framework_TestCase
6
{
7
    public function testSerializerMustHaveSerializeMethod()
8
    {
9
        $callback = new Callback();
10
        $this->setExpectedException('RuntimeException', 'The serializer must have a "serialize" method.');
11
        $callback->setSerializer(new \stdClass());
12
    }
13
14
    public function testSetGroupsWorksWithValidSerializer()
15
    {
16
        $callback = new Callback();
17
        $serializer = $this->getMock('Symfony\Component\Serializer\Serializer', array(), array(), '', false);
18
        $callback->setSerializer($serializer);
19
20
        $callback->setGroups(array('foo'));
21
    }
22
23
    public function testSetGroupsFailsWithInvalidSerializer()
24
    {
25
        $callback = new Callback();
26
        $serializer = $this->getMockBuilder('FakeSerializer')->setMethods(array('serialize'))->getMock();
27
        $callback->setSerializer($serializer);
28
29
        $this->setExpectedException(
30
            'RuntimeException',
31
            'Setting serialization groups requires using "JMS\Serializer\Serializer" or '
32
                . '"Symfony\Component\Serializer\Serializer"'
33
        );
34
35
        $callback->setGroups(array('foo'));
36
    }
37
}
38