| @@ 7-50 (lines=44) @@ | ||
| 4 | use Mockery; |
|
| 5 | use PHPUnit\Framework\TestCase; |
|
| 6 | ||
| 7 | class ItemTest extends TestCase |
|
| 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 | ||
| @@ 7-50 (lines=44) @@ | ||
| 4 | use Mockery; |
|
| 5 | use PHPUnit\Framework\TestCase; |
|
| 6 | ||
| 7 | class PrimitiveTest extends TestCase |
|
| 8 | { |
|
| 9 | protected $simplePrimitive = 'sample string'; |
|
| 10 | ||
| 11 | public function testGetData() |
|
| 12 | { |
|
| 13 | $primitive = new Primitive($this->simplePrimitive); |
|
| 14 | ||
| 15 | $this->assertSame($primitive->getData(), $this->simplePrimitive); |
|
| 16 | } |
|
| 17 | ||
| 18 | public function testGetTransformer() |
|
| 19 | { |
|
| 20 | $primitive = new Primitive($this->simplePrimitive, function () {}); |
|
| 21 | ||
| 22 | $this->assertTrue(is_callable($primitive->getTransformer())); |
|
| 23 | ||
| 24 | $transformer = 'thismightbeacallablestring'; |
|
| 25 | $primitive = new Primitive($this->simplePrimitive, $transformer); |
|
| 26 | ||
| 27 | $this->assertSame($primitive->getTransformer(), $transformer); |
|
| 28 | } |
|
| 29 | ||
| 30 | /** |
|
| 31 | * @covers \League\Fractal\Resource\Primitive::setResourceKey |
|
| 32 | */ |
|
| 33 | public function testSetResourceKey() |
|
| 34 | { |
|
| 35 | $primitive = Mockery::mock('League\Fractal\Resource\Primitive')->makePartial(); |
|
| 36 | ||
| 37 | $this->assertSame($primitive, $primitive->setResourceKey('foo')); |
|
| 38 | } |
|
| 39 | ||
| 40 | /** |
|
| 41 | * @covers \League\Fractal\Resource\Primitive::getResourceKey |
|
| 42 | */ |
|
| 43 | public function testGetResourceKey() |
|
| 44 | { |
|
| 45 | $primitive = Mockery::mock('League\Fractal\Resource\Primitive')->makePartial(); |
|
| 46 | $primitive->setResourceKey('foo'); |
|
| 47 | ||
| 48 | $this->assertSame('foo', $primitive->getResourceKey()); |
|
| 49 | } |
|
| 50 | } |
|
| 51 | ||