public function testGetValueFromFieldDescriptionWithNoValueExceptionNewAdminInstance() { $object = new \stdClass(); $fieldDescription = $this->getMock('Sonata\\AdminBundle\\Admin\\FieldDescriptionInterface'); $fieldDescription->expects($this->any())->method('getValue')->will($this->returnCallback(function () { throw new NoValueException(); })); $fieldDescription->expects($this->any())->method('getAssociationAdmin')->will($this->returnValue($this->admin)); $this->admin->expects($this->once())->method('getNewInstance')->will($this->returnValue('foo')); $this->assertSame('foo', $this->twigExtension->getValueFromFieldDescription($object, $fieldDescription)); }