/** * @test * @covers Plum\PlumDoctrine\ORM\RepositoryReader::count() */ public function countShouldReturnNumberOfResults() { $result = new stdClass(); $this->repository->shouldReceive('findBy')->andReturn([$result, $result]); $reader = new RepositoryReader($this->repository, ['age' => 29]); $this->assertEquals(2, $reader->count()); }
/** * @param string $repositoryName */ protected function mockRepository($repositoryName) { $this->repository = \Mockery::mock($repositoryName)->shouldDeferMissing()->shouldAllowMockingProtectedMethods(); $this->mockRepositoryCommands(); $this->repository->shouldReceive('getRepository')->andReturnSelf(); $this->repository->shouldReceive('getEntityManager')->withNoArgs()->andReturnSelf(); $this->repository->shouldReceive('createQuery')->withAnyArgs()->andReturnSelf(); }
/** @test */ public function getIdentity_shouldReturnTheUserCorrespondingToTheAccessToken_inQuery() { $this->oauthRequest->query['access_token'] = 'at123'; $this->oauthServer->shouldReceive('getAccessTokenData')->with($this->oauthRequest)->andReturn(['user_id' => 'jimmy']); $identity = M::mock('\\Aeris\\ZfAuth\\Identity\\IdentityInterface'); $this->identityRepository->shouldReceive('findByUsername')->with('jimmy')->andReturn($identity); $this->assertSame($identity, $this->identityProvider->getIdentity()); }