/** * @expectedException Sonata\AdminBundle\Exception\NoValueException */ public function testGetValueWhenCannotRetrieve() { $mockedObject = $this->getMock('MockedTestObject', array('myMethod')); $mockedObject->expects($this->never())->method('myMethod')->will($this->returnValue('myMethodValue')); $field = new FieldDescription(); $this->assertEquals($field->getValue($mockedObject), 'myMethodValue'); }