Hello!

There was a need to get a module or access to the actor in the dataProvider-method. Unfortunately, since 2014, it will never be fixed that all test initializations take place before the bootstrap, as a result, neither the actor nor the modules can be obtained in the dataProvider. I need this to initialize a module (read helper) with methods for generating fake data (and an instance of a Faker generator).

Are there really no sane ways to get what you want, except how to use the treit with the necessary initializations and methods or a layer in the form of the parent class for the test?

    1 answer 1

    The problem is not in the bootstrap. The dataProvider annotation is handled by PHPUnit, which knows nothing about Codeception.

    You can generate data in the test, and then loop to send it to a separate method for verification:

    public function testMe() { $one = $this->tester->getData(); $data = [ [$one, 2] ]; foreach ($data as $item) { $this->me($item[0], $item[1]); } } public function me($a, $b) { $this->assertSame($a, $b); } 
    • Thanks for the answer! Unfortunately, this approach makes it necessary to write on top some part of unnecessary code with the possibilities of normal error output (in the style of those who are issued using dataProvider). It's a pity. It remains to choose the most convenient and non-breaking test architecture between the available options. - Alexander KorDum
    • In addition, this code will not check all the date of the set, but will come out of the test on the first broken assert. - Alexander KorDum 7:56 pm