mirror of
https://github.com/Yannick7777/codeigniter-setup-script.git
synced 2025-09-10 00:03:03 +02:00
initial igniter support
This commit is contained in:
parent
dc46c9e48f
commit
123d2f13a3
105 changed files with 8740 additions and 111 deletions
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Support\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
class ExampleMigration extends Migration
|
||||
{
|
||||
protected $DBGroup = 'tests';
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
$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(): void
|
||||
{
|
||||
$this->forge->dropTable('factories');
|
||||
}
|
||||
}
|
41
igniter/tests/_support/Database/Seeds/ExampleSeeder.php
Normal file
41
igniter/tests/_support/Database/Seeds/ExampleSeeder.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Support\Database\Seeds;
|
||||
|
||||
use CodeIgniter\Database\Seeder;
|
||||
|
||||
class ExampleSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
17
igniter/tests/_support/Libraries/ConfigReader.php
Normal file
17
igniter/tests/_support/Libraries/ConfigReader.php
Normal 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()
|
||||
{
|
||||
}
|
||||
}
|
24
igniter/tests/_support/Models/ExampleModel.php
Normal file
24
igniter/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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue