public function __invoke(FilterProjectsQuery $query) { $organizations = $this->repository->query($this->specificationFactory->buildFilterableSpecification(UserId::generate($query->userId()), null === $query->organizationId() ? null : OrganizationId::generate($query->organizationId()), null === $query->name() ? null : new ProjectName($query->name()), $query->offset(), $query->limit())); return array_map(function (Project $organization) { $this->dataTransformer->write($organization); return $this->dataTransformer->read(); }, $organizations); }
function it_serializes_filtered_projects_without_project_name(FilterProjectsQuery $query, ProjectRepository $repository, Project $project, ProjectDataTransformer $dataTransformer) { $query->userId()->shouldBeCalled()->willReturn('user-id'); $query->organizationId()->shouldBeCalled()->willReturn('organization-id'); $query->name()->shouldBeCalled()->willReturn(null); $query->offset()->shouldBeCalled()->willReturn(0); $query->limit()->shouldBeCalled()->willReturn(-1); $repository->query(Argument::any())->shouldBeCalled()->willReturn([$project]); $dataTransformer->write($project)->shouldBeCalled(); $dataTransformer->read()->shouldBeCalled(); $this->__invoke($query)->shouldBeArray(); }