function mockV2Url($path, $params = null) { if (!method_exists(Config::getFactory(), 'shouldReceive')) { return; } // mocking in php is pain in the arxx if ($params === null) { $url = m::mock('Hypercharge\\v2\\Url[getUrl]', array('sandbox', $path)); $url->shouldReceive('getUrl')->andReturn($this->credentials->gatewayHost . '/v2'); Config::getFactory()->shouldReceive('createUrl')->with($path)->andReturn($url); } else { $url = m::mock('Hypercharge\\v2\\Url[getUrl]', array('sandbox', $path, $params)); $url->shouldReceive('getUrl')->andReturn($this->credentials->gatewayHost . '/v2'); Config::getFactory()->shouldReceive('createUrl')->with($path, $params)->andReturn($url); } }