umstellung auf shared codeigniter und postgres php8.2

This commit is contained in:
Markus
2022-09-18 14:07:38 +02:00
parent 22437db1c3
commit 8d16903e40
11628 changed files with 169929 additions and 1139112 deletions

View File

@@ -1,61 +0,0 @@
<?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\Autoloader;
use CodeIgniter\Autoloader\FileLocator;
use RuntimeException;
/**
* Class FatalLocator
*
* A locator replacement designed to throw
* exceptions when used to indicate when
* a lookup actually happens.
*/
class FatalLocator extends FileLocator
{
/**
* Throws.
*
* @param string $file The namespaced file to locate
* @param string $folder The folder within the namespace that we should look for the file.
* @param string $ext The file extension the file should have.
*
* @return false|string The path to the file, or false if not found.
*/
public function locateFile(string $file, ?string $folder = null, string $ext = 'php')
{
$folder = $folder ?? 'null';
throw new RuntimeException("locateFile({$file}, {$folder}, {$ext})");
}
/**
* Searches through all of the defined namespaces looking for a file.
* Returns an array of all found locations for the defined file.
*
* Example:
*
* $locator->search('Config/Routes.php');
* // Assuming PSR4 namespaces include foo and bar, might return:
* [
* 'app/Modules/foo/Config/Routes.php',
* 'app/Modules/bar/Config/Routes.php',
* ]
*/
public function search(string $path, string $ext = 'php', bool $prioritizeApp = true): array
{
$prioritizeApp = $prioritizeApp ? 'true' : 'false';
throw new RuntimeException("search({$path}, {$ext}, {$prioritizeApp})");
}
}

View File

@@ -1,14 +0,0 @@
<?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.
*/
class UnnamespacedClass
{
}

View File

@@ -1,21 +0,0 @@
<?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.
*/
if (! function_exists('autoload_foo')) {
function autoload_foo(): string
{
return 'I am autoloaded by Autoloader through $files!';
}
}
if (! defined('AUTOLOAD_CONSTANT')) {
define('AUTOLOAD_CONSTANT', 'foo');
}

View File

@@ -1,26 +0,0 @@
<?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\Cache;
use CodeIgniter\Cache\Handlers\DummyHandler;
/**
* Handler with unnecessarily restrictive
* key limit for testing validateKey.
*/
class RestrictiveHandler extends DummyHandler
{
/**
* Maximum key length.
*/
public const MAX_KEY_LENGTH = 10;
}

View File

@@ -1,21 +0,0 @@
<?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\Commands;
use CodeIgniter\CLI\BaseCommand;
abstract class AbstractInfo extends BaseCommand
{
protected $group = 'demo';
protected $name = 'app:pablo';
protected $description = 'Displays basic application information.';
}

View File

@@ -1,44 +0,0 @@
<?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\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\CodeIgniter;
use RuntimeException;
class AppInfo extends BaseCommand
{
protected $group = 'demo';
protected $name = 'app:info';
protected $arguments = ['draft' => 'unused'];
protected $description = 'Displays basic application information.';
public function run(array $params)
{
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red'));
}
public function bomb()
{
try {
CLI::color('test', 'white', 'Background');
} catch (RuntimeException $oops) {
$this->showError($oops);
}
}
public function helpme()
{
$this->call('help');
}
}

View File

@@ -1,11 +0,0 @@
<?php
use Config\App;
use CodeIgniter\CLI\CLI;
return [
'foo' => 'The command will use this as foo.',
'bar' => 'The command will use this as bar.',
'baz' => 'The baz is here.',
'bas' => CLI::color('bas', 'green') . (new App())->baseURL,
];

View File

@@ -1,34 +0,0 @@
<?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\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
use CodeIgniter\CodeIgniter;
use ReflectionException;
class InvalidCommand extends BaseCommand
{
protected $group = 'demo';
protected $name = 'app:invalid';
protected $description = '';
public function __construct()
{
throw new ReflectionException();
}
public function run(array $params)
{
CLI::write('CI Version: ' . CLI::color(CodeIgniter::CI_VERSION, 'red'));
}
}

View File

@@ -1,49 +0,0 @@
<?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\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\GeneratorTrait;
class LanguageCommand extends BaseCommand
{
use GeneratorTrait;
protected $group = 'Generators';
protected $name = 'publish:language';
protected $description = 'Publishes a language file.';
protected $usage = 'publish:language [options]';
protected $options = [
'--lang' => 'The language folder to save the file.',
'--sort' => 'Turn on/off the sortImports flag.',
];
public function run(array $params)
{
$this->setHasClassName(false);
$params[0] = 'Foobar';
$params['lang'] = $params['lang'] ?? 'en';
$this->component = 'Language';
$this->directory = 'Language\\' . $params['lang'];
$sort = (isset($params['sort']) && $params['sort'] === 'off') ? false : true;
$this->setSortImports($sort);
$this->execute($params);
}
protected function prepare(string $class): string
{
return file_get_contents(__DIR__ . '/Foobar.php') ?: '';
}
}

View File

@@ -1,28 +0,0 @@
<?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\Commands;
use CodeIgniter\CLI\BaseCommand;
class ParamsReveal extends BaseCommand
{
protected $group = 'demo';
protected $name = 'reveal';
protected $usage = 'reveal [options] [arguments]';
protected $description = 'Reveal params';
public static $args;
public function run(array $params)
{
static::$args = $params;
}
}

View File

@@ -1,77 +0,0 @@
<?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\Commands;
use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\GeneratorTrait;
class Unsuffixable extends BaseCommand
{
use GeneratorTrait;
/**
* The Command's Group
*
* @var string
*/
protected $group = 'Generators';
/**
* The Command's Name
*
* @var string
*/
protected $name = 'make:foo';
/**
* The Command's Description
*
* @var string
*/
protected $description = '';
/**
* The Command's Usage
*
* @var string
*/
protected $usage = 'make:foo [arguments] [options]';
/**
* The Command's Arguments
*
* @var array
*/
protected $arguments = [
'name' => 'Class name',
];
/**
* The Command's Options
*
* @var array
*/
protected $options = [];
/**
* Actually execute a command.
*/
public function run(array $params)
{
$this->component = 'Command';
$this->directory = 'Commands';
$this->template = 'command.tpl.php';
$this->setEnabledSuffixing(false);
$this->execute($params);
}
}

View File

@@ -1,26 +0,0 @@
<?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

@@ -1,14 +0,0 @@
<?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

@@ -1,138 +0,0 @@
<?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

@@ -1,15 +0,0 @@
<?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

@@ -1,46 +0,0 @@
<?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

@@ -1,35 +0,0 @@
<?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',
],
];
}
}

View File

@@ -1,22 +0,0 @@
<?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 App\Controllers;
use CodeIgniter\Controller;
class Hello extends Controller
{
public function index()
{
return 'Hello';
}
}

View File

@@ -1,92 +0,0 @@
<?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\Controllers;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use RuntimeException;
/**
* This is a testing only controller, intended to blow up in multiple
* ways to make sure we catch them.
*/
class Popcorn extends Controller
{
use ResponseTrait;
public function index()
{
return 'Hi there';
}
public function pop()
{
$this->respond('Oops', 567, 'Surprise');
}
public function popper()
{
throw new RuntimeException('Surprise', 500);
}
public function weasel()
{
$this->respond('', 200);
}
public function oops()
{
$this->failUnauthorized();
}
public function goaway()
{
return redirect()->to('/');
}
/**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/1834
*/
public function index3()
{
return $this->response->setJSON(['lang' => $this->request->getLocale()]);
}
public function canyon()
{
echo 'Hello-o-o ' . $this->request->getGet('foo');
}
public function cat()
{
}
public function json()
{
$this->respond(['answer' => 42]);
}
public function xml()
{
$this->respond('<my><pet>cat</pet></my>');
}
public function toindex()
{
return redirect()->route('testing-index');
}
public function echoJson()
{
return $this->response->setJSON($this->request->getJSON());
}
}

View File

@@ -1,172 +0,0 @@
<?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\Database\Migrations;
use CodeIgniter\Database\Migration;
class Migration_Create_test_tables extends Migration
{
public function up()
{
// User Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 80],
'email' => ['type' => 'VARCHAR', 'constraint' => 100],
'country' => ['type' => 'VARCHAR', 'constraint' => 40],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
'deleted_at' => ['type' => 'DATETIME', 'null' => true],
])->addKey('id', true)->createTable('user', true);
// Job Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 40],
'description' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
'created_at' => ['type' => 'INTEGER', 'constraint' => 11, 'null' => true],
'updated_at' => ['type' => 'INTEGER', 'constraint' => 11, 'null' => true],
'deleted_at' => ['type' => 'INTEGER', 'constraint' => 11, 'null' => true],
])->addKey('id', true)->createTable('job', true);
// Misc Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'key' => ['type' => 'VARCHAR', 'constraint' => 40],
'value' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
])->addKey('id', true)->createTable('misc', true);
// Database Type test table
// missing types :
// TINYINT,MEDIUMINT,BIT,YEAR,BINARY , VARBINARY, TINYTEXT,LONGTEXT,YEAR,JSON,Spatial data types
// id must be interger else SQLite3 error on not null for autoinc field
$data_type_fields = [
'id' => ['type' => 'INTEGER', 'constraint' => 20, 'auto_increment' => true],
'type_varchar' => ['type' => 'VARCHAR', 'constraint' => 40, 'null' => true],
'type_char' => ['type' => 'CHAR', 'constraint' => 10, 'null' => true],
'type_text' => ['type' => 'TEXT', 'null' => true],
'type_smallint' => ['type' => 'SMALLINT', 'null' => true],
'type_integer' => ['type' => 'INTEGER', 'null' => true],
'type_float' => ['type' => 'FLOAT', 'null' => true],
'type_numeric' => ['type' => 'NUMERIC', 'constraint' => '18,2', 'null' => true],
'type_date' => ['type' => 'DATE', 'null' => true],
'type_time' => ['type' => 'TIME', 'null' => true],
'type_datetime' => ['type' => 'DATETIME', 'null' => true],
'type_timestamp' => ['type' => 'TIMESTAMP', 'null' => true],
'type_bigint' => ['type' => 'BIGINT', 'null' => true],
'type_real' => ['type' => 'REAL', 'null' => true],
'type_enum' => ['type' => 'ENUM', 'constraint' => ['appel', 'pears'], 'null' => true],
'type_set' => ['type' => 'SET', 'constraint' => ['one', 'two'], 'null' => true],
'type_mediumtext' => ['type' => 'MEDIUMTEXT', 'null' => true],
'type_double' => ['type' => 'DOUBLE', 'null' => true],
'type_decimal' => ['type' => 'DECIMAL', 'constraint' => '18,4', 'null' => true],
'type_blob' => ['type' => 'BLOB', 'null' => true],
'type_boolean' => ['type' => 'BOOLEAN', 'null' => true],
];
if ($this->db->DBDriver === 'Postgre') {
unset(
$data_type_fields['type_real'],
$data_type_fields['type_decimal']
);
}
if ($this->db->DBDriver === 'SQLSRV') {
unset($data_type_fields['type_timestamp']);
}
if ($this->db->DBDriver === 'Postgre' || $this->db->DBDriver === 'SQLSRV') {
unset(
$data_type_fields['type_enum'],
$data_type_fields['type_set'],
$data_type_fields['type_mediumtext'],
$data_type_fields['type_double'],
$data_type_fields['type_blob']
);
}
$this->forge->addField($data_type_fields)->addKey('id', true)->createTable('type_test', true);
// Empty Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 40],
'created_at' => ['type' => 'DATE', 'null' => true],
'updated_at' => ['type' => 'DATE', 'null' => true],
])->addKey('id', true)->createTable('empty', true);
// Secondary Table
$this->forge->addField([
'id' => ['type' => 'INTEGER', 'constraint' => 3, 'auto_increment' => true],
'key' => ['type' => 'VARCHAR', 'constraint' => 40],
'value' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
])->addKey('id', true)->createTable('secondary', true);
// Stringify Primary key Table
$this->forge->addField([
'id' => ['type' => 'VARCHAR', 'constraint' => 3],
'value' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
])->addKey('id', true)->createTable('stringifypkey', true);
// Table without auto increment field
$this->forge->addField([
'key' => ['type' => 'VARCHAR', 'constraint' => 40, 'unique' => true],
'value' => ['type' => 'VARCHAR', 'constraint' => 400, 'null' => true],
])->addKey('key', true)->createTable('without_auto_increment', true);
// IP Table
$this->forge->addField([
'ip' => ['type' => 'VARCHAR', 'constraint' => 100],
'ip2' => ['type' => 'VARCHAR', 'constraint' => 100],
])->createTable('ip_table', true);
// Database session table
if ($this->db->DBDriver === 'MySQLi') {
$this->forge->addField([
'id' => ['type' => 'VARCHAR', 'constraint' => 128, 'null' => false],
'ip_address' => ['type' => 'VARCHAR', 'constraint' => 45, 'null' => false],
'timestamp timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL',
'data' => ['type' => 'BLOB', 'null' => false],
]);
$this->forge->addKey('id', true);
$this->forge->createTable('ci_sessions', true);
}
if ($this->db->DBDriver === 'Postgre') {
$this->forge->addField([
'id' => ['type' => 'VARCHAR', 'constraint' => 128, 'null' => false],
'ip_address inet NOT NULL',
'timestamp timestamptz DEFAULT CURRENT_TIMESTAMP NOT NULL',
"data bytea DEFAULT '' NOT NULL",
]);
$this->forge->addKey('id', true);
$this->forge->createTable('ci_sessions', true);
}
}
public function down()
{
$this->forge->dropTable('user', true);
$this->forge->dropTable('job', true);
$this->forge->dropTable('misc', true);
$this->forge->dropTable('type_test', true);
$this->forge->dropTable('empty', true);
$this->forge->dropTable('secondary', true);
$this->forge->dropTable('stringifypkey', true);
$this->forge->dropTable('without_auto_increment', true);
$this->forge->dropTable('ip_table', true);
if (in_array($this->db->DBDriver, ['MySQLi', 'Postgre'], true)) {
$this->forge->dropTable('ci_sessions', true);
}
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace Tests\Support\Database\Migrations;
use CodeIgniter\Database\Migration;
class ExampleMigration extends Migration
{
protected $DBGroup = 'tests';
public function up()
{
$this->forge->addField('id');
$this->forge->addField([
'name' => ['type' => 'varchar', 'constraint' => 31],
'uid' => ['type' => 'varchar', 'constraint' => 31],
'class' => ['type' => 'varchar', 'constraint' => 63],
'icon' => ['type' => 'varchar', 'constraint' => 31],
'summary' => ['type' => 'varchar', 'constraint' => 255],
'created_at' => ['type' => 'datetime', 'null' => true],
'updated_at' => ['type' => 'datetime', 'null' => true],
'deleted_at' => ['type' => 'datetime', 'null' => true],
]);
$this->forge->addKey('name');
$this->forge->addKey('uid');
$this->forge->addKey(['deleted_at', 'id']);
$this->forge->addKey('created_at');
$this->forge->createTable('factories');
}
public function down()
{
$this->forge->dropTable('factories');
}
}

View File

@@ -1,28 +0,0 @@
<?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\Database\Seeds;
use CodeIgniter\Database\Seeder;
class AnotherSeeder extends Seeder
{
public function run()
{
$row = [
'name' => 'Jerome Lohan',
'email' => 'jlo@lohanenterprises.com',
'country' => 'UK',
];
$this->db->table('user')->insert($row);
}
}

View File

@@ -1,177 +0,0 @@
<?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\Database\Seeds;
use CodeIgniter\Database\Seeder;
class CITestSeeder extends Seeder
{
public function run()
{
// Job Data
$data = [
'user' => [
[
'name' => 'Derek Jones',
'email' => 'derek@world.com',
'country' => 'US',
],
[
'name' => 'Ahmadinejad',
'email' => 'ahmadinejad@world.com',
'country' => 'Iran',
],
[
'name' => 'Richard A Causey',
'email' => 'richard@world.com',
'country' => 'US',
],
[
'name' => 'Chris Martin',
'email' => 'chris@world.com',
'country' => 'UK',
],
],
'job' => [
[
'name' => 'Developer',
'description' => 'Awesome job, but sometimes makes you bored',
],
[
'name' => 'Politician',
'description' => 'This is not really a job',
],
[
'name' => 'Accountant',
'description' => 'Boring job, but you will get free snack at lunch',
],
[
'name' => 'Musician',
'description' => 'Only Coldplay can actually called Musician',
],
],
'misc' => [
[
'key' => '\\xxxfoo456',
'value' => 'Entry with \\xxx',
],
[
'key' => '\\%foo456',
'value' => 'Entry with \\%',
],
[
'key' => 'spaces and tabs',
'value' => ' One two three tab',
],
],
'stringifypkey' => [
[
'id' => 'A01',
'value' => 'test',
],
],
'without_auto_increment' => [
[
'key' => 'key',
'value' => 'value',
],
],
'type_test' => [
[
'type_varchar' => 'test',
'type_char' => 'test',
'type_enum' => 'appel',
'type_set' => 'one',
'type_text' => 'test text',
'type_mediumtext' => 'test medium text',
'type_smallint' => 1,
'type_integer' => 123,
'type_float' => 10.1,
'type_real' => 11.21,
'type_double' => 23.22,
'type_decimal' => 123123.2234,
'type_numeric' => 123.23,
'type_blob' => 'test blob',
'type_date' => '2020-01-11T22:11:00.000+02:00',
'type_time' => '2020-07-18T15:22:00.000+02:00',
'type_datetime' => '2020-06-18T05:12:24.000+02:00',
'type_timestamp' => '2019-07-18T21:53:21.000+02:00',
'type_bigint' => 2342342,
'type_boolean' => 1,
],
],
];
// set SQL times to more correct format
if ($this->db->DBDriver === 'SQLite3') {
$data['type_test'][0]['type_date'] = '2020/01/11';
$data['type_test'][0]['type_time'] = '15:22:00';
$data['type_test'][0]['type_datetime'] = '2020/06/18 05:12:24';
$data['type_test'][0]['type_timestamp'] = '2019/07/18 21:53:21';
}
if ($this->db->DBDriver === 'Postgre') {
$data['type_test'][0]['type_time'] = '15:22:00';
$data['type_test'][0]['type_boolean'] = true;
unset(
$data['type_test'][0]['type_enum'],
$data['type_test'][0]['type_set'],
$data['type_test'][0]['type_mediumtext'],
$data['type_test'][0]['type_real'],
$data['type_test'][0]['type_double'],
$data['type_test'][0]['type_decimal'],
$data['type_test'][0]['type_blob']
);
}
if ($this->db->DBDriver === 'SQLSRV') {
$data['type_test'][0]['type_date'] = '2020-01-11';
$data['type_test'][0]['type_time'] = '15:22:00.000';
$data['type_test'][0]['type_datetime'] = '2020-06-18 05:12:24.000';
unset(
$data['type_test'][0]['type_timestamp'],
$data['type_test'][0]['type_enum'],
$data['type_test'][0]['type_set'],
$data['type_test'][0]['type_mediumtext'],
$data['type_test'][0]['type_double'],
$data['type_test'][0]['type_blob']
);
}
if ($this->db->DBDriver === 'MySQLi') {
$data['ci_sessions'][] = [
'id' => '1f5o06b43phsnnf8if6bo33b635e4p2o',
'ip_address' => '127.0.0.1',
'timestamp' => '2021-06-25 21:54:14',
'data' => '__ci_last_regenerate|i:1624650854;_ci_previous_url|s:40:\"http://localhost/index.php/home/index\";',
];
}
if ($this->db->DBDriver === 'Postgre') {
$data['ci_sessions'][] = [
'id' => '1f5o06b43phsnnf8if6bo33b635e4p2o',
'ip_address' => '127.0.0.1',
'timestamp' => '2021-06-25 21:54:14.991403+02',
'data' => '\x' . bin2hex('__ci_last_regenerate|i:1624650854;_ci_previous_url|s:40:\"http://localhost/index.php/home/index\";'),
];
}
foreach ($data as $table => $dummy_data) {
$this->db->table($table)->truncate();
foreach ($dummy_data as $single_dummy_data) {
$this->db->table($table)->insert($single_dummy_data);
}
}
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Tests\Support\Database\Seeds;
use CodeIgniter\Database\Seeder;
class ExampleSeeder extends Seeder
{
public function run()
{
$factories = [
[
'name' => 'Test Factory',
'uid' => 'test001',
'class' => 'Factories\Tests\NewFactory',
'icon' => 'fas fa-puzzle-piece',
'summary' => 'Longer sample text for testing',
],
[
'name' => 'Widget Factory',
'uid' => 'widget',
'class' => 'Factories\Tests\WidgetPlant',
'icon' => 'fas fa-puzzle-piece',
'summary' => 'Create widgets in your factory',
],
[
'name' => 'Evil Factory',
'uid' => 'evil-maker',
'class' => 'Factories\Evil\MyFactory',
'icon' => 'fas fa-book-dead',
'summary' => 'Abandon all hope, ye who enter here',
],
];
$builder = $this->db->table('factories');
foreach ($factories as $factory) {
$builder->insert($factory);
}
}
}

View File

@@ -1,43 +0,0 @@
<?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\Entity\Cast;
use CodeIgniter\Entity\Cast\BaseCast;
class CastBase64 extends BaseCast
{
/**
* Get
*
* @param mixed $value Data
* @param array $params Additional param
*
* @return mixed
*/
public static function get($value, array $params = []): string
{
return base64_decode($value, true);
}
/**
* Set
*
* @param mixed $value Data
* @param array $params Additional param
*
* @return mixed
*/
public static function set($value, array $params = []): string
{
return base64_encode($value);
}
}

View File

@@ -1,30 +0,0 @@
<?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\Entity\Cast;
use CodeIgniter\Entity\Cast\BaseCast;
class CastPassParameters extends BaseCast
{
/**
* Set
*
* @param mixed $value Data
* @param array $params Additional param
*
* @return mixed
*/
public static function set($value, array $params = [])
{
return $value . ':' . json_encode($params);
}
}

View File

@@ -1,16 +0,0 @@
<?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\Entity\Cast;
class NotExtendsBaseCast
{
}

View File

@@ -1,21 +0,0 @@
<?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\Entity;
use CodeIgniter\Entity\Entity;
class User extends Entity
{
protected $attributes = [
'country' => 'India',
];
}

View File

@@ -1,10 +0,0 @@
<?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.
*/

View File

@@ -1,10 +0,0 @@
<?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.
*/

View File

@@ -1,10 +0,0 @@
<?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.
*/

View File

@@ -1,10 +0,0 @@
<?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.
*/

View File

@@ -1,29 +0,0 @@
<?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\Filters;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
class Customfilter implements \CodeIgniter\Filters\FilterInterface
{
public function before(RequestInterface $request, $arguments = null)
{
$request->url = 'http://hellowworld.com';
return $request;
}
public function after(RequestInterface $request, ResponseInterface $response, $arguments = null)
{
}
}

View File

@@ -1 +0,0 @@

View File

@@ -1 +0,0 @@
text

View File

@@ -1 +0,0 @@
more text

View File

@@ -1 +0,0 @@
separated;"text"
1 separated text

View File

@@ -1,10 +0,0 @@
<?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.
*/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 119 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

View File

@@ -1,33 +0,0 @@
<?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\Language;
use CodeIgniter\Language\Language;
class SecondMockLanguage extends Language
{
/**
* Expose the protected *load* method
*/
public function loadem(string $file, string $locale = 'en', bool $return = false)
{
return $this->load($file, $locale, $return);
}
/**
* Expose the loaded language files
*/
public function loaded(string $locale = 'en')
{
return $this->loadedFiles[$locale];
}
}

View File

@@ -1,17 +0,0 @@
<?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.
*/
return [
'one' => 'Pyramid of Giza',
'tre' => 'Colossus of Rhodes',
'fiv' => 'Temple of Artemis',
'sev' => 'Hanging Gardens of Babylon',
];

View File

@@ -1,17 +0,0 @@
<?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.
*/
return [
'two' => 'gluttony',
'tre' => 'greed',
'six' => 'envy',
'sev' => 'pride',
];

View File

@@ -1,16 +0,0 @@
<?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.
*/
return [
'strongForce' => 'These are not the droids you are looking for',
'notaMoon' => "It's made of cheese",
'wisdom' => 'There is no try',
];

View File

@@ -1,17 +0,0 @@
<?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.
*/
return [
'for' => 'four calling birds',
'fiv' => 'five golden rings',
'six' => 'six geese a laying',
'sev' => 'seven swans a swimming',
];

View File

@@ -1,15 +0,0 @@
<?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.
*/
return [
'missingExtension' => '{0} extension could not be found.',
'bazillion' => 'billions and billions', // adds a new setting
];

View File

@@ -1,19 +0,0 @@
<?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.
*/
return [
'bar' => 'Foo Bar Translated',
'bar.min_length1' => 'The {field} field is very short.',
'bar.min_length2' => 'Supplied value ({value}) for {field} must have at least {param} characters.',
'baz' => [
'min_length3.short' => 'The {field} field is very short.',
],
];

View File

@@ -1,15 +0,0 @@
<?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.
*/
// Language system language settings
return [
'languageGetLineInvalidArgumentException' => 'Get line must be a string or array of strings.',
];

View File

@@ -1,16 +0,0 @@
<?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.
*/
return [
'strongForce' => 'These are not the droids you are looking for',
'notaMoon' => "That's no moon... it's a space station",
'cannotMove' => 'I have a very bad feeling about this',
];

View File

@@ -1,20 +0,0 @@
<?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.
*/
return [
'a' => [
'b' => [
'c' => [
'd' => 'e',
],
],
],
];

View File

@@ -1,14 +0,0 @@
<?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.
*/
return [
'languageGetLineInvalidArgumentException' => 'Whatever this would be, translated',
];

View File

@@ -0,0 +1,17 @@
<?php
namespace Tests\Support\Libraries;
/**
* Class ConfigReader
*
* An extension of BaseConfig that prevents the constructor from
* loading external values. Used to read actual local values from
* a config file.
*/
class ConfigReader extends \Config\App
{
public function __construct()
{
}
}

View File

@@ -1,63 +0,0 @@
<?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\Log\Handlers;
/**
* Class TestHandler
*
* A simple LogHandler that stores the logs in memory.
* Only used for testing purposes.
*/
class TestHandler extends \CodeIgniter\Log\Handlers\FileHandler
{
/**
* Local storage for logs.
*
* @var array
*/
protected static $logs = [];
/**
* Where would the log be written?
*/
public function __construct(array $config)
{
parent::__construct($config);
$this->handles = $config['handles'] ?? [];
$this->destination = $this->path . 'log-' . date('Y-m-d') . '.' . $this->fileExtension;
self::$logs = [];
}
/**
* Handles logging the message.
* If the handler returns false, then execution of handlers
* will stop. Any handlers that have not run, yet, will not
* be run.
*
* @param $level
* @param $message
*/
public function handle($level, $message): bool
{
$date = date($this->dateFormat);
self::$logs[] = strtoupper($level) . ' - ' . $date . ' --> ' . $message;
return true;
}
public static function getLogs()
{
return self::$logs;
}
}

View File

@@ -1,24 +0,0 @@
<?php namespace Tests\Support\MigrationTestMigrations\Database\Migrations;
class Migration_another_migration extends \CodeIgniter\Database\Migration
{
public function up()
{
$this->forge->addField([
'key' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
]);
$this->forge->createTable('foo', true);
$this->db->table('foo')->insert([
'key' => 'foobar',
]);
}
public function down()
{
$this->forge->dropTable('foo', true);
}
}

View File

@@ -1,35 +0,0 @@
<?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\MigrationTestMigrations\Database\Migrations;
class Migration_some_migration extends \CodeIgniter\Database\Migration
{
public function up()
{
$this->forge->addField([
'key' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
]);
$this->forge->createTable('foo', true);
$this->db->table('foo')->insert([
'key' => 'foobar',
]);
}
public function down()
{
$this->forge->dropTable('foo', true);
}
}

View File

@@ -1,38 +0,0 @@
<?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\MigrationTestMigrations\Database\Migrations;
class Migration_another_migration extends \CodeIgniter\Database\Migration
{
public function up()
{
$fields = [
'value' => [
'type' => 'VARCHAR',
'constraint' => 255,
],
];
$this->forge->addColumn('foo', $fields);
$this->db->table('foo')->insert([
'key' => 'foobar',
'value' => 'raboof',
]);
}
public function down()
{
if ($this->db->tableExists('foo')) {
$this->forge->dropColumn('foo', 'value');
}
}
}

View File

@@ -1,28 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class EntityModel extends Model
{
protected $table = 'job';
protected $returnType = '\Tests\Support\Models\SimpleEntity';
protected $useSoftDeletes = false;
protected $dateFormat = 'int';
protected $deletedField = 'deleted_at';
protected $allowedFields = [
'name',
'description',
'created_at',
];
}

View File

@@ -1,119 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class EventModel extends Model
{
protected $table = 'user';
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $dateFormat = 'datetime';
protected $allowedFields = [
'name',
'email',
'country',
'deleted_at',
];
protected $beforeInsert = ['beforeInsertMethod'];
protected $afterInsert = ['afterInsertMethod'];
protected $beforeUpdate = ['beforeUpdateMethod'];
protected $afterUpdate = ['afterUpdateMethod'];
protected $beforeDelete = ['beforeDeleteMethod'];
protected $afterDelete = ['afterDeleteMethod'];
protected $beforeFind = ['beforeFindMethod'];
protected $afterFind = ['afterFindMethod'];
// Cache of the most recent eventData from a trigger
public $eventData;
// Testing directive to set $returnData on beforeFind event
public $beforeFindReturnData = false;
// Holds stuff for testing events
protected $tokens = [];
protected function beforeInsertMethod(array $data)
{
$this->tokens[] = 'beforeInsert';
$this->eventData = $data;
return $data;
}
protected function afterInsertMethod(array $data)
{
$this->tokens[] = 'afterInsert';
$this->eventData = $data;
return $data;
}
protected function beforeUpdateMethod(array $data)
{
$this->tokens[] = 'beforeUpdate';
$this->eventData = $data;
return $data;
}
protected function afterUpdateMethod(array $data)
{
$this->tokens[] = 'afterUpdate';
$this->eventData = $data;
return $data;
}
protected function beforeDeleteMethod(array $data)
{
$this->tokens[] = 'beforeDelete';
$this->eventData = $data;
return $data;
}
protected function afterDeleteMethod(array $data)
{
$this->tokens[] = 'afterDelete';
$this->eventData = $data;
return $data;
}
protected function beforeFindMethod(array $data)
{
$this->tokens[] = 'beforeFind';
$this->eventData = $data;
if ($this->beforeFindReturnData) {
$data['data'] = 'foobar';
$data['returnData'] = true;
}
return $data;
}
protected function afterFindMethod(array $data)
{
$this->tokens[] = 'afterFind';
$this->eventData = $data;
return $data;
}
public function hasToken(string $token)
{
return in_array($token, $this->tokens, true);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Tests\Support\Models;
use CodeIgniter\Model;
class ExampleModel extends Model
{
protected $table = 'factories';
protected $primaryKey = 'id';
protected $returnType = 'object';
protected $useSoftDeletes = false;
protected $allowedFields = [
'name',
'uid',
'class',
'icon',
'summary',
];
protected $useTimestamps = true;
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
}

View File

@@ -1,37 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
use Faker\Generator;
class FabricatorModel extends Model
{
protected $table = 'job';
protected $returnType = 'object';
protected $useSoftDeletes = true;
protected $useTimestamps = true;
protected $dateFormat = 'int';
protected $allowedFields = [
'name',
'description',
];
// Return a faked entity
public function fake(Generator &$faker)
{
return (object) [
'name' => $faker->ipv4,
'description' => $faker->words(10),
];
}
}

View File

@@ -1,28 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class JobModel extends Model
{
protected $table = 'job';
protected $returnType = 'object';
protected $useSoftDeletes = false;
protected $dateFormat = 'int';
protected $allowedFields = [
'name',
'description',
];
public $name = '';
public $description = '';
}

View File

@@ -1,27 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class SecondaryModel extends Model
{
protected $table = 'secondary';
protected $primaryKey = 'id';
protected $returnType = 'object';
protected $useSoftDeletes = false;
protected $dateFormat = 'int';
protected $allowedFields = [
'key',
'value',
];
}

View File

@@ -1,24 +0,0 @@
<?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\Models;
use CodeIgniter\Entity\Entity;
/**
* Class SimpleEntity
*
* Simple Entity-type class for testing creating and saving entities
* in the model so we can support Entity/Repository type patterns.
*/
class SimpleEntity extends Entity
{
}

View File

@@ -1,20 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class StringifyPkeyModel extends Model
{
protected $table = 'stringifypkey';
protected $returnType = 'object';
}

View File

@@ -1,31 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
protected $table = 'user';
protected $allowedFields = [
'name',
'email',
'country',
'deleted_at',
];
protected $returnType = 'object';
protected $useSoftDeletes = true;
protected $dateFormat = 'datetime';
public $name = '';
public $email = '';
public $country = '';
}

View File

@@ -1,28 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class UserObjModel extends Model
{
protected $table = 'user';
protected $allowedFields = [
'name',
'email',
'country',
'deleted_at',
];
protected $returnType = \Tests\Support\Entity\User::class;
protected $useSoftDeletes = true;
protected $dateFormat = 'datetime';
}

View File

@@ -1,36 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class ValidErrorsModel extends Model
{
protected $table = 'job';
protected $returnType = 'object';
protected $useSoftDeletes = false;
protected $dateFormat = 'int';
protected $allowedFields = [
'name',
'description',
];
protected $validationRules = [
'name' => [
'required',
'min_length[10]',
'errors' => [
'min_length' => 'Minimum Length Error',
],
],
'token' => 'in_list[{id}]',
];
}

View File

@@ -1,39 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class ValidModel extends Model
{
protected $table = 'job';
protected $returnType = 'object';
protected $useSoftDeletes = false;
protected $dateFormat = 'int';
protected $allowedFields = [
'name',
'description',
];
protected $validationRules = [
'name' => [
'required',
'min_length[3]',
],
'token' => 'permit_empty|in_list[{id}]',
];
protected $validationMessages = [
'name' => [
'required' => 'You forgot to name the baby.',
'min_length' => 'Too short, man!',
],
];
}

View File

@@ -1,25 +0,0 @@
<?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\Models;
use CodeIgniter\Model;
class WithoutAutoIncrementModel extends Model
{
protected $table = 'without_auto_increment';
protected $primaryKey = 'key';
protected $allowedFields = [
'key',
'value',
];
protected $useAutoIncrement = false;
}

View File

@@ -1,56 +0,0 @@
<?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\Publishers;
use CodeIgniter\Publisher\Publisher;
final class TestPublisher extends Publisher
{
/**
* Return value for publish()
*
* @var bool
*/
private static $result = true;
/**
* Base path to use for the source.
*
* @var string
*/
protected $source = SUPPORTPATH . 'Files';
/**
* Base path to use for the destination.
*
* @var string
*/
protected $destination = WRITEPATH;
/**
* Fakes an error on the given file.
*/
public static function setResult(bool $result)
{
self::$result = $result;
}
/**
* Fakes a publish event so no files are actually copied.
*/
public function publish(): bool
{
$this->addPath('');
return self::$result;
}
}

View File

@@ -1,21 +0,0 @@
<?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\RESTful;
use CodeIgniter\RESTful\ResourceController;
/**
* An extendable controller to provide a RESTful API for a resource.
*/
class Worker extends ResourceController
{
}

View File

@@ -1,21 +0,0 @@
<?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\RESTful;
use CodeIgniter\RESTful\ResourcePresenter;
/**
* An extendable controller to provide a RESTful API for a resource.
*/
class Worker2 extends ResourcePresenter
{
}

View File

@@ -1,66 +0,0 @@
<?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 CodeIgniter;
use CIUnitTestCase;
use Config\Services as ConfigServices;
/**
* Services class for testing.
*/
class Services
{
/**
* Mock objects for testing which are returned if exist.
*
* @var array
*/
protected static $mocks = [];
/**
* Reset shared instances and mocks for testing.
*/
public static function reset()
{
static::$mocks = [];
CIUnitTestCase::setPrivateProperty(ConfigServices::class, 'instances', []);
}
/**
* Inject mock object for testing.
*
* @param $mock
*/
public static function injectMock(string $name, $mock)
{
$name = strtolower($name);
static::$mocks[$name] = $mock;
}
/**
* Returns a service
*/
public static function __callStatic(string $name, array $arguments)
{
$name = strtolower($name);
// Returns mock if exists
if (isset(static::$mocks[$name])) {
return static::$mocks[$name];
}
if (method_exists(ConfigServices::class, $name)) {
return ConfigServices::$name(...$arguments);
}
}
}

View File

@@ -1,22 +0,0 @@
<?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;
use CodeIgniter\Entity\Entity;
class SomeEntity extends Entity
{
protected $attributes = [
'foo' => null,
'bar' => null,
];
}

View File

@@ -1,35 +0,0 @@
<?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\Validation;
class TestRules
{
public function customError(string $str, ?string &$error = null)
{
$error = 'My lovely error';
return false;
}
public function check_object_rule(object $value, ?string $fields, array $data = [])
{
$find = false;
foreach ($value as $key => $val) {
if ($key === 'first') {
$find = true;
}
}
return $find;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -1,54 +0,0 @@
<?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\View;
/**
* Class SampleClass
*
* This class is only used to provide a reference point
* during tests to make sure that things work as expected.
*/
class SampleClass
{
public function index()
{
return 'Hello World';
}
public function hello()
{
return 'Hello';
}
public function echobox($params)
{
if (is_array($params)) {
$params = implode(',', $params);
}
return $params;
}
public static function staticEcho($params)
{
if (is_array($params)) {
$params = implode(',', $params);
}
return $params;
}
public function work($p1, $p2, $p4)
{
return 'Right on';
}
}

Some files were not shown because too many files have changed in this diff Show More