Codeception: [Laravel 5.3] Db modules populate not working

Created on 27 Oct 2016  路  4Comments  路  Source: Codeception/Codeception

What are you trying to achieve?

I only want the sql dump to only load at the start of the api suite so i set up
populate: true
cleanup: false

What do you get instead?

But i got told that the table already exist ?

Provide console output if related. Use -vvv mode for more details.

[RuntimeException]
  Error Output:
    [Codeception\Exception\ModuleException]
    Db: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'cities'
     already exists

a couple a days ago it is running fine, i think it have something to do with the newer codeception version.
but when i turn the setting to:
populate: true
cleanup: true
It is running fine but it is re-load the sql dump each test which i do not want.

Details

  • Codeception version: 2.2.6
  • PHP Version: 5.6.25
  • Operating System: windows wamp localhost
  • Installation type: Composer
  • List of installed packages (composer show)
  • Suite configuration:
class_name: ApiTester
modules:
    enabled:
        - \Helper\Api
        - Db
        - REST:
            url: /my-url/
            depends: PhpBrowser
            depends: Laravel5
    config:
        Laravel5:
          cleanup: true
          environment_file: .env.testing
        Db:
          dsn: 'mysql:host=localhost;dbname=testing-db'
          user: 'root'
          password: ''
          dump: 'tests/_data/dump.sql'
          populate: true
          cleanup: false

Most helpful comment

Solve it by adding option of "DROP TABLE IF EXIST" for the dump mysql file.
Don't know why option "cleanup=true" work, i think it delete the entire database and then run the sql file.

All 4 comments

You should use the cleanup method of the Laravel module or the Db module, but not of both. If you use it from the Laravel module, disable it for the Db module, and vice versa.

Did this work before and stopped working after an update? Or is this your first try?

Yes it did work before, a couple of days ago.
The laravel cleanup method doesn't work for me (don't know why, i have tried it in the acception test too, creating a user but it doesn't get deleted when the test is finished) so i using the Db modules to reset the database before test suite.

I rollback the codeception from 2.2.6 to 2.2.5 and all the way to 2.2.0 but none is working.
If i'm running it on an empty database then it work but not the already exist database.
It keep saying that tables already exist instead of delete the database and repopulate it using dump.sql file.
It working fine if i also config the cleanup: true, but not if the cleanup: false

Solve it by adding option of "DROP TABLE IF EXIST" for the dump mysql file.
Don't know why option "cleanup=true" work, i think it delete the entire database and then run the sql file.

Was this page helpful?
0 / 5 - 0 ratings