Completed
Push — master ( d43734...ab0406 )
by Tomasz
03:38
created

FormatTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 23
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testArrayUnserializeInvalidTypeException() 0 6 1
A testMissingUnserializationHandlerException() 0 6 1
A testJsonEncodeSerializationFailureException() 0 6 1
1
<?php
2
namespace Thunder\Serializard\Tests;
3
4
use Thunder\Serializard\Format\ArrayFormat;
5
use Thunder\Serializard\Format\JsonFormat;
6
use Thunder\Serializard\HydratorContainer\FallbackHydratorContainer;
7
use Thunder\Serializard\NormalizerContainer\FallbackNormalizerContainer;
8
9
/**
10
 * @author Tomasz Kowalczyk <[email protected]>
11
 */
12
class FormatTest extends \PHPUnit_Framework_TestCase
13
{
14
    public function testArrayUnserializeInvalidTypeException()
15
    {
16
        $format = new ArrayFormat();
17
        $this->setExpectedException('RuntimeException');
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; use expectException() 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...
18
        $format->unserialize(new \stdClass(), 'stdClass', new FallbackHydratorContainer());
19
    }
20
21
    public function testMissingUnserializationHandlerException()
22
    {
23
        $format = new ArrayFormat();
24
        $this->setExpectedException('RuntimeException');
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; use expectException() 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...
25
        $format->unserialize(array(), 'stdClass', new FallbackHydratorContainer());
26
    }
27
28
    public function testJsonEncodeSerializationFailureException()
29
    {
30
        $format = new JsonFormat();
31
        $this->setExpectedException('RuntimeException'); // Inf and NaN cannot be JSON encoded
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; use expectException() 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...
32
        $this->assertSame(INF, $format->serialize(INF, new FallbackNormalizerContainer()));
33
    }
34
}
35