You can archive it using partially Mock Objects: you can only make fun of a specific method of your class and execute (and test) another method.
Further link here
As an example, suppose your modified class:
<?php namespace Acme\DemoBundle\Service; class MyClass { public function myMethod() { $request = 'http://domain.com'; $response = $this->someMethodUsingGlobals($request);
You can test the following class of tests:
<?php namespace Acme\DemoBundle\Tests; class MyProjectTest extends \PHPUnit_Framework_TestCase { public function test_it_does_something_with_the_response() { $sut = $this->getMock('Acme\DemoBundle\Service\MyClass', array('someMethodUsingGlobals') );
Thus, the someMethodUsingGlobals method is not executed and returns the values โโdefined in the layout definition. The myMethod method myMethod executed and processed using a mock function.
Hope for this help
source share