Files
opensourcepos/tests/Helpers/migration_helperTest.php
T
BudsieBuds 35fc07e201 refactor(tests): normalize test namespaces to PSR-4 and clean up composer dependencies (#4758)
- Rename tests/helpers/ to tests/Helpers/ and add Tests\Helpers namespace
- Move CI3SecretConverterTest into tests/Libraries/ to eliminate duplicate case-conflict directory
- Map Config\ in composer.json PSR-4 autoloading
- Remove obsolete PHP 7 polyfill (random_compat) and redundant laminas-escaper
- Clean up unused dev dependencies (fakerphp, vfsstream, predis) and update tooling
- Safeguard table prefix restoration in migration_helper and reset config mock in LocaleHelperTest
2026-10-21 19:01:03 +04:00

54 lines
1.5 KiB
PHP

<?php
namespace Tests\Helpers;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use Tests\Support\FailedQueryConnectionTrait;
class migration_helperTest extends CIUnitTestCase
{
use DatabaseTestTrait;
use FailedQueryConnectionTrait;
protected $migrate = true;
protected $migrateOnce = true;
protected $refresh = false;
protected $namespace = null;
public function testIndexExists_ThrowsWhenQueryFails(): void
{
$this->requireMigrationHelper();
$this->expectException(DatabaseException::class);
indexExists('some_table', 'some_index', $this->failingConnection());
}
public function testPrimaryKeyExists_ThrowsWhenQueryFails(): void
{
$this->requireMigrationHelper();
$this->expectException(DatabaseException::class);
primaryKeyExists('some_table', $this->failingConnection());
}
public function testDropAllForeignKeyConstraints_ThrowsWhenQueryFails(): void
{
$this->requireMigrationHelper();
$this->expectException(DatabaseException::class);
dropAllForeignKeyConstraints('some_table', 'some_column', $this->failingConnection());
}
/**
* Ensure the migration helper functions are loaded (they are global).
*/
private function requireMigrationHelper(): void
{
if (! function_exists('indexExists')) {
require APPPATH . 'Helpers/migration_helper.php';
}
}
}