S
S
Sergey Pozdnyakov2016-05-25 11:47:35
Zend Framework
Sergey Pozdnyakov, 2016-05-25 11:47:35

How to add data to the database before acceptance testing?

I recently started to delve into testing using Codeception. It is not clear how to properly use the database.
There is such a functionality - the admin, adds a record, users leave comments under it. To leave a comment, you need to know the id of the post.
In Unit tests, before each test, I created an entry in the database (through modules I accessed ZF2, then to the database mapper). And he knew exactly the number.
If I connect the ZF2 module during the acceptance test, then an error appears

Fatal error: Cannot redeclare _generated\AcceptanceTesterActions::switchToIframe()

Accept.suite.yml config
class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver
        - \Helper\Acceptance
        - Db
        - ZF2
    config:
        WebDriver:
            url: 'http://test.ru/'
            browser: chrome
            port: 4444

It's not possible to just bang this line, since it is added every time the test is run, it seems like auto-generation.
In the settings, you can specify a database dump, but this is somehow inflexible ... Since a record can have several parameters, such as the date and which user groups you can add comments to. And again, the difficulty in obtaining the record number.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pozdnyakov, 2016-05-27
@Afinogen

It turned out that everything is quite simple -
there is a function
that adds data to the database, after the test the function for deleting the added data is automatically called.
PS The name is not explicit, until I got into the code - I did not understand what it was doing. Why can't you call add/insert?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question