function it_counts_without_organization_id(CountProjectsQuery $query, ProjectRepository $repository) { $query->name()->shouldBeCalled()->willReturn('organization name'); $query->organizationId()->shouldBeCalled()->willReturn(null); $query->userId()->shouldBeCalled()->willReturn('user-id'); $repository->count(Argument::any())->shouldBeCalled()->willReturn(3); $this->__invoke($query)->shouldReturn(3); }
public function __invoke(CountProjectsQuery $query) { return $this->repository->count($this->specificationFactory->buildFilterableSpecification(UserId::generate($query->userId()), null === $query->organizationId() ? null : OrganizationId::generate($query->organizationId()), null === $query->name() ? null : new ProjectName($query->name()))); }