fix false positive test case

This commit is contained in:
Reasno 2020-04-17 13:21:18 +08:00
parent 1a7ec243d4
commit 6739970444

View File

@ -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();