Skip to content

Commit

Permalink
Add tests to check failures for unsupported stream types
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonhebert committed Apr 24, 2020
1 parent 30f87bc commit dec598b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/DataStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ public function tearDown()
Mockery::close();
}

/**
* @throws ReflectionException
*/
public function testFailsToParseUnsupportedType()
{
$this->expectException(StreamException::class);
$this->expectExceptionMessage(
'Unable to create a stream from given input, must be one of [`object`, `resource`, `string`].'
);

DataStream::get([]);
}

/**
* @throws ReflectionException
*/
Expand All @@ -36,6 +49,20 @@ public function testFailsToParseUnsupportedObjectType()
$objectMethod->invokeArgs($dataStream, [new stdClass()]);
}

/**
* @throws ReflectionException
*/
public function testFailsToParseInvalidResource()
{
$objectMethod = self::getProtectedMethod('resource');
$dataStream = new DataStream();

$this->expectException(StreamException::class);
$this->expectExceptionMessage('Invalid resource: unable to create stream.');

$objectMethod->invokeArgs($dataStream, [new stdClass()]);
}

/**
* @throws ReflectionException
*/
Expand Down

0 comments on commit dec598b

Please sign in to comment.