Skip to content

Commit

Permalink
add test coverage for new exceptions throwns
Browse files Browse the repository at this point in the history
  • Loading branch information
l0gicgate committed May 3, 2019
1 parent 1157e23 commit 77be549
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions tests/NonBufferedBodyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Slim\Tests\Psr7;

use PHPUnit\Framework\TestCase;
use RuntimeException;
use Slim\Psr7\NonBufferedBody;
use Slim\Psr7\Response;
use Slim\Tests\Psr7\Assets\HeaderStack;
Expand Down Expand Up @@ -37,7 +38,6 @@ public function testTheStreamContract()
self::assertFalse($body->isSeekable(), 'Cannot seek');
self::assertTrue($body->isWritable(), 'Body is writable');
self::assertFalse($body->isReadable(), 'Body is not readable');
self::assertSame('', $body->read(10), 'Data cannot be retrieved once written');
self::assertSame('', $body->getContents(), 'Data cannot be retrieved once written');
self::assertNull($body->getMetadata(), 'Metadata mechanism is not implemented');
}
Expand Down Expand Up @@ -78,7 +78,6 @@ public function testWithAddedHeader()
], HeaderStack::stack());
}


public function testWithoutHeader()
{
(new Response())
Expand All @@ -88,4 +87,40 @@ public function testWithoutHeader()

self::assertSame([], HeaderStack::stack());
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage A NonBufferedBody is not closable.
*/
public function testCloseThrowsRuntimeException()
{
(new NonBufferedBody())->close();
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage A NonBufferedBody is not seekable.
*/
public function testSeekThrowsRuntimeException()
{
(new NonBufferedBody())->seek(10);
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage A NonBufferedBody is not rewindable.
*/
public function testRewindThrowsRuntimeException()
{
(new NonBufferedBody())->rewind();
}

/**
* @expectedException RuntimeException
* @expectedExceptionMessage A NonBufferedBody is not readable.
*/
public function testReadThrowsRuntimeException()
{
(new NonBufferedBody())->read(10);
}
}

0 comments on commit 77be549

Please sign in to comment.