Unit testing with MOCK

Unit-testing, integration testing for the code i write is what i prefer most. Either to increase the existing code coverage or at least maintain the existing code coverage is what i thrive for.

Many instance i will use Mock here are few code snippets of how i use them.

class MyClassTest extends \PHPUnit_Framework_TestCase {
    function testMethod() {
      $stub = $this->getMockBuilder('WebServiceRequest')
            ->disableOriginalConstructor()
            ->setMethods(array('getRequest'))
            ->getMock();

      $stub->expects($this->any())
            ->method('getRequest')
            ->will($this->returnValue("foo-bar"));

     $stub->getResult("dummy_url"); // when getRequest() is called will returns 'foo-bar'
    }
}