mirror of
https://github.com/danog/file.git
synced 2024-11-26 11:54:54 +01:00
Avoid warning when writing an empty string with eio
No warning emitted from uv, but there's also no reason to call uv_fs_write().
This commit is contained in:
parent
8cfe851cd2
commit
94c3bb631c
@ -132,6 +132,10 @@ class EioHandle implements Handle
|
||||
{
|
||||
$length = \strlen($data);
|
||||
|
||||
if ($length === 0) {
|
||||
return new Success(0);
|
||||
}
|
||||
|
||||
$deferred = new Deferred;
|
||||
$this->poll->listen($deferred->promise());
|
||||
|
||||
|
@ -150,6 +150,10 @@ class UvHandle implements Handle
|
||||
{
|
||||
$length = \strlen($data);
|
||||
|
||||
if ($length === 0) {
|
||||
return new Success(0);
|
||||
}
|
||||
|
||||
$deferred = new Deferred;
|
||||
$this->poll->listen($deferred->promise());
|
||||
|
||||
|
@ -41,6 +41,21 @@ abstract class HandleTest extends TestCase
|
||||
});
|
||||
}
|
||||
|
||||
public function testEmptyWrite()
|
||||
{
|
||||
$this->execute(function () {
|
||||
$path = Fixture::path() . "/write";
|
||||
|
||||
$handle = yield File\open($path, "c+");
|
||||
$this->assertSame(0, $handle->tell());
|
||||
|
||||
yield $handle->write("");
|
||||
$this->assertSame(0, $handle->tell());
|
||||
|
||||
yield $handle->close();
|
||||
});
|
||||
}
|
||||
|
||||
public function testWriteAfterClose()
|
||||
{
|
||||
$this->execute(function () {
|
||||
|
Loading…
Reference in New Issue
Block a user