Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codeigniter does not run migration for IonAuth in tests (reopened) #1587

Open
dgvirtual opened this issue Jul 23, 2024 · 2 comments
Open

Codeigniter does not run migration for IonAuth in tests (reopened) #1587

dgvirtual opened this issue Jul 23, 2024 · 2 comments

Comments

@dgvirtual
Copy link
Contributor

I have a test class that should run migrations in all namespaces:

namespace Tests\App\Libraries;

use App\Libraries\InvoicesLib;
use App\Models\InvoicesModel;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\DatabaseTestTrait;
use Tests\Support\Database\Seeds\ClientsSeeder;
use Tests\Support\Database\Seeds\IncomeTypesSeeder;
use Tests\Support\Database\Seeds\InvoicesSeeder;
use Tests\Support\Database\Seeds\ServiceTypesSeeder;
use Tests\Support\Database\Seeds\SettingsSeeder;

/**
 * @internal
 */
final class InvoicesLibTest extends CIUnitTestCase
{
    use DatabaseTestTrait;

    protected $DBGroup = 'tests';

    // For Migrations
    protected $migrate     = true;
    protected $migrateOnce = false;
    protected $refresh     = true;
    protected $namespace; // = from all namespaces

All migrations are run except for IonAuth. Therefore I see errors like:

dg@tvenkinys:~/Programavimas/saskaitos$ vendor/bin/phpunit --filter InvoicesLib
PHPUnit 9.6.20 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.6
Configuration: /home/dg/Programavimas/saskaitos/phpunit.xml
Warning:       XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set

EEEEEEEEE                                                           9 / 9 (100%)

Time: 00:06.765, Memory: 14.00 MB

There were 9 errors:

1) Tests\App\Libraries\InvoicesLibTest::testCalculateInvoiceNumber
CodeIgniter\Database\Exceptions\DatabaseException: SQLite3::exec(): no such table: main.users

/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Database/BaseConnection.php:647
/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Database/BaseBuilder.php:2307
/home/dg/Programavimas/saskaitos/tests/_support/Database/Seeds/ClientsSeeder.php:81
/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Database/Seeder.php:145
/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Test/DatabaseTestTrait.php:223
/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Test/DatabaseTestTrait.php:209
/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Test/DatabaseTestTrait.php:190
/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Test/DatabaseTestTrait.php:58
/home/dg/Programavimas/saskaitos/vendor/codeigniter4/framework/system/Test/CIUnitTestCase.php:249
/home/dg/Programavimas/saskaitos/tests/app/Libraries/InvoicesLibTest.php:46

Caused by
CodeIgniter\Database\Exceptions\DatabaseException: SQLite3::exec(): no such table: main.users

What could be the cause of it?

also, when I run in an empty project

php spark migrate --all

The ionAuth migration is omitted, while other non App namespace migrations are included (I use only one, Settings).

I have to run

php spark migrate -n IonAuth

to get it to execute.

I am doing these tests on Codeigniter 4.4.8. On earlier versions (before 4.4.1, I would presume) this did work.

@dgvirtual
Copy link
Contributor Author

dgvirtual commented Jul 23, 2024

[see comments below] Well, nevermind perhaps. I just did a test on another project, that has been upgraded to codeigniter 4.5.3. at least

php spark migrate --all

does invoke migration for IonAuth. That project has no tests configured, but I assume it would also work.

@dgvirtual dgvirtual changed the title Codeigniter does not run migration for IonAuth in tests (and in CLI php spark migrate --all) Codeigniter does not run migration for IonAuth in tests (reopened) Jul 23, 2024
@dgvirtual
Copy link
Contributor Author

I have upgraded my project to 4.5.3, and though php spark migrate --all now does include IonAuth migration, the tests class fails to run it during initiation.

So I am reopening the issue.

@dgvirtual dgvirtual reopened this Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant