File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -249,7 +249,7 @@ public function stream_lock($operation)
249
249
{
250
250
assert (is_resource ($ this ->fp ));
251
251
252
- return flock ($ this ->fp , $ operation );
252
+ return flock ($ this ->fp , LOCK_SH );
253
253
}
254
254
255
255
public function stream_metadata ($ path , $ option , $ value )
Original file line number Diff line number Diff line change 36
36
namespace Infection \Tests \StreamWrapper ;
37
37
38
38
use function count ;
39
+ use function file_put_contents ;
39
40
use Infection \StreamWrapper \IncludeInterceptor ;
40
41
use InvalidArgumentException ;
42
+ use function is_link ;
41
43
use const PHP_SAPI ;
42
44
use PHPUnit \Framework \Error \Warning ;
43
45
use PHPUnit \Framework \TestCase ;
44
46
use RuntimeException ;
47
+ use function symlink ;
48
+ use function sys_get_temp_dir ;
45
49
46
50
/**
47
51
* Tests IncludeInterceptor for correct operation.
@@ -433,4 +437,15 @@ public function test_it_respects_symlinks_in_url_stat(): void
433
437
434
438
$ this ->assertTrue (is_link ($ symlink ));
435
439
}
440
+
441
+ public function test_it_works_with_locks (): void
442
+ {
443
+ IncludeInterceptor::intercept (self ::$ files [1 ], self ::$ files [2 ]);
444
+ IncludeInterceptor::enable ();
445
+
446
+ // action - lock the file to check locking does not throw an exception with our stream wrapper
447
+ file_put_contents (self ::$ files [1 ], 'text ' , LOCK_EX );
448
+
449
+ $ this ->addToAssertionCount (1 );
450
+ }
436
451
}
You can’t perform that action at this time.
0 commit comments