Welcome Guest, Not a member yet? Register   Sign In
How to run a single seeder during unit test?
#3

(02-25-2023, 01:13 AM)InsiteFX Wrote: Database seeds are simple classes that must have a run() method, and extend CodeIgniter\Database\Seeder. Within the run() the class can create any form of data that it needs to. It has access to the database connection and the forge through $this->db and $this->forge, respectively. Seed files must be stored within the app/Database/Seeds directory. The name of the file must match the name of the class.

I'm sorry I wasn't clear enough, but I'm trying to seed the db to run unit tests.

When I move the TestSeeder class into app/Database/Seeds I get this error:

Code:
1) App\Controllers\UsersTest::testCreateUsuarioNuevo
InvalidArgumentException: The specified seeder is not a valid file: C:\wamp64\www\back\tests\_support\Database/Seeds/TestSeeder.php

But when I move it back into tests/_support/Database/Seeds:

Code:
1) App\Controllers\UsersTest::testCreateUsuarioNuevo
Error: Class 'App\Database\Seeds\TestSeeder' not found

Thanks for your answer!
Reply


Messages In This Thread
RE: How to run a single seeder during unit test? - by Flurzo - 02-25-2023, 08:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB