public function testGetReaderWithException()
 {
     $this->setExpectedException('\\RuntimeException', 'The class "Foo\\Foo" does not have any reader manager');
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface');
     $auditManager = new AuditManager($container);
     $auditManager->getReader('Foo\\Foo');
 }
 public function testhistoryCompareRevisionsActionAction()
 {
     $this->request->query->set('id', 123);
     $this->admin->expects($this->once())->method('isGranted')->with($this->equalTo('EDIT'))->will($this->returnValue(true));
     $object = new \stdClass();
     $this->admin->expects($this->once())->method('getObject')->will($this->returnValue($object));
     $this->admin->expects($this->any())->method('getClass')->will($this->returnValue('Foo'));
     $this->auditManager->expects($this->once())->method('hasReader')->with($this->equalTo('Foo'))->will($this->returnValue(true));
     $reader = $this->getMock('Sonata\\AdminBundle\\Model\\AuditReaderInterface');
     $this->auditManager->expects($this->once())->method('getReader')->with($this->equalTo('Foo'))->will($this->returnValue($reader));
     $objectRevision = new \stdClass();
     $objectRevision->revision = 456;
     $compareObjectRevision = new \stdClass();
     $compareObjectRevision->revision = 789;
     $reader->expects($this->at(0))->method('find')->with($this->equalTo('Foo'), $this->equalTo(123), $this->equalTo(456))->will($this->returnValue($objectRevision));
     $reader->expects($this->at(1))->method('find')->with($this->equalTo('Foo'), $this->equalTo(123), $this->equalTo(789))->will($this->returnValue($compareObjectRevision));
     $this->admin->expects($this->once())->method('setSubject')->with($this->equalTo($objectRevision))->will($this->returnValue(null));
     $fieldDescriptionCollection = new FieldDescriptionCollection();
     $this->admin->expects($this->once())->method('getShow')->will($this->returnValue($fieldDescriptionCollection));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $this->controller->historyCompareRevisionsAction(123, 456, 789, $this->request));
     $this->assertEquals($this->admin, $this->parameters['admin']);
     $this->assertEquals('SonataAdminBundle::standard_layout.html.twig', $this->parameters['base_template']);
     $this->assertEquals($this->pool, $this->parameters['admin_pool']);
     $this->assertEquals('show', $this->parameters['action']);
     $this->assertEquals($objectRevision, $this->parameters['object']);
     $this->assertEquals($compareObjectRevision, $this->parameters['object_compare']);
     $this->assertEquals($fieldDescriptionCollection, $this->parameters['elements']);
     $this->assertEquals(array(), $this->session->getFlashBag()->all());
     $this->assertEquals('SonataAdminBundle:CRUD:show_compare.html.twig', $this->template);
 }