Completed
Push — master ( 6bc3b4...34ca55 )
by Ralf
15s queued 11s
created

SmartSerializerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4
1
<?php
2
/**
3
 * User: zach
4
 * Date: 6/20/13
5
 * Time: 9:07 AM
6
 */
7
8
namespace Elasticsearch\Tests\Serializers;
9
10
use Elasticsearch\Serializers\SmartSerializer;
11
use PHPUnit_Framework_TestCase;
12
13
/**
14
 * Class SmartSerializerTest
15
 * @package Elasticsearch\Tests\Serializers
16
 */
17
class SmartSerializerTest extends PHPUnit_Framework_TestCase
18
{
19
    private $serializer;
20
21
    public function testDeserializeWithNonJsonContentTypeReturnsRawDataString()
22
    {
23
        $body = '<some-tag>content</some-tag>';
24
25
        $result = $this->serializer->deserialize($body, array('content_type' => 'application/xml'));
26
27
        $this->assertEquals($body, $result);
28
    }
29
30
    public function testDeserializeWithJsonContentTypeReturnsDecodedJson()
31
    {
32
        $result = $this->serializer->deserialize('{"one": "two"}', array('content_type' => 'application/json'));
33
34
        $this->assertInternalType('array', $result);
35
        $this->assertArrayHasKeY('one', $result);
36
    }
37
38
    public function testDeserializeWithoutContentTypeReturnsDecodedJson()
39
    {
40
        $result = $this->serializer->deserialize('{"one": "two"}', array());
41
42
        $this->assertInternalType('array', $result);
43
        $this->assertArrayHasKeY('one', $result);
44
    }
45
46
    protected function setUp()
47
    {
48
        $this->serializer = new SmartSerializer();
49
    }
50
}
51