Skip to content

Commit

Permalink
Merge pull request #4 from jdecool/fix-tests
Browse files Browse the repository at this point in the history
Fix test after merge branch 0.1-dev into master
  • Loading branch information
jdecool authored Aug 1, 2019
2 parents 4a3c24f + ffeaff4 commit bf9fb78
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ php:
- 7.1
- 7.2
- 7.3
- 7.4snapshot
- nightly

matrix:
Expand All @@ -14,6 +15,7 @@ matrix:
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable"
allow_failures:
- php: 7.4snapshot
- php: nightly

install:
Expand Down
32 changes: 16 additions & 16 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public function testConstructWithInvalidUrl(): void
/**
* @dataProvider httpMethods
*/
public function testCallForV1(string $method, int $statusCode, ...$params): void
public function testCallForV1(string $method, int $statusCode, $responseContent, ...$requestParams): void
{
$response = $this->createMock(ResponseInterface::class);
$response->method('getStatusCode')
->willReturn($statusCode);
$response->method('getBody')
->willReturn(json_encode([]));
->willReturn(json_encode($responseContent));

$http = $this->createMock(HttpMethodsClient::class);
$http->expects($this->once())
Expand All @@ -90,21 +90,21 @@ public function testCallForV1(string $method, int $statusCode, ...$params): void
->willReturn($response);

$client = Client::createV1($http, 'foo');
$resource = call_user_func([$client, $method], 'resource', $params);
$resource = call_user_func([$client, $method], 'resource', $requestParams);

$this->assertIsArray($resource);
$this->assertTrue(true, 'No error occured during call');
}

/**
* @dataProvider httpMethods
*/
public function testCallForV2(string $method, int $statusCode, ...$params): void
public function testCallForV2(string $method, int $statusCode, $responseContent, ...$requestParams): void
{
$response = $this->createMock(ResponseInterface::class);
$response->method('getStatusCode')
->willReturn($statusCode);
$response->method('getBody')
->willReturn(json_encode([]));
->willReturn(json_encode($responseContent));

$http = $this->createMock(HttpMethodsClient::class);
$http->expects($this->once())
Expand All @@ -113,21 +113,21 @@ public function testCallForV2(string $method, int $statusCode, ...$params): void
->willReturn($response);

$client = Client::createV2($http, 'foo');
$resource = call_user_func([$client, $method], 'resource', $params);
$resource = call_user_func([$client, $method], 'resource', $requestParams);

$this->assertIsArray($resource);
$this->assertTrue(true, 'No error occured during call');
}

/**
* @dataProvider httpMethods
*/
public function testCallForBeta(string $method, int $statusCode, ...$params): void
public function testCallForBeta(string $method, int $statusCode, $responseContent, ...$requestParams): void
{
$response = $this->createMock(ResponseInterface::class);
$response->method('getStatusCode')
->willReturn($statusCode);
$response->method('getBody')
->willReturn(json_encode([]));
->willReturn(json_encode($responseContent));

$http = $this->createMock(HttpMethodsClient::class);
$http->expects($this->once())
Expand All @@ -136,9 +136,9 @@ public function testCallForBeta(string $method, int $statusCode, ...$params): vo
->willReturn($response);

$client = Client::createBeta($http, 'foo');
$resource = call_user_func([$client, $method], 'resource', $params);
$resource = call_user_func([$client, $method], 'resource', $requestParams);

$this->assertIsArray($resource);
$this->assertTrue(true, 'No error occured during call');
}

public function testGetCall(): void
Expand Down Expand Up @@ -466,10 +466,10 @@ public function exceptionCalls(): array
public function httpMethods(): array
{
return [
['get', 200],
['post', 201, []],
['put', 200, []],
['delete', 204],
['get', 200, []],
['post', 201, [], []],
['put', 200, [], []],
['delete', 204, null],
];
}
}

0 comments on commit bf9fb78

Please sign in to comment.