Added test for basic controller validity

This commit is contained in:
Marcin Kurczewski 2014-09-06 17:51:04 +02:00
parent 7c4eddd810
commit 73214396ce
5 changed files with 27 additions and 7 deletions

View file

@ -1,9 +1,8 @@
<?php <?php
$start = microtime(true); $start = microtime(true);
define('DS', DIRECTORY_SEPARATOR); require_once(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
require_once(__DIR__ . DS . '..' . DS . 'vendor' . DS . 'autoload.php'); require_once(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'AutoLoader.php');
require_once(__DIR__ . DS . '..' . DS . 'src' . DS . 'AutoLoader.php');
$dispatcher = \Szurubooru\Injector::get(\Szurubooru\Dispatcher::class); $dispatcher = \Szurubooru\Injector::get(\Szurubooru\Dispatcher::class);
$dispatcher->run(); $dispatcher->run();

View file

@ -6,7 +6,7 @@ final class InputReader
public function __construct() public function __construct()
{ {
$_PUT = []; $_PUT = [];
if ($_SERVER['REQUEST_METHOD'] == 'PUT') if (isset($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] == 'PUT')
parse_str(file_get_contents('php://input'), $_PUT); parse_str(file_get_contents('php://input'), $_PUT);
foreach ([$_GET, $_POST, $_PUT] as $source) foreach ([$_GET, $_POST, $_PUT] as $source)

View file

@ -7,9 +7,14 @@ final class Injector
public static function init() public static function init()
{ {
$definitionsPath = __DIR__
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'src'
. DIRECTORY_SEPARATOR . 'di.php';
$builder = new \DI\ContainerBuilder(); $builder = new \DI\ContainerBuilder();
$builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache()); $builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache());
$builder->addDefinitions(__DIR__ . DS . '..' . DS . 'src' . DS . 'di.php'); $builder->addDefinitions($definitionsPath);
self::$container = $builder->build(); self::$container = $builder->build();
} }

View file

@ -1,8 +1,8 @@
<?php <?php
return [ return [
\Szurubooru\Config::class => DI\object()->constructor([ \Szurubooru\Config::class => DI\object()->constructor([
__DIR__ . DS . '..' . DS . 'data' . DS . 'config.ini', __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'config.ini',
__DIR__ . DS . '..' . DS . 'data' . DS . 'local.ini']), __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'local.ini']),
\Szurubooru\ControllerRepository::class => DI\object()->constructor(DI\link('controllers')), \Szurubooru\ControllerRepository::class => DI\object()->constructor(DI\link('controllers')),

View file

@ -0,0 +1,16 @@
<?php
namespace Szurubooru\Tests;
require_once __DIR__
. DIRECTORY_SEPARATOR . '..'
. DIRECTORY_SEPARATOR . 'vendor'
. DIRECTORY_SEPARATOR . 'autoload.php';
class ControllerRepositoryTest extends \Szurubooru\Tests\AbstractTestCase
{
public function testInjection()
{
$controllerRepository = \Szurubooru\Injector::get(\Szurubooru\ControllerRepository::class);
$this->assertNotEmpty($controllerRepository->getControllers());
}
}