diff --git a/.gitignore b/.gitignore index af9cf0ee3..0771c3c9b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,7 @@ public/ *.min.css # Tests -core/tests/coverage +tests/coverage # Composer vendor/ diff --git a/core/tests/phpunit.sh b/core/tests/phpunit.sh deleted file mode 100644 index d3d6d25bb..000000000 --- a/core/tests/phpunit.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -php "$PWD"/../../vendor/bin/phpunit $@; diff --git a/tests/phpunit.sh b/tests/phpunit.sh new file mode 100644 index 000000000..08e3d3a3f --- /dev/null +++ b/tests/phpunit.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +php "$PWD"/../vendor/bin/phpunit $@; diff --git a/core/tests/phpunit.xml.dist b/tests/phpunit.xml.dist similarity index 85% rename from core/tests/phpunit.xml.dist rename to tests/phpunit.xml.dist index a6e2962f2..4d21a2478 100644 --- a/core/tests/phpunit.xml.dist +++ b/tests/phpunit.xml.dist @@ -4,7 +4,7 @@ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/3.7/phpunit.xsd" backupGlobals="true" backupStaticAttributes="false" - bootstrap="../../vendor/autoload.php" + bootstrap="../vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" @@ -21,8 +21,8 @@ - ../base - ../modules + ../core/base + ../core/modules ../legacy diff --git a/core/tests/testdata/CommandMapperTest/config.yml b/tests/testdata/CommandMapperTest/config.yml similarity index 100% rename from core/tests/testdata/CommandMapperTest/config.yml rename to tests/testdata/CommandMapperTest/config.yml diff --git a/core/tests/testdata/CommandMapperTest/noenabledmodules.config.yml b/tests/testdata/CommandMapperTest/noenabledmodules.config.yml similarity index 100% rename from core/tests/testdata/CommandMapperTest/noenabledmodules.config.yml rename to tests/testdata/CommandMapperTest/noenabledmodules.config.yml diff --git a/core/tests/testdata/ConfigTest/LoadEmpty/config.yml b/tests/testdata/ConfigTest/LoadEmpty/config.yml similarity index 100% rename from core/tests/testdata/ConfigTest/LoadEmpty/config.yml rename to tests/testdata/ConfigTest/LoadEmpty/config.yml diff --git a/core/tests/testdata/ConfigTest/LoadMultiple/config_1.yml b/tests/testdata/ConfigTest/LoadMultiple/config_1.yml similarity index 100% rename from core/tests/testdata/ConfigTest/LoadMultiple/config_1.yml rename to tests/testdata/ConfigTest/LoadMultiple/config_1.yml diff --git a/core/tests/testdata/ConfigTest/LoadMultiple/config_2.yml b/tests/testdata/ConfigTest/LoadMultiple/config_2.yml similarity index 100% rename from core/tests/testdata/ConfigTest/LoadMultiple/config_2.yml rename to tests/testdata/ConfigTest/LoadMultiple/config_2.yml diff --git a/core/tests/testdata/ConfigTest/LoadMultiple/config_3.yml b/tests/testdata/ConfigTest/LoadMultiple/config_3.yml similarity index 100% rename from core/tests/testdata/ConfigTest/LoadMultiple/config_3.yml rename to tests/testdata/ConfigTest/LoadMultiple/config_3.yml diff --git a/core/tests/testdata/ConfigTest/LoadSingle/config.yml b/tests/testdata/ConfigTest/LoadSingle/config.yml similarity index 100% rename from core/tests/testdata/ConfigTest/LoadSingle/config.yml rename to tests/testdata/ConfigTest/LoadSingle/config.yml diff --git a/core/tests/testdata/InstanceTest/config.yml b/tests/testdata/InstanceTest/config.yml similarity index 100% rename from core/tests/testdata/InstanceTest/config.yml rename to tests/testdata/InstanceTest/config.yml diff --git a/core/tests/testdata/ModuleMapper/config.yml b/tests/testdata/ModuleMapper/config.yml similarity index 100% rename from core/tests/testdata/ModuleMapper/config.yml rename to tests/testdata/ModuleMapper/config.yml diff --git a/core/tests/testdata/ModuleMapper/noenabledmodules.config.yml b/tests/testdata/ModuleMapper/noenabledmodules.config.yml similarity index 100% rename from core/tests/testdata/ModuleMapper/noenabledmodules.config.yml rename to tests/testdata/ModuleMapper/noenabledmodules.config.yml diff --git a/core/tests/testdata/RouterTest/DefaultRouter/config.yml b/tests/testdata/RouterTest/DefaultRouter/config.yml similarity index 100% rename from core/tests/testdata/RouterTest/DefaultRouter/config.yml rename to tests/testdata/RouterTest/DefaultRouter/config.yml diff --git a/core/tests/testdata/RouterTest/DefaultRouter/defaultaction.config.yml b/tests/testdata/RouterTest/DefaultRouter/defaultaction.config.yml similarity index 100% rename from core/tests/testdata/RouterTest/DefaultRouter/defaultaction.config.yml rename to tests/testdata/RouterTest/DefaultRouter/defaultaction.config.yml diff --git a/core/tests/testdata/RouterTest/DefaultRouter/defaultcontroller.config.yml b/tests/testdata/RouterTest/DefaultRouter/defaultcontroller.config.yml similarity index 100% rename from core/tests/testdata/RouterTest/DefaultRouter/defaultcontroller.config.yml rename to tests/testdata/RouterTest/DefaultRouter/defaultcontroller.config.yml diff --git a/core/tests/testdata/RouterTest/DefaultRouter/defaultmodule.config.yml b/tests/testdata/RouterTest/DefaultRouter/defaultmodule.config.yml similarity index 100% rename from core/tests/testdata/RouterTest/DefaultRouter/defaultmodule.config.yml rename to tests/testdata/RouterTest/DefaultRouter/defaultmodule.config.yml diff --git a/core/tests/testdata/RouterTest/ModRewriteRouter/config.yml b/tests/testdata/RouterTest/ModRewriteRouter/config.yml similarity index 100% rename from core/tests/testdata/RouterTest/ModRewriteRouter/config.yml rename to tests/testdata/RouterTest/ModRewriteRouter/config.yml diff --git a/core/tests/testdata/RouterTest/ModRewriteRouter/defaultaction.config.yml b/tests/testdata/RouterTest/ModRewriteRouter/defaultaction.config.yml similarity index 100% rename from core/tests/testdata/RouterTest/ModRewriteRouter/defaultaction.config.yml rename to tests/testdata/RouterTest/ModRewriteRouter/defaultaction.config.yml diff --git a/core/tests/testdata/RouterTest/ModRewriteRouter/defaultcontroller.config.yml b/tests/testdata/RouterTest/ModRewriteRouter/defaultcontroller.config.yml similarity index 100% rename from core/tests/testdata/RouterTest/ModRewriteRouter/defaultcontroller.config.yml rename to tests/testdata/RouterTest/ModRewriteRouter/defaultcontroller.config.yml diff --git a/core/tests/testdata/RouterTest/ModRewriteRouter/defaultmodule.config.yml b/tests/testdata/RouterTest/ModRewriteRouter/defaultmodule.config.yml similarity index 100% rename from core/tests/testdata/RouterTest/ModRewriteRouter/defaultmodule.config.yml rename to tests/testdata/RouterTest/ModRewriteRouter/defaultmodule.config.yml diff --git a/core/tests/unit/phpunit/base/Cli/CommandMapperTest.php b/tests/unit/phpunit/base/Cli/CommandMapperTest.php similarity index 87% rename from core/tests/unit/phpunit/base/Cli/CommandMapperTest.php rename to tests/unit/phpunit/base/Cli/CommandMapperTest.php index 7576b450d..b7b44e779 100644 --- a/core/tests/unit/phpunit/base/Cli/CommandMapperTest.php +++ b/tests/unit/phpunit/base/Cli/CommandMapperTest.php @@ -2,9 +2,8 @@ declare(strict_types=1); -use PHPUnit\Framework\TestCase; use PHPUnit\Framework\Error\Error; - +use PHPUnit\Framework\TestCase; use SuiteCRM\Core\Base\Cli\CommandMapper; final class CommandMapperTest extends TestCase @@ -38,7 +37,7 @@ final class CommandMapperTest extends TestCase $this->commandMapper = new CommandMapper($this->file, $this->configParameters, $configPath); - $this->assertInstanceOf('SuiteCRM\Core\Base\Cli\CommandMapper', $this->commandMapper); + $this->assertInstanceOf(CommandMapper::class, $this->commandMapper); } public function testCommandMapperWithoutConfig(): void @@ -56,7 +55,7 @@ final class CommandMapperTest extends TestCase $this->commandMapper = new CommandMapper($this->file, $this->configParameters, $configPath); - $this->assertInstanceOf('SuiteCRM\Core\Base\Cli\CommandMapper', $this->commandMapper); + $this->assertInstanceOf(CommandMapper::class, $this->commandMapper); $modules = $this->commandMapper->getAllCommands(); @@ -69,7 +68,7 @@ final class CommandMapperTest extends TestCase $this->commandMapper = new CommandMapper($this->file, $this->configParameters, $configPath); - $this->assertInstanceOf('SuiteCRM\Core\Base\Cli\CommandMapper', $this->commandMapper); + $this->assertInstanceOf(CommandMapper::class, $this->commandMapper); $modules = $this->commandMapper->getAllCommands(); diff --git a/core/tests/unit/phpunit/base/Cli/SuiteCommand.php b/tests/unit/phpunit/base/Cli/SuiteCommandTest.php similarity index 100% rename from core/tests/unit/phpunit/base/Cli/SuiteCommand.php rename to tests/unit/phpunit/base/Cli/SuiteCommandTest.php diff --git a/core/tests/unit/phpunit/base/Config/ConfigTest.php b/tests/unit/phpunit/base/Config/ConfigTest.php similarity index 94% rename from core/tests/unit/phpunit/base/Config/ConfigTest.php rename to tests/unit/phpunit/base/Config/ConfigTest.php index d86509a71..85a45d5b5 100644 --- a/core/tests/unit/phpunit/base/Config/ConfigTest.php +++ b/tests/unit/phpunit/base/Config/ConfigTest.php @@ -3,9 +3,7 @@ declare(strict_types=1); use PHPUnit\Framework\TestCase; - use SuiteCRM\Core\Base\Config\Manager as ConfigManager; -use SuiteCRM\Core\Base\Config\ParameterCollection; final class ConfigTest extends TestCase { @@ -69,7 +67,6 @@ final class ConfigTest extends TestCase ) ); - $this->assertInstanceOf('SuiteCRM\Core\Base\Config\ParameterCollection', $configParameters); $this->assertTrue($configParameters->has('config.data_1')); } diff --git a/core/tests/unit/phpunit/base/Helper/DataCollectionTest.php b/tests/unit/phpunit/base/Helper/DataCollectionTest.php similarity index 99% rename from core/tests/unit/phpunit/base/Helper/DataCollectionTest.php rename to tests/unit/phpunit/base/Helper/DataCollectionTest.php index 100a8acea..27105fe52 100644 --- a/core/tests/unit/phpunit/base/Helper/DataCollectionTest.php +++ b/tests/unit/phpunit/base/Helper/DataCollectionTest.php @@ -3,7 +3,6 @@ declare(strict_types=1); use PHPUnit\Framework\TestCase; - use SuiteCRM\Core\Base\Helper\Data\Collection; final class DataCollectionTest extends TestCase diff --git a/core/tests/unit/phpunit/base/Helper/FileHelperTest.php b/tests/unit/phpunit/base/Helper/FileHelperTest.php similarity index 99% rename from core/tests/unit/phpunit/base/Helper/FileHelperTest.php rename to tests/unit/phpunit/base/Helper/FileHelperTest.php index 8bb040ed5..f313b9731 100644 --- a/core/tests/unit/phpunit/base/Helper/FileHelperTest.php +++ b/tests/unit/phpunit/base/Helper/FileHelperTest.php @@ -3,7 +3,6 @@ declare(strict_types=1); use PHPUnit\Framework\TestCase; - use SuiteCRM\Core\Base\Helper\File\File as FileHelper; final class FileHelperTest extends TestCase diff --git a/core/tests/unit/phpunit/base/LoadInstanceTest.php b/tests/unit/phpunit/base/LoadInstanceTest.php similarity index 95% rename from core/tests/unit/phpunit/base/LoadInstanceTest.php rename to tests/unit/phpunit/base/LoadInstanceTest.php index 541eef8f6..4a789b96d 100644 --- a/core/tests/unit/phpunit/base/LoadInstanceTest.php +++ b/tests/unit/phpunit/base/LoadInstanceTest.php @@ -2,11 +2,9 @@ declare(strict_types=1); -use SuiteCRM\Core\Base\Config\Manager as ConfigManager; - -use SuiteCRM\Core\Base\Instance; - use PHPUnit\Framework\TestCase; +use SuiteCRM\Core\Base\Instance; +use SuiteCRM\Core\Modules\Users\Controller\Oauth; final class LoadInstanceTest extends TestCase { @@ -97,7 +95,7 @@ final class LoadInstanceTest extends TestCase $route = $this->instance->getRoute(); $this->assertSame('Users', $route->module); - $this->assertSame('SuiteCRM\Core\Modules\Users\Controller\Oauth', $route->controller); + $this->assertSame(Oauth::class, $route->controller); $this->assertSame('actionLogin', $route->action); } diff --git a/core/tests/unit/phpunit/base/Module/ModuleMapperTest.php b/tests/unit/phpunit/base/Module/ModuleMapperTest.php similarity index 71% rename from core/tests/unit/phpunit/base/Module/ModuleMapperTest.php rename to tests/unit/phpunit/base/Module/ModuleMapperTest.php index b98f01786..d46d5f53c 100644 --- a/core/tests/unit/phpunit/base/Module/ModuleMapperTest.php +++ b/tests/unit/phpunit/base/Module/ModuleMapperTest.php @@ -3,11 +3,9 @@ declare(strict_types=1); use PHPUnit\Framework\TestCase; - -use SuiteCRM\Core\Base\Module\ModuleMapper; - use SuiteCRM\Core\Base\Config\Manager as ConfigManager; -use SuiteCRM\Core\Base\Config\ParameterCollection; +use SuiteCRM\Core\Base\Module\ModuleMapper; +use SuiteCRM\Core\Modules\Users\Users; final class ModuleMapperTest extends TestCase { @@ -19,12 +17,12 @@ final class ModuleMapperTest extends TestCase // Get the Base Path if (!defined('BASE_PATH')) { - define('BASE_PATH', __DIR__ . '/../../../../../'); + define('BASE_PATH', dirname(__DIR__, 5) . '/'); } // Get the Application Path if (!defined('APP_PATH')) { - define('APP_PATH', BASE_PATH . '/modules'); + define('APP_PATH', BASE_PATH . '/core/modules'); } $this->fileHelper = new SuiteCRM\Core\Base\Helper\File\File(); @@ -41,12 +39,12 @@ final class ModuleMapperTest extends TestCase ); $filePaths = [ - __DIR__ . '/../../../../../modules' + BASE_PATH . '/core/modules' ]; $moduleMapper = new ModuleMapper($filePaths, $this->fileHelper, $configParameters); - $this->assertCount(1, count($moduleMapper->checkModulesExist(['Users']))); + $this->assertCount(1, $moduleMapper->checkModulesExist(['Users'])); } public function testGetModuleClassesFromFileName(): void @@ -59,18 +57,16 @@ final class ModuleMapperTest extends TestCase ] ); - $filePaths = [ - __DIR__ . '/../../../../../modules' - ]; + $filePaths = [BASE_PATH . '/core/modules']; $moduleMapper = new ModuleMapper($filePaths, $this->fileHelper, $configParameters); $moduleClasses = $moduleMapper->getModuleClassesFromFileName( [ - realpath(__DIR__ . '/../../../../../modules/Users/Users.php') + realpath(BASE_PATH . '/core/modules/Users/Users.php') ] ); - $this->assertInstanceOf('SuiteCRM\Core\Modules\Users\Users', $moduleClasses[0]); + $this->assertInstanceOf(Users::class, $moduleClasses[0]); } } \ No newline at end of file diff --git a/core/tests/unit/phpunit/base/Router/DefaultRouterTest.php b/tests/unit/phpunit/base/Router/DefaultRouterTest.php similarity index 92% rename from core/tests/unit/phpunit/base/Router/DefaultRouterTest.php rename to tests/unit/phpunit/base/Router/DefaultRouterTest.php index b19881dfa..0eedafae0 100644 --- a/core/tests/unit/phpunit/base/Router/DefaultRouterTest.php +++ b/tests/unit/phpunit/base/Router/DefaultRouterTest.php @@ -3,19 +3,16 @@ declare(strict_types=1); use PHPUnit\Framework\TestCase; - use SuiteCRM\Core\Base\Helper\File\File as FileHelper; use SuiteCRM\Core\Base\Instance; final class DefaultRouterTest extends TestCase { - protected $request; - - protected $config; - protected $fileHelper; + protected $instance; + public function setUp() { // Get the Application Path @@ -48,7 +45,7 @@ final class DefaultRouterTest extends TestCase $route = new stdClass(); - $this->assertInstanceOf('SuiteCRM\Core\Base\Helper\File\File', $this->fileHelper); + $this->assertInstanceOf(FileHelper::class, $this->fileHelper); $moduleManager = new SuiteCRM\Core\Base\Module\Manager($configParameters, $this->fileHelper); @@ -105,7 +102,7 @@ final class DefaultRouterTest extends TestCase $this->instance = new Instance($configParameters, $route, $moduleManager); - $this->assertInstanceOf('SuiteCRM\Core\Base\Instance', $this->instance); + $this->assertInstanceOf(Instance::class, $this->instance); } public function testNoController(): void @@ -123,7 +120,7 @@ final class DefaultRouterTest extends TestCase $route = new stdClass(); - $this->assertInstanceOf('SuiteCRM\Core\Base\Helper\File\File', $this->fileHelper); + $this->assertInstanceOf(FileHelper::class, $this->fileHelper); $moduleManager = new SuiteCRM\Core\Base\Module\Manager($configParameters, $this->fileHelper); @@ -181,7 +178,7 @@ final class DefaultRouterTest extends TestCase $this->instance = new Instance($configParameters, $route, $moduleManager); - $this->assertInstanceOf('SuiteCRM\Core\Base\Instance', $this->instance); + $this->assertInstanceOf(Instance::class, $this->instance); } public function testNoAction(): void @@ -196,7 +193,7 @@ final class DefaultRouterTest extends TestCase $route = new stdClass(); - $this->assertInstanceOf('SuiteCRM\Core\Base\Helper\File\File', $this->fileHelper); + $this->assertInstanceOf(FileHelper::class, $this->fileHelper); $moduleManager = new SuiteCRM\Core\Base\Module\Manager($configParameters, $this->fileHelper); @@ -254,7 +251,7 @@ final class DefaultRouterTest extends TestCase $this->instance = new Instance($configParameters, $route, $moduleManager); - $this->assertInstanceOf('SuiteCRM\Core\Base\Instance', $this->instance); + $this->assertInstanceOf(Instance::class, $this->instance); } } \ No newline at end of file diff --git a/core/tests/unit/phpunit/base/Router/ModRewriteRouterTest.php b/tests/unit/phpunit/base/Router/ModRewriteRouterTest.php similarity index 93% rename from core/tests/unit/phpunit/base/Router/ModRewriteRouterTest.php rename to tests/unit/phpunit/base/Router/ModRewriteRouterTest.php index 25400aa05..55aa3f284 100644 --- a/core/tests/unit/phpunit/base/Router/ModRewriteRouterTest.php +++ b/tests/unit/phpunit/base/Router/ModRewriteRouterTest.php @@ -3,7 +3,6 @@ declare(strict_types=1); use PHPUnit\Framework\TestCase; - use SuiteCRM\Core\Base\Helper\File\File as FileHelper; use SuiteCRM\Core\Base\Instance; @@ -16,6 +15,8 @@ final class ModRewriteRouterTest extends TestCase protected $fileHelper; + protected $instance; + public function setUp() { // Get the Application Path @@ -51,7 +52,7 @@ final class ModRewriteRouterTest extends TestCase $route = new stdClass(); - $this->assertInstanceOf('SuiteCRM\Core\Base\Helper\File\File', $this->fileHelper); + $this->assertInstanceOf(FileHelper::class, $this->fileHelper); $moduleManager = new SuiteCRM\Core\Base\Module\Manager($configParameters, $this->fileHelper); @@ -111,7 +112,7 @@ final class ModRewriteRouterTest extends TestCase $this->instance = new Instance($configParameters, $route, $moduleManager); - $this->assertInstanceOf('SuiteCRM\Core\Base\Instance', $this->instance); + $this->assertInstanceOf(Instance::class, $this->instance); } public function testNoController(): void @@ -131,7 +132,7 @@ final class ModRewriteRouterTest extends TestCase $route = new stdClass(); - $this->assertInstanceOf('SuiteCRM\Core\Base\Helper\File\File', $this->fileHelper); + $this->assertInstanceOf(FileHelper::class, $this->fileHelper); $moduleManager = new SuiteCRM\Core\Base\Module\Manager($configParameters, $this->fileHelper); @@ -191,7 +192,7 @@ final class ModRewriteRouterTest extends TestCase $this->instance = new Instance($configParameters, $route, $moduleManager); - $this->assertInstanceOf('SuiteCRM\Core\Base\Instance', $this->instance); + $this->assertInstanceOf(Instance::class, $this->instance); } public function testNoModule(): void @@ -211,7 +212,7 @@ final class ModRewriteRouterTest extends TestCase $route = new stdClass(); - $this->assertInstanceOf('SuiteCRM\Core\Base\Helper\File\File', $this->fileHelper); + $this->assertInstanceOf(FileHelper::class, $this->fileHelper); $moduleManager = new SuiteCRM\Core\Base\Module\Manager($configParameters, $this->fileHelper); @@ -273,6 +274,6 @@ final class ModRewriteRouterTest extends TestCase $this->instance = new Instance($configParameters, $route, $moduleManager); - $this->assertInstanceOf('SuiteCRM\Core\Base\Instance', $this->instance); + $this->assertInstanceOf(Instance::class, $this->instance); } } \ No newline at end of file diff --git a/core/tests/unit/phpunit/legacy/AuthenticationServiceTest.php b/tests/unit/phpunit/legacy/AuthenticationServiceTest.php similarity index 90% rename from core/tests/unit/phpunit/legacy/AuthenticationServiceTest.php rename to tests/unit/phpunit/legacy/AuthenticationServiceTest.php index 0011ad9e4..9f88ad1d5 100644 --- a/core/tests/unit/phpunit/legacy/AuthenticationServiceTest.php +++ b/tests/unit/phpunit/legacy/AuthenticationServiceTest.php @@ -2,16 +2,14 @@ declare(strict_types=1); -use SuiteCRM\Core\Base\Config\Manager as ConfigManager; - -use SuiteCRM\Core\Base\Instance; - use PHPUnit\Framework\TestCase; -use SuiteCRM\Core\Legacy\AuthenticationService; use SuiteCRM\Core\Legacy\Authentication; +use SuiteCRM\Core\Legacy\AuthenticationService; final class AuthenticationServiceTest extends TestCase { + protected $authenticationService; + public function setUp() { $this->authenticationService = new AuthenticationService(); diff --git a/core/tests/unit/phpunit/legacy/AuthenticationTest.php b/tests/unit/phpunit/legacy/AuthenticationTest.php similarity index 100% rename from core/tests/unit/phpunit/legacy/AuthenticationTest.php rename to tests/unit/phpunit/legacy/AuthenticationTest.php diff --git a/core/tests/unit/phpunit/legacy/NavbarServiceTest.php b/tests/unit/phpunit/legacy/NavbarServiceTest.php similarity index 100% rename from core/tests/unit/phpunit/legacy/NavbarServiceTest.php rename to tests/unit/phpunit/legacy/NavbarServiceTest.php diff --git a/core/tests/unit/phpunit/legacy/NavbarTest.php b/tests/unit/phpunit/legacy/NavbarTest.php similarity index 100% rename from core/tests/unit/phpunit/legacy/NavbarTest.php rename to tests/unit/phpunit/legacy/NavbarTest.php