This commit is contained in:
Markus
2022-04-28 09:40:10 +02:00
commit 795794f992
9586 changed files with 1146991 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Config;
/**
* Class BadRegistrar
*
* Doesn't provides a basic registrar class for testing BaseConfig registration functions,
* because it doesn't return an associative array
*/
class BadRegistrar
{
public static function RegistrarConfig()
{
return 'I am not worthy';
}
}

View File

@@ -0,0 +1,14 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Config\Filters;
$filters->aliases['test-customfilter'] = \Tests\Support\Filters\Customfilter::class;

View File

@@ -0,0 +1,138 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Config;
/**
* Class Registrar
*
* Provides a basic registrar class for testing BaseConfig registration functions.
*/
class Registrar
{
/**
* DB config array for testing purposes.
*
* @var array
*/
protected static $dbConfig = [
'MySQLi' => [
'DSN' => '',
'hostname' => '127.0.0.1',
'username' => 'root',
'password' => '',
'database' => 'test',
'DBDriver' => 'MySQLi',
'DBPrefix' => 'db_',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
],
'Postgre' => [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'postgres',
'password' => 'postgres',
'database' => 'test',
'DBDriver' => 'Postgre',
'DBPrefix' => 'db_',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 5432,
],
'SQLite3' => [
'DSN' => '',
'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => 'database.db',
'DBDriver' => 'SQLite3',
'DBPrefix' => 'db_',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3306,
],
'SQLSRV' => [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'sa',
'password' => '1Secure*Password1',
'database' => 'test',
'DBDriver' => 'SQLSRV',
'DBPrefix' => 'db_',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 1433,
],
];
/**
* Override database config
*
* @return array
*/
public static function Database()
{
$config = [];
// Under GitHub Actions, we can set an ENV var named 'DB'
// so that we can test against multiple databases.
if ($group = getenv('DB')) {
if (! empty(self::$dbConfig[$group])) {
$config['tests'] = self::$dbConfig[$group];
}
}
return $config;
}
/**
* Demonstrates Publisher security.
*
* @see PublisherRestrictionsTest::testRegistrarsNotAllowed()
*
* @return array
*/
public static function Publisher()
{
return [
'restrictions' => [SUPPORTPATH => '*'],
];
}
}

View File

@@ -0,0 +1,15 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Config;
// This is a simple file to include for testing the RouteCollection class.
$routes->add('testing', 'TestController::index', ['as' => 'testing-index']);

View File

@@ -0,0 +1,46 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Config;
use CodeIgniter\HTTP\URI;
use Config\Services as BaseServices;
use RuntimeException;
/**
* Services Class
*
* Provides a replacement uri Service
* to demonstrate overriding core services.
*/
class Services extends BaseServices
{
/**
* The URI class provides a way to model and manipulate URIs.
*
* @param string $uri
*
* @return URI
*/
public static function uri(?string $uri = null, bool $getShared = true)
{
// Intercept our test case
if ($uri === 'testCanReplaceFrameworkServices') {
throw new RuntimeException('Service originated from ' . static::class);
}
if ($getShared) {
return static::getSharedInstance('uri', $uri);
}
return new URI($uri);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* This file is part of CodeIgniter 4 framework.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support\Config;
/**
* Class Registrar
*
* Provides a basic registrar class for testing BaseConfig registration functions.
*/
class TestRegistrar
{
public static function RegistrarConfig()
{
return [
'bar' => [
'first',
'second',
],
'format' => 'nice',
'fruit' => [
'apple',
'banana',
],
];
}
}