Version 5.1 - All the GraphQL #32
@ -8,6 +8,11 @@
|
|||||||
searchResults = JSON.parse(searchResults);
|
searchResults = JSON.parse(searchResults);
|
||||||
_.$('.cssload-loader')[0].setAttribute('hidden', 'hidden');
|
_.$('.cssload-loader')[0].setAttribute('hidden', 'hidden');
|
||||||
|
|
||||||
|
// Give mustache a key to iterate over
|
||||||
|
searchResults = {
|
||||||
|
data: searchResults.data
|
||||||
|
};
|
||||||
|
|
||||||
Mustache.parse(tempHtml);
|
Mustache.parse(tempHtml);
|
||||||
_.$('#series_list')[0].innerHTML = Mustache.render(tempHtml, searchResults);
|
_.$('#series_list')[0].innerHTML = Mustache.render(tempHtml, searchResults);
|
||||||
});
|
});
|
||||||
|
@ -64,21 +64,6 @@ trait MALTrait {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unencode the dual-encoded ampersands in the body
|
|
||||||
*
|
|
||||||
* This is a dirty hack until I can fully track down where
|
|
||||||
* the dual-encoding happens
|
|
||||||
*
|
|
||||||
* @param FormBody $formBody The form builder object to fix
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function fixBody(FormBody $formBody): string
|
|
||||||
{
|
|
||||||
$rawBody = \Amp\wait($formBody->getBody());
|
|
||||||
return html_entity_decode($rawBody, \ENT_HTML5, 'UTF-8');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a request object
|
* Create a request object
|
||||||
*
|
*
|
||||||
|
40
tests/API/MAL/ListItemTest.php
Normal file
40
tests/API/MAL/ListItemTest.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* Hummingbird Anime List Client
|
||||||
|
*
|
||||||
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
|
*
|
||||||
|
* PHP version 7
|
||||||
|
*
|
||||||
|
* @package HummingbirdAnimeClient
|
||||||
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
|
* @copyright 2015 - 2017 Timothy J. Warren
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
|
* @version 4.0
|
||||||
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Aviat\AnimeClient\Tests\API\MAL;
|
||||||
|
|
||||||
|
use Aviat\AnimeClient\API\MAL\ListItem;
|
||||||
|
use Aviat\AnimeClient\API\MAL\MALRequestBuilder;
|
||||||
|
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||||
|
use Aviat\Ion\Di\ContainerAware;
|
||||||
|
|
||||||
|
class ListItemTest extends AnimeClientTestCase {
|
||||||
|
|
||||||
|
protected $listItem;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->listItem = new ListItem();
|
||||||
|
$this->listItem->setContainer($this->container);
|
||||||
|
$this->listItem->setRequestBuilder(new MALRequestBuilder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGet()
|
||||||
|
{
|
||||||
|
$this->assertEquals([], $this->listItem->get('foo'));
|
||||||
|
}
|
||||||
|
}
|
51
tests/API/MAL/MALTraitTest.php
Normal file
51
tests/API/MAL/MALTraitTest.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* Hummingbird Anime List Client
|
||||||
|
*
|
||||||
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
|
*
|
||||||
|
* PHP version 7
|
||||||
|
*
|
||||||
|
* @package HummingbirdAnimeClient
|
||||||
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
|
* @copyright 2015 - 2017 Timothy J. Warren
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
|
* @version 4.0
|
||||||
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Aviat\AnimeClient\Tests\API\MAL;
|
||||||
|
|
||||||
|
use Aviat\AnimeClient\API\MAL\MALRequestBuilder;
|
||||||
|
use Aviat\AnimeClient\API\MAL\MALTrait;
|
||||||
|
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||||
|
use Aviat\Ion\Di\ContainerAware;
|
||||||
|
|
||||||
|
class MALTraitTest extends AnimeClientTestCase {
|
||||||
|
|
||||||
|
protected $obj;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->obj = new class {
|
||||||
|
use ContainerAware;
|
||||||
|
use MALTrait;
|
||||||
|
};
|
||||||
|
$this->obj->setContainer($this->container);
|
||||||
|
$this->obj->setRequestBuilder(new MALRequestBuilder());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetupRequest()
|
||||||
|
{
|
||||||
|
$request = $this->obj->setUpRequest('GET', 'foo', [
|
||||||
|
'query' => [
|
||||||
|
'foo' => 'bar'
|
||||||
|
],
|
||||||
|
'body' => ''
|
||||||
|
]);
|
||||||
|
$this->assertInstanceOf(\Amp\Artax\Request::class, $request);
|
||||||
|
$this->assertEquals($request->getUri(), 'https://myanimelist.net/api/foo?foo=bar');
|
||||||
|
$this->assertEquals($request->getBody(), '');
|
||||||
|
}
|
||||||
|
}
|
35
tests/API/MAL/ModelTest.php
Normal file
35
tests/API/MAL/ModelTest.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* Hummingbird Anime List Client
|
||||||
|
*
|
||||||
|
* An API client for Kitsu and MyAnimeList to manage anime and manga watch lists
|
||||||
|
*
|
||||||
|
* PHP version 7
|
||||||
|
*
|
||||||
|
* @package HummingbirdAnimeClient
|
||||||
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
||||||
|
* @copyright 2015 - 2017 Timothy J. Warren
|
||||||
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
|
* @version 4.0
|
||||||
|
* @link https://git.timshomepage.net/timw4mail/HummingBirdAnimeClient
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Aviat\AnimeClient\Tests\API\MAL;
|
||||||
|
|
||||||
|
use Aviat\AnimeClient\Tests\AnimeClientTestCase;
|
||||||
|
|
||||||
|
class ModelTest extends AnimeClientTestCase {
|
||||||
|
|
||||||
|
protected $model;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->model = $this->container->get('mal-model');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetListItem()
|
||||||
|
{
|
||||||
|
$this->assertEquals([], $this->model->getListItem('foo'));
|
||||||
|
}
|
||||||
|
}
|
@ -102,6 +102,10 @@ class AnimeClientTestCase extends TestCase {
|
|||||||
'routes' => [
|
'routes' => [
|
||||||
|
|
||||||
]
|
]
|
||||||
|
],
|
||||||
|
'mal' => [
|
||||||
|
'username' => 'foo',
|
||||||
|
'password' => 'bar'
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user