Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
10 changed files with 51 additions and 42 deletions
Showing only changes of commit d6f9ceb5c7 - Show all commits

View File

@ -63,23 +63,38 @@ class BaseCommand extends Command {
$container = new Container();
// Create Config Object
$config = new Config($config_array);
$container->set('config', $config);
$container->set('config', function() {
return new Config();
});
$container->setInstance('config', $config_array);
// Create Cache Object
$container->set('cache', new CacheManager($config));
$container->set('cache', function($container) {
return new CacheManager($container->get('config'));
});
// Create session Object
$session = (new SessionFactory())->newInstance($_COOKIE);
$container->set('session', $session);
$container->set('session', function() {
return (new SessionFactory())->newInstance($_COOKIE);
});
// Models
$container->set('api-model', new Model\API($container));
$container->set('anime-model', new Model\Anime($container));
$container->set('manga-model', new Model\Manga($container));
$container->set('api-model', function($container) {
return new Model\API($container);
});
$container->set('anime-model', function($container) {
return new Model\Anime($container);
});
$container->set('manga-model', function($container) {
return new Model\Manga($container);
});
$container->set('auth', new HummingbirdAuth($container));
$container->set('util', new Util($container));
$container->set('auth', function($container) {
return new HummingbirdAuth($container);
});
$container->set('util', function($container) {
return new Util($container);
});
return $container;
};

View File

@ -24,7 +24,7 @@ class HummingbirdAuthTest extends AnimeClient_TestCase {
$auth = new HummingbirdAuth($this->container);
$friend = new Friend($auth);
$this->auth = $friend;
$this->container->set('session', self::$session);
$this->container->setInstance('session', self::$session);
}
public function dataAuthenticate()

View File

@ -33,7 +33,7 @@ class ControllerTest extends AnimeClient_TestCase {
'database' => '',
'file' => ":memory:"
]);
$this->container->set('config', $config);
$this->container->setInstance('config', $config);
$this->assertInstanceOf(
'Aviat\AnimeClient\Controller',

View File

@ -29,39 +29,25 @@ class DispatcherTest extends AnimeClient_TestCase {
'SERVER_NAME' => $host
]);
$request = ServerRequestFactory::fromGlobals(
$_SERVER,
$_GET,
$_POST,
$_COOKIE,
$_FILES
);
$old_config = $this->container->get('config');
$this->setSuperGlobals([
'_SERVER' => $_SERVER
]);
$logger = new Logger('test_logger');
$logger->pushHandler(new TestHandler(Logger::DEBUG));
// Add the appropriate objects to the container
$this->container = new Container([
'config' => $old_config,
'request' => $request,
'response' => new Response,
'aura-router' => new RouterContainer
]);
$this->container->setLogger($logger, 'default');
if ( ! empty($config))
{
$config = new Config($config);
$this->container->set('config', $config);
$this->container->setInstance('config', $config);
}
$this->router = new Dispatcher($this->container);
$this->config = $this->container->get('config');
$this->urlGenerator = new UrlGenerator($this->container);
$this->container->set('url-generator', $this->urlGenerator);
$this->container->setInstance('url-generator', $this->urlGenerator);
}
public function testRouterSanity()

View File

@ -43,7 +43,7 @@ class MenuHelperTest extends AnimeClient_TestCase {
// Set config for tests
$config = $this->container->get('config');
$config->set('menus', $menus);
$this->container->set('config', $config);
$this->container->setInstance('config', $config);
foreach($menus as $case => $config)
{

View File

@ -66,7 +66,7 @@ class MenuGeneratorTest extends AnimeClient_TestCase {
];
$config = $this->container->get('config');
$config->set('menus', $menus);
$this->container->set('config', $config);
$this->container->setInstance('config', $config);
$expected = '';
$this->assertEquals($expected, $this->generator->generate('manga_list'));

View File

@ -10,7 +10,7 @@ class AnimeCollectionModelTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$this->container->set('config', new Config([
$this->container->setInstance('config', new Config([
'database' => [
'collection' => [
'type' => 'sqlite',
@ -37,7 +37,7 @@ class AnimeCollectionModelTest extends AnimeClient_TestCase {
public function testInvalidDatabase()
{
$this->container->set('config', new Config([
$this->container->setInstance('config', new Config([
'database' => [
'collection' => [
'type' => 'sqlite',
@ -57,7 +57,7 @@ class AnimeCollectionModelTest extends AnimeClient_TestCase {
public function testNonExistentDatabase()
{
$this->container->set('config', new Config([
$this->container->setInstance('config', new Config([
'database' => [
'collection' => [
'type' => 'sqlite',

View File

@ -12,7 +12,7 @@ class MangaModelTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$this->container->set('util', new MockUtil($this->container));
$this->container->setInstance('util', new MockUtil($this->container));
$this->model = new Friend(new TestMangaModel($this->container));
$this->mockDir = __DIR__ . '/../../test_data/manga_list';
}

View File

@ -83,7 +83,7 @@ class UrlGeneratorTest extends AnimeClient_TestCase {
public function testFullUrl($config, $path, $type, $expected)
{
$config = new Config($config);
$this->container->set('config', $config);
$this->container->setInstance('config', $config);
$urlGenerator = new UrlGenerator($this->container);
$result = $urlGenerator->full_url($path, $type);
@ -127,7 +127,7 @@ class UrlGeneratorTest extends AnimeClient_TestCase {
public function testBaseUrl($config, $type, $expected)
{
$config = new Config($config);
$this->container->set('config', $config);
$this->container->setInstance('config', $config);
$urlGenerator = new UrlGenerator($this->container);
$result = $urlGenerator->base_url($type);

View File

@ -91,7 +91,13 @@ class AnimeClient_TestCase extends PHPUnit_Framework_TestCase {
// Set up DI container
$di = require _dir($APP_DIR, 'bootstrap.php');
$container = $di($config_array);
$container->set('session-handler', self::$session_handler);
// Use mock session handler
$container->set('session-handler', function() {
$session_handler = new TestSessionHandler();
session_set_save_handler($session_handler, TRUE);
return $session_handler;
});
$this->container = $container;
}
@ -116,8 +122,10 @@ class AnimeClient_TestCase extends PHPUnit_Framework_TestCase {
['Zend\Diactoros\ServerRequestFactory', 'fromGlobals'],
array_merge($default, $supers)
);
$this->container->set('request', $request);
$this->container->set('response', new HttpResponse());
$this->container->setInstance('request', $request);
$this->container->set('repsone', function() {
return new HttpResponse();
});
}
/**