/**
  * Test rendering a block that throws an exception.
  */
 public function testRenderBlockWithException()
 {
     // GIVEN
     // mock a block service that throws an user exception
     $service = $this->getMock('Sonata\\BlockBundle\\Block\\BlockServiceInterface');
     $service->expects($this->once())->method('load');
     $exception = $this->getMock('\\Exception');
     $service->expects($this->once())->method('execute')->will($this->returnCallback(function () use($exception) {
         throw $exception;
     }));
     $this->blockServiceManager->expects($this->once())->method('get')->will($this->returnValue($service));
     // mock the exception strategy manager to return a response when given the correct exception
     $response = $this->getMock('Symfony\\Component\\HttpFoundation\\Response');
     $this->exceptionStrategyManager->expects($this->once())->method('handleException')->with($this->equalTo($exception))->will($this->returnValue($response));
     // mock the logger to ensure a crit message is logged
     $this->logger->expects($this->once())->method('critical');
     // mock a block object
     $block = $this->getMock('Sonata\\BlockBundle\\Model\\BlockInterface');
     $blockContext = new BlockContext($block);
     // WHEN
     $result = $this->renderer->render($blockContext);
     // THEN
     $this->assertEquals($response, $result, 'Should return the response provider by the exception manager');
 }