Skip to content

Commit

Permalink
Update tests to support missing library
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanmac committed Nov 11, 2014
1 parent 200aa25 commit fe64361
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Formats/BSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}

Expand Down
19 changes: 16 additions & 3 deletions tests/ParserPHPTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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 */
Expand Down

0 comments on commit fe64361

Please sign in to comment.