Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Meldiron committed Jun 30, 2024
1 parent 9c04512 commit a6c4c28
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tests/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function call(string $method, string $path = '', array $headers = [], arr

if ($decode) {
$strpos = strpos($responseType, ';');
$strpos = \is_bool($strpos) ? 0 : $strpos;
$strpos = \is_bool($strpos) ? \strlen($responseType) : $strpos;
switch (substr($responseType, 0, $strpos)) {
case 'multipart/form-data':
$boundary = \explode('boundary=', $responseHeaders['content-type'] ?? '')[1] ?? '';
Expand Down
21 changes: 9 additions & 12 deletions tests/ExecutorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function provideScenarios(): array
$this->assertEmpty($response['body']['errors']);
},
'body' => function () {
return 1;
return '1';
},
],
[
Expand All @@ -359,7 +359,7 @@ public function provideScenarios(): array
$this->assertEmpty($response['body']['errors']);
},
'body' => function () {
return 5;
return '5';
},
],
[
Expand All @@ -374,11 +374,11 @@ public function provideScenarios(): array
$this->assertEquals("OK", $response['body']['body']);
$this->assertGreaterThan(5 * 1024 * 1024, strlen($response['body']['logs']));
$this->assertLessThan(6 * 1024 * 1024, strlen($response['body']['logs']));
$this->assertStringContainsString('Log file has been truncated to 5 MBs', $response['body']['logs']);
$this->assertStringContainsString('truncated', $response['body']['logs']);
$this->assertEmpty($response['body']['errors']);
},
'body' => function () {
return 15;
return '15';
},
],
[
Expand Down Expand Up @@ -418,6 +418,7 @@ public function provideScenarios(): array
$this->assertEmpty($response['body']['logs']);
$this->assertEmpty($response['body']['errors']);
},
null, // body
'mimeType' => 'multipart/form-data'
],
[
Expand All @@ -431,6 +432,7 @@ public function provideScenarios(): array
$this->assertEquals(400, $response['headers']['status-code']);
\var_dump($response);
},
null, // body
'mimeType' => 'application/json'
],
[
Expand Down Expand Up @@ -473,7 +475,7 @@ public function provideScenarios(): array
*
* @dataProvider provideScenarios
*/
public function testScenarios(string $image, string $entrypoint, string $folder, string $version, string $startCommand, string $buildCommand, callable $assertions, callable $bodyCallable = null, string $mimeType = "application/json"): void
public function testScenarios(string $image, string $entrypoint, string $folder, string $version, string $startCommand, string $buildCommand, callable $assertions, callable $body = null, string $mimeType = "application/json"): void
{
/** Prepare deployment */
$output = '';
Expand All @@ -497,11 +499,6 @@ public function testScenarios(string $image, string $entrypoint, string $folder,

$path = $response['body']['path'];

$body = "";
if (isset($bodyCallable)) {
$body = \strval($bodyCallable());
}

$params = [
'source' => $path,
'entrypoint' => $entrypoint,
Expand All @@ -512,8 +509,8 @@ public function testScenarios(string $image, string $entrypoint, string $folder,
'logging' => true,
];

if (!empty($body)) {
$params['body'] = $body;
if (isset($body)) {
$params['body'] = $body();
}

/** Execute function */
Expand Down

0 comments on commit a6c4c28

Please sign in to comment.