From 073ec6c6c6548356d81fa225a18c39e0fb8dfd62 Mon Sep 17 00:00:00 2001 From: George Steel Date: Tue, 16 May 2023 09:45:19 +0100 Subject: [PATCH] Fix restoration of error handler Signed-off-by: George Steel --- test/Compress/SnappyTest.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/Compress/SnappyTest.php b/test/Compress/SnappyTest.php index f8e5500a..2cd4db09 100644 --- a/test/Compress/SnappyTest.php +++ b/test/Compress/SnappyTest.php @@ -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