diff --git a/src/Formats/BSON.php b/src/Formats/BSON.php index 8d99bf2..46bab24 100644 --- a/src/Formats/BSON.php +++ b/src/Formats/BSON.php @@ -31,7 +31,7 @@ public function parse($payload) } return array(); } else { - throw new ParserException('Failed To Parse BSON - Supporting Library Not Available.'); + throw new ParserException('Failed To Parse BSON - Supporting Library Not Available'); } } diff --git a/tests/ParserPHPTest.php b/tests/ParserPHPTest.php index 090d911..36603bd 100644 --- a/tests/ParserPHPTest.php +++ b/tests/ParserPHPTest.php @@ -260,7 +260,7 @@ public function parser_empty_json_data() /** @test */ public function parser_validates_bson_data() { - if (function_exists('bson_encode')) { + if (function_exists('bson_decode')) { $expected = array('status' => 123, 'message' => 'hello world'); $payload = bson_encode($expected); @@ -272,8 +272,21 @@ public function parser_validates_bson_data() /** @test */ public function parser_empty_bson_data() { - $parser = new Parser(); - $this->assertEquals(array(), $parser->bson("")); + if (function_exists('bson_decode')) { + $parser = new Parser(); + $this->assertEquals(array(), $parser->bson("")); + } + } + + /** @test */ + public function throw_an_exception_when_bson_library_not_loaded() + { + if (! function_exists('bson_decode')) { + $this->setExpectedException('Exception', 'Failed To Parse BSON - Supporting Library Not Available'); + + $parser = new Parser(); + $this->assertEquals(array(), $parser->bson("")); + } } /** @test */