Skip to content

Commit 2ab079f

Browse files
committed
workaround PHP sleep() mocking limitation
1 parent 62e5acb commit 2ab079f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

bootstrap-dev-sleep.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Malkusch\Lock\Tests;
6+
7+
use phpmock\environment\SleepEnvironmentBuilder;
8+
9+
// workaround https://github.com/php/php-src/issues/17116
10+
(static function () {
11+
$sleepBuilder = new SleepEnvironmentBuilder();
12+
$sleepBuilder->addNamespace('Malkusch\Lock\Mutex');
13+
$sleepBuilder->addNamespace('Malkusch\Lock\Util');
14+
$sleepBuilder->addNamespace('Malkusch\Lock\Tests\Mutex');
15+
$sleepBuilder->addNamespace('Malkusch\Lock\Tests\Util');
16+
$sleep = $sleepBuilder->build();
17+
$sleep->enable();
18+
$sleep->disable();
19+
})();

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@
7979
"autoload-dev": {
8080
"psr-4": {
8181
"Malkusch\\Lock\\Tests\\": "tests/"
82-
}
82+
},
83+
"files": [
84+
"bootstrap-dev-sleep.php"
85+
]
8386
},
8487
"config": {
8588
"allow-plugins": {

0 commit comments

Comments
 (0)