Skip to content

Commit

Permalink
Fix restoration of error handler
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed May 16, 2023
1 parent 2f2318f commit 073ec6c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/Compress/SnappyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,15 @@ public function testANonStringWillYieldATypeErrorDuringCompression(): void
throw new TypeError($message);
});

$this->expectException(TypeError::class);
$this->expectExceptionMessage('snappy_compress : expects parameter to be string');
/** @psalm-suppress InvalidArgument, InvalidCast */
(new SnappyCompression())->compress([]);

restore_error_handler();
try {
/** @psalm-suppress InvalidArgument, InvalidCast */
(new SnappyCompression())->compress([]);
self::fail('An exception was expected');
} catch (TypeError $e) {
self::assertStringContainsString('snappy_compress : expects parameter to be string', $e->getMessage());
} finally {
restore_error_handler();
}
}

public function testNonScalarInputCausesAnException(): void
Expand Down

0 comments on commit 073ec6c

Please sign in to comment.