I am writing functional tests (at last!) and they are functioning satisfactorily, except for a reason. The test fills a certain form and send it and then makes some confirmations to see if everything worked well. However, as each test runs, a new registry linked to form (News) is generated in the DB. Ie, 10 tests performed, 10 new records.
I need BD to be cleaned up on each functional testing, either by deleting and recreating or truncate the tables.
I’ve read almost all the codeception manual, already searched in all that can be called internet, already swept the world and nothing, I have not found solution. I’ve tried using the solution offered in Codeception (see below) but I have already included the configuration into multiple files * .yml to figure out which correct (always remaking the codecept build) and I could not.
My dumpfile has several instructions in, including TRUNCATE tables and insertion of records. It was necessary to use the PDO because the Command::execute() only executes one sql command for calling, ignoring the others.
I will still try to solve this by using the "codeception way" to do so. Still accepting suggestions. But for now it is a considerable progress!
Thank you for your answer but where do you use your methods, I mean, which class? I think it would be useful for unit tests, but maybe not in functional tests. Can you give some more details? Thanks.
Bye the way, i am being able to use my solution/workaround temporarily.
I think there are no much information about tests on yii2. If we read codeception instructions they dont work with yii2 (in this case, at least). But in the guide, we dont have enough info. The same in tests/README.md. So, we have to "crack" the things, unfortunately. I feel tempted to make a "direct" codeception installation, without yii2 plugin, just to see what happens, but I know it could be very hard.