First Local Commit - After Clean up.
Signed-off-by: Rick Hays <rhays@haysgang.com>
This commit is contained in:
22
tests/_support/Models/EntityModel.php
Normal file
22
tests/_support/Models/EntityModel.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php 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',
|
||||
];
|
||||
}
|
||||
79
tests/_support/Models/EventModel.php
Normal file
79
tests/_support/Models/EventModel.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php 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 $afterFind = ['afterFindMethod'];
|
||||
protected $afterDelete = ['afterDeleteMethod'];
|
||||
|
||||
// Holds stuff for testing events
|
||||
protected $tokens = [];
|
||||
|
||||
protected function beforeInsertMethod(array $data)
|
||||
{
|
||||
$this->tokens[] = 'beforeInsert';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterInsertMethod(array $data)
|
||||
{
|
||||
$this->tokens[] = 'afterInsert';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function beforeUpdateMethod(array $data)
|
||||
{
|
||||
$this->tokens[] = 'beforeUpdate';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterUpdateMethod(array $data)
|
||||
{
|
||||
$this->tokens[] = 'afterUpdate';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterFindMethod(array $data)
|
||||
{
|
||||
$this->tokens[] = 'afterFind';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function afterDeleteMethod(array $data)
|
||||
{
|
||||
$this->tokens[] = 'afterDelete';
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function hasToken(string $token)
|
||||
{
|
||||
return in_array($token, $this->tokens);
|
||||
}
|
||||
|
||||
}
|
||||
23
tests/_support/Models/JobModel.php
Normal file
23
tests/_support/Models/JobModel.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php 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 = '';
|
||||
}
|
||||
21
tests/_support/Models/SecondaryModel.php
Normal file
21
tests/_support/Models/SecondaryModel.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php 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',
|
||||
];
|
||||
}
|
||||
16
tests/_support/Models/SimpleEntity.php
Normal file
16
tests/_support/Models/SimpleEntity.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php namespace Tests\Support\Models;
|
||||
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
/**
|
||||
* Class SimpleEntity
|
||||
*
|
||||
* Simple Entity-type class for testing creating and saving entities
|
||||
* in the model so we can support Entity/Repository type patterns.
|
||||
*
|
||||
* @package Tests\Support\Models
|
||||
*/
|
||||
class SimpleEntity extends Entity
|
||||
{
|
||||
|
||||
}
|
||||
27
tests/_support/Models/UserModel.php
Normal file
27
tests/_support/Models/UserModel.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php 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 = '';
|
||||
}
|
||||
30
tests/_support/Models/ValidErrorsModel.php
Normal file
30
tests/_support/Models/ValidErrorsModel.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php 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}]',
|
||||
];
|
||||
}
|
||||
34
tests/_support/Models/ValidModel.php
Normal file
34
tests/_support/Models/ValidModel.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php 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' => 'in_list[{id}]',
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
'name' => [
|
||||
'required' => 'You forgot to name the baby.',
|
||||
'min_length' => 'Too short, man!',
|
||||
],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user