mirror of
https://github.com/danog/byte-stream.git
synced 2024-11-26 20:04:51 +01:00
Add infection and tests
This commit is contained in:
parent
f31f990b80
commit
0b282a7321
@ -32,7 +32,8 @@
|
|||||||
"amphp/phpunit-util": "^1",
|
"amphp/phpunit-util": "^1",
|
||||||
"phpunit/phpunit": "^6",
|
"phpunit/phpunit": "^6",
|
||||||
"friendsofphp/php-cs-fixer": "^2.3",
|
"friendsofphp/php-cs-fixer": "^2.3",
|
||||||
"amphp/php-cs-fixer-config": "dev-master"
|
"amphp/php-cs-fixer-config": "dev-master",
|
||||||
|
"infection/infection": "^0.9.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
11
infection.json.dist
Normal file
11
infection.json.dist
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"timeout": 5,
|
||||||
|
"source": {
|
||||||
|
"directories": [
|
||||||
|
"lib"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"logs": {
|
||||||
|
"text": "infection.log"
|
||||||
|
}
|
||||||
|
}
|
@ -255,4 +255,27 @@ class MessageTest extends TestCase
|
|||||||
$stream->read();
|
$stream->read();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testFalsyValueInStreamWhenBuffering()
|
||||||
|
{
|
||||||
|
Loop::run(function () {
|
||||||
|
$emitter = new Emitter;
|
||||||
|
$emitter->emit("0");
|
||||||
|
$emitter->complete();
|
||||||
|
$message = new Message(new IteratorStream($emitter->iterate()));
|
||||||
|
|
||||||
|
$this->assertSame("0", yield $message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFalsyValueInStreamWhenStreaming()
|
||||||
|
{
|
||||||
|
Loop::run(function () {
|
||||||
|
$emitter = new Emitter;
|
||||||
|
$emitter->emit("0");
|
||||||
|
$message = new Message(new IteratorStream($emitter->iterate()));
|
||||||
|
|
||||||
|
$this->assertSame("0", yield $message->read());
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
16
test/PendingReadErrorTest.php
Normal file
16
test/PendingReadErrorTest.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Amp\ByteStream\Test;
|
||||||
|
|
||||||
|
use Amp\ByteStream\PendingReadError;
|
||||||
|
use Amp\PHPUnit\TestCase;
|
||||||
|
|
||||||
|
class PendingReadErrorTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testDefaultErrorCode()
|
||||||
|
{
|
||||||
|
$this->assertSame(0, (new PendingReadError)->getCode());
|
||||||
|
}
|
||||||
|
}
|
25
test/PipeTest.php
Normal file
25
test/PipeTest.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Amp\ByteStream\Test;
|
||||||
|
|
||||||
|
use Amp\ByteStream\IteratorStream;
|
||||||
|
use Amp\ByteStream\OutputBuffer;
|
||||||
|
use Amp\Iterator;
|
||||||
|
use Amp\PHPUnit\TestCase;
|
||||||
|
use function Amp\ByteStream\pipe;
|
||||||
|
use function Amp\Promise\wait;
|
||||||
|
|
||||||
|
class PipeTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testPipe()
|
||||||
|
{
|
||||||
|
$stream = new IteratorStream(Iterator\fromIterable(["abc", "def"]));
|
||||||
|
$buffer = new OutputBuffer;
|
||||||
|
|
||||||
|
$this->assertSame(6, wait(pipe($stream, $buffer)));
|
||||||
|
|
||||||
|
$buffer->end();
|
||||||
|
$this->assertSame("abcdef", wait($buffer));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user