run functional test and I got Exception

In Advance Template, trying to run a simple functional test, but I got DB Exception

Here is the test code




# AboutCept.php #

<?php

use tests\codeception\frontend\FunctionalTester;

use tests\codeception\frontend\_pages\AboutPage;


/* @var $scenario Codeception\Scenario */


$I = new FunctionalTester($scenario);

$I->wantTo('ensure that about works');

AboutPage::openBy($I);

$I->see('About', 'h1');




And here is my codecept command




codecept run functional AboutCept



And this is the output





SQLSTATE[23000]: Integrity constraint violoation: 1451 Cannot delete or update a parent row: a foreign key constraint fails 

(`codecept`.`city`, CONSTRAINT `FK_city_user` FOREIGN KEY (`created_by`) REFERENCES `user` (`id`)).

The SQL being executed was: DELETE FROM `user`



I dont understand where in the AboutCept that do the delete user ? So frustrated :angry:

any ideas ?

Hi,

I am not sure about problem, but try to run same example in book… if it works… then your configuration is fine :)

Please read below book for your clarification

https://books.google.at/books?id=TGK4CAAAQBAJ&pg=PA52&lpg=PA52&dq=FunctionalTester+yii&source=bl&ots=8KkFLqmpQC&sig=gpr01HzLD6QPpAsoX6NOHJohz4c&hl=en&sa=X&ved=0ahUKEwi1r6uj9-fMAhWM8RQKHc06BjwQ6AEIMjAD#v=onepage&q=FunctionalTester%20yii&f=false

the issue is i set foreign keys constraint in all tables.

When Codecept tries to loadFixtures() and unloadFixtures(), it fails because of foreign key constraints set in tables.

I found out about Global Db Fixtures which will disable integrity checks (http://www.yiiframework.com/doc-2.0/guide-test-fixtures.html#defining-and-using-global-fixtures) but I dont know how to use/setup it.

I post more when I figure it out