From 0b63f810a9947787e0046f0549688a0a22f2d671 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 25 Jun 2015 17:00:29 -0400 Subject: [PATCH] First unit tests, add a few of the forgotten app requirements --- .gitignore | 4 ++- .travis.yml | 12 +++++++++ README.md | 1 + app/base/pre_conf_functions.php | 40 ++++++++++++++++++++++++++++++ app/models/MangaModel.php | 3 +++ index.php | 43 +++++++++++++++------------------ phpdoc.dist.xml | 23 ++++++++++++++++++ phpunit.xml | 16 ++++++++++++ tests/base/CoreTest.php | 22 +++++++++++++++++ tests/base/FunctionsTest.php | 23 ++++++++++++++++++ tests/bootstrap.php | 39 ++++++++++++++++++++++++++++++ 11 files changed, 201 insertions(+), 25 deletions(-) create mode 100644 .travis.yml create mode 100644 app/base/pre_conf_functions.php create mode 100644 phpdoc.dist.xml create mode 100644 phpunit.xml create mode 100644 tests/base/CoreTest.php create mode 100644 tests/base/FunctionsTest.php create mode 100644 tests/bootstrap.php diff --git a/.gitignore b/.gitignore index 3a08e110..a2b08c12 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ public/js/cache/* composer.lock *.sqlite *.db -*.sqlite3 \ No newline at end of file +*.sqlite3 +docs/* +coverage/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..52558996 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: php + +install: + - composer install + +php: + - 5.4 + - 5.5 + - 5.6 + - 7 + - hhvm + - nightly \ No newline at end of file diff --git a/README.md b/README.md index 44e77a0e..9819e1bb 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ A self-hosted client that allows custom formatting of data from the hummingbird * PHP 5.4+ * PDO SQLite (For collection tab) +* GD ### Installation diff --git a/app/base/pre_conf_functions.php b/app/base/pre_conf_functions.php new file mode 100644 index 00000000..4faadd9e --- /dev/null +++ b/app/base/pre_conf_functions.php @@ -0,0 +1,40 @@ + [], 'Plan to Read' => [], diff --git a/index.php b/index.php index 6bbf992e..1677be43 100644 --- a/index.php +++ b/index.php @@ -3,43 +3,38 @@ * Here begins everything! */ +// ----------------------------------------------------------------------------- +// ! Start config +// ----------------------------------------------------------------------------- + /** * Well, whose list is it? */ define('WHOSE', "Tim's"); -/** - * Joins paths together. Variadic to take an - * arbitrary number of arguments - * - * @return string - */ -function _dir() { return implode(DIRECTORY_SEPARATOR, func_get_args()); } +// ----------------------------------------------------------------------------- +// ! End config +// ----------------------------------------------------------------------------- + +// Work around the silly timezone error +$timezone = ini_get('date.timezone'); +if ($timezone === '' || $timezone === FALSE) +{ + ini_set('date.timezone', 'GMT'); +} define('ROOT_DIR', __DIR__); -define('APP_DIR', _dir(ROOT_DIR, 'app')); -define('CONF_DIR', _dir(APP_DIR, 'config')); -define('BASE_DIR', _dir(APP_DIR, 'base')); +define('APP_DIR', ROOT_DIR . DIRECTORY_SEPARATOR . 'app'); +define('CONF_DIR', APP_DIR . DIRECTORY_SEPARATOR . 'config'); +define('BASE_DIR', APP_DIR . DIRECTORY_SEPARATOR . 'base'); +require BASE_DIR . DIRECTORY_SEPARATOR . 'pre_conf_functions.php'; // Load config and global functions $config = require _dir(APP_DIR, '/config/config.php'); require _dir(BASE_DIR, '/functions.php'); // Setup autoloaders -require _dir(ROOT_DIR, '/vendor/autoload.php'); -spl_autoload_register(function ($class) { - $dirs = ["base", "controllers", "models"]; - - foreach($dirs as $dir) - { - $file = _dir(APP_DIR, $dir, "{$class}.php"); - if (file_exists($file)) - { - require_once $file; - return; - } - } -}); +_setup_autoloaders(); session_start(); diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml new file mode 100644 index 00000000..7dd06d43 --- /dev/null +++ b/phpdoc.dist.xml @@ -0,0 +1,23 @@ + + + Hummingbird Anime Client + + docs + + + docs + + +