Skip to content

Commit 68c2121

Browse files
authored
Merge pull request #165 from clue-labs/php8.2
Make tests compatible with PHP 8.2 by avoiding dynamic properties
2 parents c7af3d8 + f96bfb2 commit 68c2121

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

tests/EnforceBlockingWrapper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
/**
66
* Used to test dummy stream resources that do not support setting non-blocking mode
77
*
8-
* @link http://php.net/manual/de/class.streamwrapper.php
8+
* @link https://www.php.net/manual/en/class.streamwrapper.php
99
*/
1010
class EnforceBlockingWrapper
1111
{
12+
public $context;
13+
1214
public function stream_open($path, $mode, $options, &$opened_path)
1315
{
1416
return true;

tests/WritableResourceStreamTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,23 @@ public function testEmptyWriteDoesNotAddToLoop()
157157
public function testWriteReturnsFalseWhenWritableResourceStreamIsFull()
158158
{
159159
$stream = fopen('php://temp', 'r+');
160-
$loop = $this->createWriteableLoopMock();
161-
$loop->preventWrites = true;
160+
161+
$preventWrites = true;
162+
$loop = $this->createLoopMock();
163+
$loop
164+
->expects($this->any())
165+
->method('addWriteStream')
166+
->will($this->returnCallback(function ($stream, $listener) use (&$preventWrites) {
167+
if (!$preventWrites) {
168+
call_user_func($listener, $stream);
169+
}
170+
}));
162171

163172
$buffer = new WritableResourceStream($stream, $loop, 4);
164173
$buffer->on('error', $this->expectCallableNever());
165174

166175
$this->assertTrue($buffer->write("foo"));
167-
$loop->preventWrites = false;
176+
$preventWrites = false;
168177
$this->assertFalse($buffer->write("bar\n"));
169178
}
170179

@@ -504,14 +513,11 @@ public function testWritingToClosedStream()
504513
private function createWriteableLoopMock()
505514
{
506515
$loop = $this->createLoopMock();
507-
$loop->preventWrites = false;
508516
$loop
509517
->expects($this->any())
510518
->method('addWriteStream')
511-
->will($this->returnCallback(function ($stream, $listener) use ($loop) {
512-
if (!$loop->preventWrites) {
513-
call_user_func($listener, $stream);
514-
}
519+
->will($this->returnCallback(function ($stream, $listener) {
520+
call_user_func($listener, $stream);
515521
}));
516522

517523
return $loop;

0 commit comments

Comments
 (0)