mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-04 04:37:46 +08:00
fix false positive test case
This commit is contained in:
parent
1a7ec243d4
commit
6739970444
@ -13,6 +13,7 @@ namespace HyperfTest\Utils;
|
||||
|
||||
use Hyperf\Utils\Parallel;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Swoole\Runtime;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
@ -22,18 +23,19 @@ class FilesystemTest extends TestCase
|
||||
{
|
||||
public function testLock()
|
||||
{
|
||||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||
file_put_contents('./test.txt', str_repeat('a', 10000));
|
||||
$p = new Parallel();
|
||||
for ($i = 0; $i < 100; ++$i) {
|
||||
$p->add(function () {
|
||||
$fs = new \Hyperf\Utils\Filesystem\Filesystem();
|
||||
$fs->put('./test.txt', str_repeat('b', 1000000));
|
||||
$this->assertEquals(1000000, strlen($fs->get('./test.txt', true)));
|
||||
$fs->put('./test.txt', str_repeat('b', 100000), true);
|
||||
$this->assertEquals(100000, strlen($fs->get('./test.txt', true)));
|
||||
});
|
||||
$p->add(function () {
|
||||
$fs = new \Hyperf\Utils\Filesystem\Filesystem();
|
||||
$this->assertEquals(1000000, strlen($fs->get('./test.txt', true)));
|
||||
$fs->put('./test.txt', str_repeat('c', 1000000));
|
||||
$this->assertEquals(100000, strlen($fs->get('./test.txt', true)));
|
||||
$fs->put('./test.txt', str_repeat('c', 100000), true);
|
||||
});
|
||||
}
|
||||
$p->wait();
|
||||
|
Loading…
Reference in New Issue
Block a user