Пример #1
0
 public function testExec()
 {
     $httpMock = $this->getMock(Http::class, ['setOptions', 'execute', 'close']);
     $response = ['body' => 'text'];
     $httpMock->method('execute')->willReturn(json_encode($response));
     $this->setProperty('http', $httpMock);
     $res = $this->request->exec('http://example.com', 'a=b');
     $this->assertEquals($response, $res);
     $this->request->clearToken();
     $res = $this->request->exec('http://example.com', 'a=b');
     $this->assertEquals($response, $res);
 }
Пример #2
0
 /** @test */
 public function executeRequestToPinterestApi()
 {
     $httpMock = $this->getHttpMock();
     $response = $this->createSuccessApiResponse();
     $httpMock->shouldReceive('execute')->andReturn(json_encode($response));
     $this->setProperty('http', $httpMock);
     $res = $this->request->exec('http://example.com', 'a=b');
     $this->assertEquals($response, $res);
     $this->request->clearToken();
     $res = $this->request->exec('http://example.com', 'a=b');
     $this->assertEquals($response, $res);
 }