Move tests to root directory

This commit is contained in:
Matt Lorimer 2019-12-23 17:13:46 +00:00 committed by Dillon-Brown
parent e212c81a3a
commit 9a1442f726
35 changed files with 42 additions and 58 deletions

2
.gitignore vendored
View file

@ -16,7 +16,7 @@ public/
*.min.css
# Tests
core/tests/coverage
tests/coverage
# Composer
vendor/

View file

@ -1,3 +0,0 @@
#!/bin/bash
php "$PWD"/../../vendor/bin/phpunit $@;

3
tests/phpunit.sh Normal file
View file

@ -0,0 +1,3 @@
#!/bin/bash
php "$PWD"/../vendor/bin/phpunit $@;

View file

@ -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 @@
<filter>
<whitelist>
<directory suffix=".php">../base</directory>
<directory suffix=".php">../modules</directory>
<directory suffix=".php">../core/base</directory>
<directory suffix=".php">../core/modules</directory>
<directory suffix=".php">../legacy</directory>
</whitelist>
</filter>

View file

@ -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();

View file

@ -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'));
}

View file

@ -3,7 +3,6 @@
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use SuiteCRM\Core\Base\Helper\Data\Collection;
final class DataCollectionTest extends TestCase

View file

@ -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

View file

@ -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);
}

View file

@ -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]);
}
}

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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();