|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace IBM\Watson\Common\Tests; |
|
4
|
|
|
|
|
5
|
|
|
use Mockery as m; |
|
6
|
|
|
use IBM\Watson\Common\stubs\Api; |
|
7
|
|
|
use Psr\Http\Message\RequestInterface; |
|
8
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
9
|
|
|
|
|
10
|
|
|
class ApiTest extends AbstractTestCase |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* @var \IBM\Watson\Common\Api\ApiInterface |
|
14
|
|
|
*/ |
|
15
|
|
|
private $api; |
|
16
|
|
|
|
|
17
|
|
|
public function setUp() |
|
18
|
|
|
{ |
|
19
|
|
|
parent::setUp(); |
|
20
|
|
|
|
|
21
|
|
|
$this->api = new Api($this->httpClient, $this->requestBuilder); |
|
22
|
|
|
|
|
23
|
|
|
$this->requestBuilder |
|
|
|
|
|
|
24
|
|
|
->shouldReceive('create') |
|
25
|
|
|
->once() |
|
26
|
|
|
->andReturn(m::mock(RequestInterface::class)); |
|
27
|
|
|
|
|
28
|
|
|
$this->httpClient |
|
|
|
|
|
|
29
|
|
|
->shouldReceive('sendRequest') |
|
30
|
|
|
->once() |
|
31
|
|
|
->andReturn(m::mock(ResponseInterface::class)); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testGet() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodGet()); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testHead() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodHead()); |
|
|
|
|
|
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testTrace() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodTrace()); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function testPost() |
|
50
|
|
|
{ |
|
51
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodPost()); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testPut() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodPut()); |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testPatch() |
|
60
|
|
|
{ |
|
61
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodPatch()); |
|
|
|
|
|
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function testDelete() |
|
65
|
|
|
{ |
|
66
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodDelete()); |
|
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function testOptions() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->assertInstanceOf(ResponseInterface::class, $this->api->httpMethodOptions()); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.