2015-11-17 16:45:41 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Aviat\Ion\Friend;
|
2016-01-07 13:45:43 -05:00
|
|
|
use Aviat\Ion\Json;
|
2015-11-17 16:45:41 -05:00
|
|
|
|
|
|
|
class MangaModelTest extends AnimeClient_TestCase {
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2016-08-29 15:36:36 -04:00
|
|
|
$this->container->setInstance('util', new MockUtil($this->container));
|
2015-11-17 16:45:41 -05:00
|
|
|
$this->model = new Friend(new TestMangaModel($this->container));
|
2016-08-29 17:09:56 -04:00
|
|
|
$this->mockDir = __DIR__ . '/../test_data/manga_list';
|
2015-11-17 16:45:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testZipperLists()
|
|
|
|
{
|
2016-01-07 13:45:43 -05:00
|
|
|
$raw_data = Json::decodeFile($this->mockDir . '/manga.json');
|
|
|
|
$expected = Json::decodeFile($this->mockDir . '/manga-zippered.json');
|
2015-11-17 16:45:41 -05:00
|
|
|
|
2016-10-20 22:09:36 -04:00
|
|
|
$this->assertEquals($expected, $this->model->zipperLists($raw_data));
|
2015-11-17 16:45:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testMapByStatus()
|
|
|
|
{
|
2016-01-07 13:45:43 -05:00
|
|
|
$original = Json::decodeFile($this->mockDir . '/manga-transformed.json');
|
|
|
|
$expected = Json::decodeFile($this->mockDir . '/manga-mapped.json');
|
2015-11-17 16:45:41 -05:00
|
|
|
$actual = $this->model->map_by_status($original);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetListFromApi()
|
|
|
|
{
|
|
|
|
$data = file_get_contents($this->mockDir . '/manga.json');
|
|
|
|
$client = $this->getMockClient(200, [
|
|
|
|
'Content-type' => 'application/json'
|
|
|
|
], $data);
|
|
|
|
$this->model->__set('client', $client);
|
|
|
|
|
|
|
|
$reflect = new ReflectionClass($this->model);
|
|
|
|
$constants = $reflect->getConstants();
|
|
|
|
|
2016-01-07 13:45:43 -05:00
|
|
|
$expected_all = Json::decodeFile($this->mockDir . '/manga-mapped.json');
|
2015-11-17 16:45:41 -05:00
|
|
|
|
|
|
|
$this->assertEquals($expected_all, $this->model->_get_list_from_api());
|
|
|
|
|
|
|
|
foreach($constants as $name => $value)
|
|
|
|
{
|
|
|
|
$key = $reflect->getConstant($name);
|
|
|
|
$this->assertEquals($expected_all[$key], $this->model->_get_list_from_api($key));
|
|
|
|
}
|
|
|
|
}
|
2015-11-18 10:31:42 -05:00
|
|
|
|
|
|
|
public function testGetList()
|
|
|
|
{
|
2015-11-18 10:58:12 -05:00
|
|
|
if (($var = getenv('CI')))
|
|
|
|
{
|
|
|
|
$this->markTestSkipped();
|
|
|
|
}
|
|
|
|
|
2016-01-11 15:31:53 -05:00
|
|
|
$data = file_get_contents($this->mockDir . '/manga.json');
|
|
|
|
$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'));
|
2015-11-18 10:31:42 -05:00
|
|
|
}
|
2015-11-17 16:45:41 -05:00
|
|
|
}
|