-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests, fix ResourceOutputStream writable check
- Loading branch information
Showing
5 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
.php_cs.cache | ||
build | ||
coverage | ||
composer.lock | ||
phpunit.xml | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Amp\ByteStream\Test; | ||
|
||
use Amp\ByteStream\ResourceInputStream; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ResourceInputStreamTest extends TestCase { | ||
public function testGetResource() { | ||
$stream = new ResourceInputStream(\STDIN); | ||
|
||
$this->assertSame(\STDIN, $stream->getResource()); | ||
} | ||
|
||
public function testNonStream() { | ||
$this->expectException(\Error::class); | ||
$this->expectExceptionMessage("Expected a valid stream"); | ||
|
||
new ResourceInputStream(42); | ||
} | ||
|
||
public function testNotReadable() { | ||
$this->expectException(\Error::class); | ||
$this->expectExceptionMessage("Expected a readable stream"); | ||
|
||
new ResourceInputStream(\STDOUT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Amp\ByteStream\Test; | ||
|
||
use Amp\ByteStream\ResourceOutputStream; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ResourceOutputStreamTest extends TestCase { | ||
public function testGetResource() { | ||
$stream = new ResourceOutputStream(\STDOUT); | ||
|
||
$this->assertSame(\STDOUT, $stream->getResource()); | ||
} | ||
|
||
public function testNonStream() { | ||
$this->expectException(\Error::class); | ||
$this->expectExceptionMessage("Expected a valid stream"); | ||
|
||
new ResourceOutputStream(42); | ||
} | ||
|
||
public function testNotWritable() { | ||
$this->expectException(\Error::class); | ||
$this->expectExceptionMessage("Expected a writable stream"); | ||
|
||
new ResourceOutputStream(\STDIN); | ||
} | ||
} |