umstellung auf shared codeigniter und postgres php8.2
This commit is contained in:
@@ -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',
|
||||
];
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
24
tests/_support/Models/ExampleModel.php
Normal file
24
tests/_support/Models/ExampleModel.php
Normal 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;
|
||||
}
|
||||
@@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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 = '';
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
@@ -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';
|
||||
}
|
||||
@@ -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 = '';
|
||||
}
|
||||
@@ -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';
|
||||
}
|
||||
@@ -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}]',
|
||||
];
|
||||
}
|
||||
@@ -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!',
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user