JSONDecoderTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 51
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetData() 0 23 1
A testGetData_InvalidSyntax() 0 14 1
1
<?php
2
3
namespace Wambo\Core\Storage;
4
5
/**
6
 * Class JSONDecoderTest
7
 *
8
 * @package Wambo\Core\Storage
9
 */
10
class JSONDecoderTest extends \PHPUnit_Framework_TestCase
11
{
12
13
    /**
14
     * @test
15
     */
16
    public function testGetData()
17
    {
18
        // arrange
19
        $jsonDecoder = new JSONDecoder();
20
        $json = <<<JSON
21
{
22
  "foo": "bar",
23
  "key": "value",
24
  "multi": {"is": true}
25
}
26
JSON;
27
        $data = array(
28
            'foo' => 'bar',
29
            'key' => 'value',
30
            'multi' => array('is' => true)
31
        );
32
33
        // act
34
        $decodedJSONData = $jsonDecoder->getData($json);
35
36
        // assert
37
        $this->assertEquals($decodedJSONData, $data);
38
    }
39
40
    /**
41
     * Test broken json
42
     *
43
     * @test
44
     * @expectedException \Wambo\Core\Storage\Exception\RuntimeException
45
     */
46
    public function testGetData_InvalidSyntax()
47
    {
48
        // arrange
49
        $jsonDecoder = new JSONDecoder();
50
        $json = <<<JSON
51
{
52
  "foo", "bar"
53
}
54
JSON;
55
56
        // act
57
        $jsonDecoder->getData($json);
58
59
    }
60
}
61