Ejemplo n.º 1
0
 public function __invoke(FilterOrganizationsQuery $query)
 {
     $organizations = $this->repository->query($this->specificationFactory->buildFilterableSpecification($query->name(), UserId::generate($query->userId()), $query->offset(), $query->limit()));
     return array_map(function (Organization $organization) {
         $this->dataTransformer->write($organization);
         return $this->dataTransformer->read();
     }, $organizations);
 }
Ejemplo n.º 2
0
 function it_serializes_filtered_organizations(FilterOrganizationsQuery $query, OrganizationRepository $repository, Organization $organization, OrganizationDataTransformer $dataTransformer)
 {
     $query->userId()->shouldBeCalled()->willReturn('user-id');
     $query->name()->shouldBeCalled()->willReturn('organization name');
     $query->offset()->shouldBeCalled()->willReturn(0);
     $query->limit()->shouldBeCalled()->willReturn(-1);
     $repository->query(Argument::any())->shouldBeCalled()->willReturn([$organization]);
     $dataTransformer->write($organization)->shouldBeCalled();
     $dataTransformer->read()->shouldBeCalled();
     $this->__invoke($query)->shouldBeArray();
 }