Skip to content

Commit 7528aa6

Browse files
test: fix test hanging in http call (#126)
1 parent 553f36f commit 7528aa6

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/src/Functional/SplitCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public function testSplitFailsWhenFileDoesNotExist(): void
259259
// Should display error message
260260
$output = $this->commandTester->getDisplay();
261261
$this->assertStringContainsString('File not found', $output);
262-
$this->assertStringContainsString($nonExistentFile, $output);
262+
$this->assertStringContainsString('nonexistent.har', $output);
263263
}
264264

265265
public function testSplitFailsWhenPathIsDirectory(): void
@@ -279,7 +279,7 @@ public function testSplitFailsWhenPathIsDirectory(): void
279279
// Should display error message indicating it's a directory
280280
$output = $this->commandTester->getDisplay();
281281
$this->assertStringContainsString('Path is a directory', $output);
282-
$this->assertStringContainsString($directoryPath, $output);
282+
$this->assertStringContainsString('notafile', $output);
283283
}
284284

285285
private function recursiveRemoveDirectory(string $directory): void

tests/src/Unit/ReadmeTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Deviantintegral\Har\Response;
1313
use Deviantintegral\Har\Serializer;
1414
use GuzzleHttp\Client;
15+
use GuzzleHttp\RequestOptions;
1516
use PHPUnit\Framework\TestCase;
1617

1718
class ReadmeTest extends TestCase
@@ -33,7 +34,9 @@ public function testExample()
3334

3435
// Send the request live!
3536
try {
36-
$psr7_response = (new Client())->send($psr7_request);
37+
$psr7_response = (new Client())->send($psr7_request, [
38+
RequestOptions::TIMEOUT => 5,
39+
]);
3740

3841
// Convert the response back to a HAR response object.
3942
$response = Response::fromPsr7Response($psr7_response);

0 commit comments

Comments
 (0)