Skip to content

Commit

Permalink
Add tests for read and write modes
Browse files Browse the repository at this point in the history
  • Loading branch information
sagikazarmark committed Dec 7, 2018
1 parent 4b24215 commit f067611
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions tests/StreamTest.php
Expand Up @@ -257,6 +257,83 @@ public function gzipModeProvider()
['mode' => 'wb2', 'readable' => false, 'writable' => true],
];
}

/**
* @dataProvider readableModeProvider
*
* @param string $mode
*/
public function testReadableStream($mode)
{
$r = fopen('php://temp', $mode);
$stream = new Stream($r);

$this->assertTrue($stream->isReadable());

$stream->close();
}

public function readableModeProvider()
{
return [
['r'],
['w+'],
['r+'],
['x+'],
['c+'],
['rb'],
['w+b'],
['r+b'],
['x+b'],
['c+b'],
['rt'],
['w+t'],
['r+t'],
['x+t'],
['c+t'],
['a+'],
['rb+'],
];
}

/**
* @dataProvider writableModeProvider
*
* @param string $mode
*/
public function testWritableStream($mode)
{
$r = fopen('php://temp', $mode);
$stream = new Stream($r);

$this->assertTrue($stream->isWritable());

$stream->close();
}

public function writableModeProvider()
{
return [
['w'],
['w+'],
['rw'],
['r+'],
['x+'],
['c+'],
['wb'],
['w+b'],
['r+b'],
['rb+'],
['x+b'],
['c+b'],
['w+t'],
['r+t'],
['x+t'],
['c+t'],
['a'],
['a+'],
];
}
}

namespace GuzzleHttp\Psr7;
Expand Down

0 comments on commit f067611

Please sign in to comment.