Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RepositoryControllerTest extends \PHPUnit_Framework_TestCase
- {
- function tearDown()
- {
- \Mockery::close();
- }
- public function testGetAllAction()
- {
- $request = \Mockery::mock( 'Symfony\Component\HttpFoundation\Request' );
- $app = \Mockery::mock( 'Silex\Application' );
- $expected_results = [ ]; // you know this
- $db = \Mockery::mock( '\Doctrine\Common\Persistence\ObjectManager' );
- $db->shouldReceive( 'getRepository->createQueryBuilder->setFirstResult->setMaxResults->getQuery->getResult' )
- ->andReturn( $expected_results );
- // in RepositoryController use $app->offsetGet('em') instead of $app['em'];
- $app->shouldReceive( 'offsetGet' )->with( 'em' )->andReturn( $db );
- $controller = new RepositoryController( $request, $app );
- $this->assertSame( json_encode( $expected_results ), $controller->getAllAction() );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement