Exemplo n.º 1
0
 function it_builds_an_entity_resource(\LaraPackage\Api\Contracts\Resource\Entity $entity, FractalFactory $fractalFactory, \LaraPackage\Api\Contracts\Factory\VersionFactory $versionFactory, \LaraPackage\Api\Contracts\Entity\Transformer\Transformer $transformer, Fractal\Resource\Item $item, Fractal\Manager $manager, Fractal\Scope $scope)
 {
     $expected = ['test'];
     $entityData = new \ArrayIterator(['test']);
     $entity->getData()->shouldBeCalled()->willReturn($entityData);
     $fractalFactory->createEntity($entityData, $transformer)->shouldBeCalled()->willReturn($item);
     $this->setPayloadAssertions($fractalFactory, $item, $manager, $scope, $entityData);
     $this->entity($entity, $transformer);
     $this->getIterator()->getArrayCopy()->shouldReturn($expected);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function entity(\LaraPackage\Api\Contracts\Resource\Entity $entity, \LaraPackage\Api\Contracts\Entity\Transformer\Transformer $transformer)
 {
     $resource = $this->fractalFactory->createEntity($entity->getData(), $transformer);
     $this->setPayload($resource);
 }