/** * Setup a mock service using Phockito::spy() to mock a basic version of `isAPIAvaiable` * @param boolean $available Can change this to account for when API is unavailable * @return __phockito_FlickrService_Spy */ public function getMockService($available = true) { // setup mock $spy = Phockito::spy('FlickrService'); Phockito::when($spy)->isAPIAvailable()->return($available); return $spy; }
function testSpyingCall() { $spy = Phockito::spy('PhockitoOverloadedCallTest_OverloadedCall'); $this->assertEquals($spy->Foo(), 'Foo'); Phockito::when($spy)->Foo()->return(1); $this->assertEquals($spy->Foo(), 1); Phockito::verify($spy, 2)->Foo(); }
/** * @expectedException RuntimeException */ public function testPostPactFailure() { $http = Phockito::spy('Pact\\HttpClient'); Phockito::when($http)->execute()->return(false); $mockServiceRequests = new MockServiceRequests($http); $pactDetails = ['consumer' => ['name' => 'c'], 'provider' => ['name' => 'p']]; $mockServiceRequests->postPact($pactDetails, 'http://127.0.0.1'); }
public function mockController() { $this->controller = Phockito::spy('Kleinbottle\\tests\\fixtures\\controller'); Phockito::when($this->router)->loadController('controller')->return($this->controller); $this->router->captureOutput(); }
protected function getServiceSpy() { $serviceSpy = Phockito::spy('Solr3Service'); Phockito::when($serviceSpy)->_sendRawPost()->return($this->getFakeRawSolrResponse()); return $serviceSpy; }
public function mockController() { $this->controller = Phockito::spy('Kleinbottle\\tests\\fixtures\\json'); Phockito::when($this->router)->loadController('json')->return($this->controller); }
function testCanSpyAndOverrideUndefinedToString() { $mock = Phockito::spy('PhockitoTostringTest_MockWithoutToString'); Phockito::when($mock)->__toString()->return('NewReturnValue'); $this->assertEquals('NewReturnValue', '' . $mock); }
function testConstructorSupressedWhenDesired() { $spy = Phockito::spy('PhockitoSpiesTest_MockMe', Phockito::DONT_CALL_CONSTRUCTOR); $this->assertFalse($spy->constructor_arg); }