mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Commit realizando cambios en los roles de los usuarios
This commit is contained in:
@ -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');
|
||||
}
|
||||
}
|
||||
41
ci4/tests/_support/Database/Seeds/ExampleSeeder.php
Normal file
41
ci4/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()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
61
ci4/tests/_support/DatabaseTestCase.php
Normal file
61
ci4/tests/_support/DatabaseTestCase.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\DatabaseTestTrait;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class DatabaseTestCase extends CIUnitTestCase
|
||||
{
|
||||
use DatabaseTestTrait;
|
||||
|
||||
/**
|
||||
* Should the database be refreshed before each test?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $refresh = true;
|
||||
|
||||
/**
|
||||
* The seed file(s) used for all tests within this test case.
|
||||
* Should be fully-namespaced or relative to $basePath
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $seed = 'Tests\Support\Database\Seeds\ExampleSeeder';
|
||||
|
||||
/**
|
||||
* The path to the seeds directory.
|
||||
* Allows overriding the default application directories.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $basePath = SUPPORTPATH . 'Database/';
|
||||
|
||||
/**
|
||||
* The namespace(s) to help us find the migration classes.
|
||||
* Empty is equivalent to running `spark migrate -all`.
|
||||
* Note that running "all" runs migrations in date order,
|
||||
* but specifying namespaces runs them in namespace order (then date)
|
||||
*
|
||||
* @var array|string|null
|
||||
*/
|
||||
protected $namespace = 'Tests\Support';
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Extra code to run before each test
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
parent::tearDown();
|
||||
|
||||
// Extra code to run after each test
|
||||
}
|
||||
}
|
||||
17
ci4/tests/_support/Libraries/ConfigReader.php
Normal file
17
ci4/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()
|
||||
{
|
||||
}
|
||||
}
|
||||
28
ci4/tests/_support/Models/ExampleModel.php
Normal file
28
ci4/tests/_support/Models/ExampleModel.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?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;
|
||||
}
|
||||
38
ci4/tests/_support/SessionTestCase.php
Normal file
38
ci4/tests/_support/SessionTestCase.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support;
|
||||
|
||||
use CodeIgniter\Session\Handlers\ArrayHandler;
|
||||
use CodeIgniter\Session\SessionInterface;
|
||||
use CodeIgniter\Test\CIUnitTestCase;
|
||||
use CodeIgniter\Test\Mock\MockSession;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class SessionTestCase extends CIUnitTestCase
|
||||
{
|
||||
/**
|
||||
* @var SessionInterface
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mockSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pre-loads the mock session driver into $this->session.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected function mockSession()
|
||||
{
|
||||
$config = config('App');
|
||||
$this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config);
|
||||
\Config\Services::injectMock('session', $this->session);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user