From 73214396cebc435b7fc47aa7a34511a6c90798d8 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 6 Sep 2014 17:51:04 +0200 Subject: [PATCH] Added test for basic controller validity --- public_html/api-dispatch.php | 5 ++--- src/Helpers/InputReader.php | 2 +- src/Injector.php | 7 ++++++- src/di.php | 4 ++-- tests/ControllerRepositoryTest.php | 16 ++++++++++++++++ 5 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 tests/ControllerRepositoryTest.php diff --git a/public_html/api-dispatch.php b/public_html/api-dispatch.php index dc7066b0..ae325a0c 100644 --- a/public_html/api-dispatch.php +++ b/public_html/api-dispatch.php @@ -1,9 +1,8 @@ run(); diff --git a/src/Helpers/InputReader.php b/src/Helpers/InputReader.php index 43f616f2..d8b72ccb 100644 --- a/src/Helpers/InputReader.php +++ b/src/Helpers/InputReader.php @@ -6,7 +6,7 @@ final class InputReader public function __construct() { $_PUT = []; - if ($_SERVER['REQUEST_METHOD'] == 'PUT') + if (isset($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] == 'PUT') parse_str(file_get_contents('php://input'), $_PUT); foreach ([$_GET, $_POST, $_PUT] as $source) diff --git a/src/Injector.php b/src/Injector.php index d6a41483..4f8b665f 100644 --- a/src/Injector.php +++ b/src/Injector.php @@ -7,9 +7,14 @@ final class Injector public static function init() { + $definitionsPath = __DIR__ + . DIRECTORY_SEPARATOR . '..' + . DIRECTORY_SEPARATOR . 'src' + . DIRECTORY_SEPARATOR . 'di.php'; + $builder = new \DI\ContainerBuilder(); $builder->setDefinitionCache(new \Doctrine\Common\Cache\ArrayCache()); - $builder->addDefinitions(__DIR__ . DS . '..' . DS . 'src' . DS . 'di.php'); + $builder->addDefinitions($definitionsPath); self::$container = $builder->build(); } diff --git a/src/di.php b/src/di.php index d75b294a..290e8ce7 100644 --- a/src/di.php +++ b/src/di.php @@ -1,8 +1,8 @@ DI\object()->constructor([ - __DIR__ . DS . '..' . DS . 'data' . DS . 'config.ini', - __DIR__ . DS . '..' . DS . 'data' . DS . 'local.ini']), + __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'config.ini', + __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'local.ini']), \Szurubooru\ControllerRepository::class => DI\object()->constructor(DI\link('controllers')), diff --git a/tests/ControllerRepositoryTest.php b/tests/ControllerRepositoryTest.php new file mode 100644 index 00000000..debe8a1d --- /dev/null +++ b/tests/ControllerRepositoryTest.php @@ -0,0 +1,16 @@ +assertNotEmpty($controllerRepository->getControllers()); + } +}