Completed
Push — master ( f1a3d7...431755 )
by Matt
07:09
created

ItemTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetData() 6 6 1
A testGetTransformer() 11 11 1
A testSetResourceKey() 6 6 1
A testGetResourceKey() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
Duplication introduced by
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