public function testHistoryViewRevisionAction() { $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; $reader->expects($this->once())->method('find')->with($this->equalTo('Foo'), $this->equalTo(123), $this->equalTo(456))->will($this->returnValue($objectRevision)); $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->historyViewRevisionAction(123, 456)); $this->assertSame($this->admin, $this->parameters['admin']); $this->assertSame('SonataAdminBundle::standard_layout.html.twig', $this->parameters['base_template']); $this->assertSame($this->pool, $this->parameters['admin_pool']); $this->assertSame('show', $this->parameters['action']); $this->assertSame($objectRevision, $this->parameters['object']); $this->assertSame($fieldDescriptionCollection, $this->parameters['elements']); $this->assertSame(array(), $this->session->getFlashBag()->all()); $this->assertSame('SonataAdminBundle:CRUD:show.html.twig', $this->template); }