tripal/TripalTestSuite

Update Docs: How to use DatabaseSeeder in Test

Closed this issue ยท 4 comments

I'm currently writing a tripal test that calls a database seeder within it. There is documentation on how to do that here: https://tripaltestsuite.readthedocs.io/en/latest/db-seeders.html#running-seeders

You can also run the seeder manually by using the static seed() method. For example, within a test class, you can run $seeder = UsersTableSeeder::seed() which runs the up() method and returns an initialized seeder object. If you are using the DBTransaction trait, the data will be automatically rolled at the end of each test function.

However, following those instructions as is produces a class not found error:

PHP Fatal error:  Class 'Tests\tripal_chado\fields\UsersTableSeeder' not found in /var/www/sites/all/modules/contrib/tripal/tests/tripal_chado/fields/ChadoFieldGetValuesListTest.php on line 24
#0  StatonLab\TripalTestSuite\TripalTestBootstrap::shutdownHandler()

Instead the instructions should tell us to use the correct namespace as follows: $seeder = \Tests\DatabaseSeeders\UsersTableSeeder::seed()

Hi @laceysanderson

The documentation assumed you imported the class using use at the beginning of the file:

use Tests\DatabaseSeeders\UsersTableSeeder;

I'll add a line to indicate that this is required. Thanks for bring it up to our attention!

Ooooh! I see :-)

I added an "attention" block to inform the user of the import requirement. Don't forget to clear the browser cache to see the new docs (sometimes it doesn't update for me).

Thanks!

Perfect ๐Ÿ‘