Skip to content

Commit fe64361

Browse files
committed
Update tests to support missing library
1 parent 200aa25 commit fe64361

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

src/Formats/BSON.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function parse($payload)
3131
}
3232
return array();
3333
} else {
34-
throw new ParserException('Failed To Parse BSON - Supporting Library Not Available.');
34+
throw new ParserException('Failed To Parse BSON - Supporting Library Not Available');
3535
}
3636
}
3737

tests/ParserPHPTest.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public function parser_empty_json_data()
260260
/** @test */
261261
public function parser_validates_bson_data()
262262
{
263-
if (function_exists('bson_encode')) {
263+
if (function_exists('bson_decode')) {
264264
$expected = array('status' => 123, 'message' => 'hello world');
265265
$payload = bson_encode($expected);
266266

@@ -272,8 +272,21 @@ public function parser_validates_bson_data()
272272
/** @test */
273273
public function parser_empty_bson_data()
274274
{
275-
$parser = new Parser();
276-
$this->assertEquals(array(), $parser->bson(""));
275+
if (function_exists('bson_decode')) {
276+
$parser = new Parser();
277+
$this->assertEquals(array(), $parser->bson(""));
278+
}
279+
}
280+
281+
/** @test */
282+
public function throw_an_exception_when_bson_library_not_loaded()
283+
{
284+
if (! function_exists('bson_decode')) {
285+
$this->setExpectedException('Exception', 'Failed To Parse BSON - Supporting Library Not Available');
286+
287+
$parser = new Parser();
288+
$this->assertEquals(array(), $parser->bson(""));
289+
}
277290
}
278291

279292
/** @test */

0 commit comments

Comments
 (0)