Update changelog and add additional tests
This commit is contained in:
parent
1bc1d2fa31
commit
47b8a83d86
@ -1,6 +1,9 @@
|
||||
# Changelog
|
||||
|
||||
## Version 3
|
||||
* Converted user configuration to toml files
|
||||
* Added a caching layer for api calls, which resets upon updates from the
|
||||
app.
|
||||
* Removed json file "cache" from the app folder
|
||||
* Added a bulk thumbnail generator script
|
||||
* Removed json file "cache" from the app folder
|
||||
|
||||
|
3
console
3
console
@ -52,7 +52,8 @@ unset($CONF_DIR);
|
||||
// Start console script
|
||||
// ---------------------------------------------------------------------------------------------------------------------
|
||||
$console = new \ConsoleKit\Console([
|
||||
'cache-images' => '\Aviat\AnimeClient\Command\CacheImages'
|
||||
'cache-images' => '\Aviat\AnimeClient\Command\CacheImages',
|
||||
'clear-cache' => '\Aviat\AnimeClient\Command\ClearCache',
|
||||
]);
|
||||
|
||||
$console->run();
|
@ -14,6 +14,8 @@
|
||||
namespace Aviat\AnimeClient\Command;
|
||||
|
||||
use Aura\Session\SessionFactory;
|
||||
use ConsoleKit\Command;
|
||||
use ConsoleKit\Widgets\Box;
|
||||
|
||||
use Aviat\Ion\Di\Container;
|
||||
use Aviat\Ion\Cache\CacheManager;
|
||||
@ -25,9 +27,28 @@ use Aviat\AnimeClient\Model;
|
||||
/**
|
||||
* Base class for console command setup
|
||||
*/
|
||||
class BaseCommand extends \ConsoleKit\Command {
|
||||
class BaseCommand extends Command {
|
||||
use \Aviat\Ion\Di\ContainerAware;
|
||||
|
||||
/**
|
||||
* Echo text in a box
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
protected function echoBox($message)
|
||||
{
|
||||
echo "\n";
|
||||
$box = new Box($this->getConsole(), $message);
|
||||
$box->write();
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the Di container
|
||||
*
|
||||
* @return Container
|
||||
*/
|
||||
protected function setupContainer()
|
||||
{
|
||||
$CONF_DIR = __DIR__ . '/../../../../app/config/';
|
||||
|
@ -13,8 +13,6 @@
|
||||
|
||||
namespace Aviat\AnimeClient\Command;
|
||||
|
||||
use \ConsoleKit\Widgets\Box;
|
||||
|
||||
use Aviat\AnimeClient\Model;
|
||||
/**
|
||||
* Generates thumbnail image cache so that cover images load faster
|
||||
@ -25,20 +23,6 @@ class CacheImages extends BaseCommand {
|
||||
protected $animeModel;
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* Echo text in a box
|
||||
*
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
protected function echoBox($message)
|
||||
{
|
||||
echo "\n";
|
||||
$box = new Box($this->getConsole(), $message);
|
||||
$box->write();
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert manga images
|
||||
*
|
||||
|
37
src/Aviat/AnimeClient/Command/ClearCache.php
Normal file
37
src/Aviat/AnimeClient/Command/ClearCache.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Hummingbird Anime Client
|
||||
*
|
||||
* An API client for Hummingbird to manage anime and manga watch lists
|
||||
*
|
||||
* @package HummingbirdAnimeClient
|
||||
* @author Timothy J. Warren
|
||||
* @copyright Copyright (c) 2015 - 2016
|
||||
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
namespace Aviat\AnimeClient\Command;
|
||||
|
||||
/**
|
||||
* Clears the API Cache
|
||||
*/
|
||||
class ClearCache extends BaseCommand {
|
||||
/**
|
||||
* Run the image conversion script
|
||||
*
|
||||
* @param array $args
|
||||
* @param array $options
|
||||
* @return void
|
||||
* @throws \ConsoleKit\ConsoleException
|
||||
*/
|
||||
public function execute(array $args, array $options = array())
|
||||
{
|
||||
$this->setContainer($this->setupContainer());
|
||||
$cache = $this->container->get('cache');
|
||||
$cache->purge();
|
||||
|
||||
$this->echoBox('API Cache has been cleared.');
|
||||
}
|
||||
}
|
||||
// End of ClearCache.php
|
19
tests/AnimeClient/Command/BaseCommandTest.php
Normal file
19
tests/AnimeClient/Command/BaseCommandTest.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use ConsoleKit\Console;
|
||||
use Aviat\Ion\Friend;
|
||||
use Aviat\AnimeClient\Command\BaseCommand;
|
||||
|
||||
class BaseCommandTest extends AnimeClient_TestCase {
|
||||
public function setUp()
|
||||
{
|
||||
$this->base = new BaseCommand(new Console());
|
||||
$this->friend = new Friend($this->base);
|
||||
}
|
||||
|
||||
public function testSetupContainer()
|
||||
{
|
||||
$container = $this->friend->setupContainer();
|
||||
$this->assertInstanceOf('Aviat\Ion\Di\Container', $container);
|
||||
}
|
||||
}
|
36
tests/Ion/Cache/Driver/RedisDriver2Test.php
Normal file
36
tests/Ion/Cache/Driver/RedisDriver2Test.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
require_once('CacheDriverBase.php');
|
||||
|
||||
use Aviat\AnimeClient\Config;
|
||||
use Aviat\Ion\Di\Container;
|
||||
use Aviat\Ion\Cache\Driver\RedisDriver;
|
||||
|
||||
class CacheRedisDriverTestTwo extends AnimeClient_TestCase {
|
||||
use CacheDriverBase;
|
||||
|
||||
protected $driver;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Setup config with port and password
|
||||
$container = new Container();
|
||||
$container->set('config', new Config([
|
||||
'redis' => [
|
||||
'host' => 'localhost',
|
||||
'port' => 6379,
|
||||
'password' => '',
|
||||
'database' => 13,
|
||||
]
|
||||
]));
|
||||
$this->driver = new RedisDriver($container);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->driver->__destruct();
|
||||
}
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
|
||||
require_once('CacheDriverBase.php');
|
||||
|
||||
use Aviat\Ion\Friend;
|
||||
use Aviat\Ion\Cache\Driver\RedisDriver;
|
||||
|
||||
class CacheRedisDriverTest extends AnimeClient_TestCase {
|
||||
@ -15,4 +14,10 @@ class CacheRedisDriverTest extends AnimeClient_TestCase {
|
||||
parent::setUp();
|
||||
$this->driver = new RedisDriver($this->container);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
$this->driver->__destruct();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user