Completed
Push — master ( e03925...d40975 )
by Matt
17s queued 12s
created

test/Resource/ItemTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php namespace League\Fractal\Test\Resource;
2
3
use League\Fractal\Resource\Item;
4
use Mockery;
5
use PHPUnit\Framework\TestCase;
6
7 View Code Duplication
class ItemTest extends TestCase
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    protected $simpleItem = ['foo' => 'bar'];
10
11
    public function testGetData()
12
    {
13
        $item = new Item($this->simpleItem, function () {});
14
15
        $this->assertSame($item->getData(), $this->simpleItem);
16
    }
17
18
    public function testGetTransformer()
19
    {
20
        $item = new Item($this->simpleItem, function () {});
21
22
        $this->assertTrue(is_callable($item->getTransformer()));
23
24
        $transformer = 'thismightbeacallablestring';
25
        $item = new Item($this->simpleItem, $transformer);
26
27
        $this->assertSame($item->getTransformer(), $transformer);
28
    }
29
30
    /**
31
     * @covers \League\Fractal\Resource\Item::setResourceKey
32
     */
33
    public function testSetResourceKey()
34
    {
35
        $item = Mockery::mock('League\Fractal\Resource\Item')->makePartial();
36
37
        $this->assertSame($item, $item->setResourceKey('foo'));
38
    }
39
40
    /**
41
     * @covers \League\Fractal\Resource\Item::getResourceKey
42
     */
43
    public function testGetResourceKey()
44
    {
45
        $item = Mockery::mock('League\Fractal\Resource\Item')->makePartial();
46
        $item->setResourceKey('foo');
47
48
        $this->assertSame('foo', $item->getResourceKey());
49
    }
50
}
51