diff --git a/server/composer.json b/server/composer.json index 33104af1..48bc8e7b 100755 --- a/server/composer.json +++ b/server/composer.json @@ -11,5 +11,8 @@ }, "require-dev": { "phpunit/phpunit": "^5.7" + }, + "autoload":{ + "classmap": ["libs/", "models/", "controllers/", "data/"] } } diff --git a/server/index.php b/server/index.php index 66048610..0702f045 100644 --- a/server/index.php +++ b/server/index.php @@ -15,49 +15,5 @@ if(defined('MYSQL_HOST') && defined('MYSQL_DATABASE') && defined('MYSQL_USER') & \Slim\Slim::registerAutoLoader(); $app = new \Slim\Slim(); -// LOAD LIBRARIES -include_once 'libs/Controller.php'; -include_once 'libs/ControllerGroup.php'; -include_once 'libs/Hashing.php'; -include_once 'libs/MailSender.php'; -include_once 'libs/Date.php'; -include_once 'libs/DataStoreList.php'; -include_once 'libs/LinearCongruentialGenerator.php'; -include_once 'libs/FileManager.php'; -include_once 'libs/FileDownloader.php'; -include_once 'libs/FileUploader.php'; - Controller::init(); - -// LOAD DATA -spl_autoload_register(function ($class) { - $classPath = "data/{$class}.php"; - - if(file_exists($classPath)) { - include_once $classPath; - } -}); - -// LOAD MODELS -spl_autoload_register(function ($class) { - $classPath = "models/{$class}.php"; - - if(file_exists($classPath)) { - include_once $classPath; - } -}); - -// LOAD CUSTOM VALIDATIONS -include_once 'libs/validations/dataStoreId.php'; -include_once 'libs/validations/userEmail.php'; -include_once 'libs/validations/staffEmail.php'; -include_once 'libs/validations/captcha.php'; -include_once 'libs/validations/validLanguage.php'; -include_once 'libs/validations/validTicketNumber.php'; - -// LOAD CONTROLLERS -foreach (glob('controllers/*.php') as $controller) { - include_once $controller; -} - $app->run(); diff --git a/server/tests/controllers/user/loginTest.php b/server/tests/controllers/user/loginTest.php index f86ec8b6..0cca2e80 100755 --- a/server/tests/controllers/user/loginTest.php +++ b/server/tests/controllers/user/loginTest.php @@ -10,8 +10,6 @@ include_once 'tests/__mocks__/HashingMock.php'; include_once 'tests/__mocks__/SessionCookieMock.php'; include_once 'data/ERRORS.php'; -include_once 'controllers/user/login.php'; - use PHPUnit\Framework\TestCase; class LoginControllerTest extends TestCase { diff --git a/server/tests/libs/HashingTest.php b/server/tests/libs/HashingTest.php index 9b4cfb95..966be913 100644 --- a/server/tests/libs/HashingTest.php +++ b/server/tests/libs/HashingTest.php @@ -1,6 +1,4 @@