| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 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 | } |
||
| 51 |