getReactor()->run(function($reactor) { $path = __DIR__ . "/fixture/new.txt"; $fs = $this->getFilesystem($reactor); $flags = Filesystem::READ | Filesystem::WRITE | Filesystem::CREATE; $fh = (yield $fs->open($path, $flags)); yield $fh->write(0, "test"); $data = (yield $fh->read(0, 8192)); $this->assertSame("test", $data); yield $fh->close(); yield $fs->unlink($path); }); } public function testTruncate() { $this->getReactor()->run(function($reactor) { $path = __DIR__ . "/fixture/truncate.txt"; $fs = $this->getFilesystem($reactor); $flags = Filesystem::READ | Filesystem::WRITE | Filesystem::CREATE; $fh = (yield $fs->open($path, $flags)); yield $fh->write(0, "test"); $data = (yield $fh->read(0, 8192)); $this->assertSame("test", $data); yield $fh->truncate(); yield $fh->close(); $stat = (yield $fs->stat($path)); $this->assertEquals(0, $stat["size"]); yield $fs->unlink($path); }); } public function testStat() { $this->getReactor()->run(function($reactor) { $fs = $this->getFilesystem($reactor); $fh = (yield $fs->open(__DIR__ . "/fixture/small.txt")); $stat = (yield $fh->stat()); $this->assertInternalType("array", $stat); }); } }