Use composer autoloader for source files (except tests)
This commit is contained in:
parent
c70868d3fa
commit
5d83143664
|
@ -11,5 +11,8 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"autoload":{
|
||||
"classmap": ["libs/", "models/", "controllers/", "data/"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
include_once 'libs/Hashing.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HashingTest extends TestCase {
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
include_once 'libs/Hashing.php';
|
||||
include_once 'libs/LinearCongruentialGenerator.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LinearCongruentialGeneratorTest extends TestCase {
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
<?php
|
||||
include_once 'tests/__lib__/Mock.php';
|
||||
include_once 'tests/__mocks__/RespectMock.php';
|
||||
include_once 'tests/__mocks__/SettingMock.php';
|
||||
include_once 'tests/__mocks__/APIKeyMock.php';
|
||||
include_once 'tests/__mocks__/ControllerMock.php';
|
||||
include_once 'tests/__mocks__/ReCaptchaMock.php';
|
||||
|
||||
include_once 'libs/validations/captcha.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class CaptchaValidationTest extends TestCase {
|
||||
|
|
|
@ -3,7 +3,6 @@ include_once 'tests/__lib__/Mock.php';
|
|||
include_once 'tests/__mocks__/BeanMock.php';
|
||||
include_once 'tests/__mocks__/SlimMock.php';
|
||||
include_once 'tests/__mocks__/RedBeanMock.php';
|
||||
include_once 'models/DataStore.php';
|
||||
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
|
@ -3,7 +3,6 @@ include_once 'tests/__lib__/Mock.php';
|
|||
include_once 'tests/__mocks__/BeanMock.php';
|
||||
include_once 'tests/__mocks__/SettingMock.php';
|
||||
include_once 'tests/__mocks__/RedBeanMock.php';
|
||||
include_once 'models/MailTemplate.php';
|
||||
|
||||
use RedBeanPHP\Facade as RedBean;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
include_once 'tests/__lib__/Mock.php';
|
||||
include_once 'tests/__mocks__/SlimMock.php';
|
||||
include_once 'models/Response.php';
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
|
Loading…
Reference in New Issue