CodeIgniter 4 website:
- Catalog 999 SGK (lớp 1-12) từ API, lọc theo lớp/môn/NXB, tìm kiếm
- Trang chủ grouped browse (bậc học -> lớp -> môn, ưu tiên môn quan trọng)
- Chi tiết sách: metadata đầy đủ, cover nghệ thuật /thumb/{W}x{H}/
- Đọc online qua gate captcha + countdown, PDF viewer pdf.js
- Download: captcha + token một lần + auto cache-bust version
- Tự đồng bộ catalog/cover khi API thay đổi (refresh:catalog)
- Legal: DMCA, miễn trừ trách nhiệm, điều khoản, bảo mật, liên hệ
47 lines
1.2 KiB
PHP
47 lines
1.2 KiB
PHP
<?php
|
|
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
|
use CodeIgniter\Test\DatabaseTestTrait;
|
|
use Tests\Support\Database\Seeds\ExampleSeeder;
|
|
use Tests\Support\Models\ExampleModel;
|
|
|
|
/**
|
|
* @internal
|
|
*/
|
|
final class ExampleDatabaseTest extends CIUnitTestCase
|
|
{
|
|
use DatabaseTestTrait;
|
|
|
|
protected $seed = ExampleSeeder::class;
|
|
|
|
public function testModelFindAll(): void
|
|
{
|
|
$model = new ExampleModel();
|
|
|
|
// Get every row created by ExampleSeeder
|
|
$objects = $model->findAll();
|
|
|
|
// Make sure the count is as expected
|
|
$this->assertCount(3, $objects);
|
|
}
|
|
|
|
public function testSoftDeleteLeavesRow(): void
|
|
{
|
|
$model = new ExampleModel();
|
|
$this->setPrivateProperty($model, 'useSoftDeletes', true);
|
|
$this->setPrivateProperty($model, 'tempUseSoftDeletes', true);
|
|
|
|
/** @var stdClass $object */
|
|
$object = $model->first();
|
|
$model->delete($object->id);
|
|
|
|
// The model should no longer find it
|
|
$this->assertNull($model->find($object->id));
|
|
|
|
// ... but it should still be in the database
|
|
$result = $model->builder()->where('id', $object->id)->get()->getResult();
|
|
|
|
$this->assertCount(1, $result);
|
|
}
|
|
}
|