Skip to content

Commit

Permalink
test old and new error response formats
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-gribanov committed Aug 14, 2017
1 parent 80104d6 commit 6146465
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions tests/Util/ErrorDetectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,49 @@ public function testNoErrors()
}

/**
* @expectedException \AnimeDb\Bundle\AniDbBrowserBundle\Exception\BannedException
* @return array
*/
public function testBanned()
public function responses()
{
$response = '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
$response .= '<body><error>Banned</error></body>';
$xml = '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;

$this->checker->detect($response);
return [
[$xml.'<body><error>%s</error></body>'],
[$xml.'<error>%s</error>'],
];
}

/**
* @expectedException \AnimeDb\Bundle\AniDbBrowserBundle\Exception\NotFoundException
* @expectedException \AnimeDb\Bundle\AniDbBrowserBundle\Exception\BannedException
* @dataProvider responses
*
* @param string $response
*/
public function testNotFound()
public function testBanned($response)
{
$response = '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
$response .= '<body><error>Anime not found</error></body>';
$this->checker->detect(sprintf($response, 'Banned'));
}

$this->checker->detect($response);
/**
* @expectedException \AnimeDb\Bundle\AniDbBrowserBundle\Exception\NotFoundException
* @dataProvider responses
*
* @param string $response
*/
public function testNotFound($response)
{
$this->checker->detect(sprintf($response, 'Anime not found'));
}

/**
* @expectedException \AnimeDb\Bundle\AniDbBrowserBundle\Exception\ErrorException
* @expectedExceptionMessage Foo
* @dataProvider responses
*
* @param string $response
*/
public function testError()
public function testError($response)
{
$response = '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
$response .= '<body><error>Foo</error></body>';

$this->checker->detect($response);
$this->checker->detect(sprintf($response, 'Foo'));
}
}

0 comments on commit 6146465

Please sign in to comment.