Change logger methods to be inline with interface, fix Manga Model tests

This commit is contained in:
Timothy Warren 2016-01-11 15:31:53 -05:00
parent e51159e7f3
commit b611d02a2c
7 changed files with 2975 additions and 34 deletions

View File

@ -67,8 +67,8 @@ class Dispatcher extends RoutingBase {
$raw_route = $this->request->url->get(PHP_URL_PATH); $raw_route = $this->request->url->get(PHP_URL_PATH);
$route_path = "/" . trim($raw_route, '/'); $route_path = "/" . trim($raw_route, '/');
$logger->addDebug('Dispatcher - Routing data from get_route method'); $logger->debug('Dispatcher - Routing data from get_route method');
$logger->addDebug(print_r([ $logger->debug(print_r([
'route_path' => $route_path 'route_path' => $route_path
], TRUE)); ], TRUE));
@ -100,8 +100,8 @@ class Dispatcher extends RoutingBase {
{ {
$route = $this->get_route(); $route = $this->get_route();
$logger->addDebug('Dispatcher - Route invoke arguments'); $logger->debug('Dispatcher - Route invoke arguments');
$logger->addDebug(print_r($route, TRUE)); $logger->debug(print_r($route, TRUE));
} }
if($route) if($route)
@ -241,8 +241,8 @@ class Dispatcher extends RoutingBase {
$controller = new $controller_name($this->container); $controller = new $controller_name($this->container);
// Run the appropriate controller method // Run the appropriate controller method
$logger->addDebug('Dispatcher - controller arguments'); $logger->debug('Dispatcher - controller arguments');
$logger->addDebug(print_r($params, TRUE)); $logger->debug(print_r($params, TRUE));
call_user_func_array([$controller, $method], $params); call_user_func_array([$controller, $method], $params);
} }

View File

@ -161,8 +161,8 @@ class Anime extends API {
if ($response->getStatusCode() != 200) if ($response->getStatusCode() != 200)
{ {
$logger->addWarning("Non 200 response for search api call"); $logger->warning("Non 200 response for search api call");
$logger->addWarning($response->getBody()); $logger->warning($response->getBody());
throw new RuntimeException($response->getEffectiveUrl()); throw new RuntimeException($response->getEffectiveUrl());
} }

View File

@ -57,43 +57,35 @@ class MangaModelTest extends AnimeClient_TestCase {
public function testGetList() public function testGetList()
{ {
$this->markTestSkipped();
if (($var = getenv('CI'))) if (($var = getenv('CI')))
{ {
$this->markTestSkipped(); $this->markTestSkipped();
} }
$data = $this->model->get_all_lists(); $data = file_get_contents($this->mockDir . '/manga.json');
$this->assertEquals($data['Reading'], $this->model->get_list('Reading')); $client = $this->getMockClient(200, [
'Content-type' => 'application/json'
], $data);
$this->model->__set('client', $client);
$expected = Json::decodeFile($this->mockDir . '/get-all-lists.json');
$this->assertEquals($expected['Reading'], $this->model->get_list('Reading'));
} }
public function testGetAllLists() public function testGetAllLists()
{ {
$this->markTestSkipped();
if (($var = getenv('CI'))) if (($var = getenv('CI')))
{ {
$this->markTestSkipped(); $this->markTestSkipped();
} }
$data = Json::decodeFile($this->mockDir . '/manga-mapped.json'); $data = file_get_contents($this->mockDir . '/manga.json');
$client = $this->getMockClient(200, [
'Content-type' => 'application/json'
], $data);
$this->model->__set('client', $client);
foreach($data as &$val) $expected = Json::decodeFile($this->mockDir . '/get-all-lists.json');
{ $this->assertEquals($expected, $this->model->get_all_lists());
$this->sort_by_name($val);
}
$this->assertEquals($data, $this->model->get_all_lists());
}
private function sort_by_name(&$array)
{
$sort = array();
foreach ($array as $key => $item)
{
$sort[$key] = $item['manga']['title'];
}
array_multisort($sort, SORT_ASC, $array);
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long