Skip to content

Commit 4aacd5f

Browse files
committed
Use Assert::throws()
1 parent 5b4ec76 commit 4aacd5f

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/test/php/text/json/unittest/StreamInputTest.class.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,16 @@ public function calling_pairs_after_resetting_with_bom($input) {
7070

7171
#[Test]
7272
public function cannot_reset_unseekable() {
73-
$input= new StreamInput(newinstance(InputStream::class, [], [
74-
'read' => function($size= 8192) { return '[1]'; },
75-
'available' => function() { return true; },
76-
'close' => function() { }
77-
]));
73+
$input= new StreamInput(new class() implements InputStream {
74+
public function read($size= 8192) { return '[1]'; }
75+
public function available() { return true; }
76+
public function close() { }
77+
});
7878
Assert::equals([1], iterator_to_array($input->elements()), '#1');
79-
try {
79+
Assert::throws(IOException::class, function() use($input) {
8080
$input->reset();
8181
iterator_to_array($input->elements());
82-
$this->fail('Expected exception not caught', null, 'io.IOException');
83-
} catch (IOException $expected) {
84-
// OK
85-
}
82+
});
8683
}
8784

8885
#[Test]

0 commit comments

Comments
 (0)