Completed
Push — develop ( c8d2e9...9b1d71 )
by Adam
03:00
created

ArrayHydratorSpec   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 4 1
A it_should_hydrate_response() 0 12 1
1
<?php
2
3
namespace spec\IBM\Watson\Common\Hydrator;
4
5
use IBM\Watson\Common\Hydrator\ArrayHydrator;
6
use PhpSpec\ObjectBehavior;
7
use Mockery as m;
8
use Psr\Http\Message\ResponseInterface;
9
use Psr\Http\Message\StreamInterface;
10
11
class ArrayHydratorSpec extends ObjectBehavior
12
{
13
    function it_is_initializable()
14
    {
15
        $this->shouldHaveType(ArrayHydrator::class);
16
    }
17
18
    function it_should_hydrate_response()
19
    {
20
        $stream = m::mock(StreamInterface::class);
21
        $stream->shouldReceive('__toString')->once()->andReturn('{"param": "value","param2": 99}');
22
23
        $response = m::mock(ResponseInterface::class);
24
        $response->shouldReceive('getHeaderLine')->with('Content-Type')->andReturn('application/json');
25
        $response->shouldReceive('getBody')->andReturn($stream);
26
27
        $hydrated = $this->hydrate($response);
28
        $hydrated->shouldBeArray();
29
    }
30
}
31