Completed
Pull Request — master (#309)
by
unknown
03:02
created

ItemTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetData() 0 6 1
A testGetTransformer() 0 11 1
A testSetResourceKey() 0 6 1
A testGetResourceKey() 0 7 1
1
<?php namespace League\Fractal\Test;
2
3
use League\Fractal\Resource\Item;
4
use Mockery;
5
6
class ItemTest extends \PHPUnit_Framework_TestCase
7
{
8
    protected $simpleItem = ['foo' => 'bar'];
9
10
    public function testGetData()
11
    {
12
        $item = new Item($this->simpleItem, function () {});
13
14
        $this->assertSame($item->getData(), $this->simpleItem);
15
    }
16
17
    public function testGetTransformer()
18
    {
19
        $item = new Item($this->simpleItem, function () {});
20
21
        $this->assertTrue(is_callable($item->getTransformer()));
22
23
        $transformer = 'thismightbeacallablestring';
24
        $item = new Item($this->simpleItem, $transformer);
25
26
        $this->assertSame($item->getTransformer(), $transformer);
27
    }
28
29
    /**
30
     * @covers League\Fractal\Resource\Item::setResourceKey
31
     */
32
    public function testSetResourceKey()
33
    {
34
        $item = Mockery::mock('League\Fractal\Resource\Item')->makePartial();
35
36
        $this->assertSame($item, $item->setResourceKey('foo'));
37
    }
38
39
    /**
40
     * @covers League\Fractal\Resource\Item::getResourceKey
41
     */
42
    public function testGetResourceKey()
43
    {
44
        $item = Mockery::mock('League\Fractal\Resource\Item')->makePartial();
45
        $item->setResourceKey('foo');
46
47
        $this->assertSame('foo', $item->getResourceKey());
48
    }
49
}
50