2

I'm trying to use Codeception to make some functional acceptance tests on project using Symfony 4. Project environment is built with docker containers(just simple pgsql container and php container that run php bin/comnsole serve and expose 8000 to different local port). I've met the problem that running tests specified with symfony extension causes an error:

bin/codecept run -v
Codeception PHP Testing Framework v2.4.0
Powered by PHPUnit 7.0.2 by Sebastian Bergmann and contributors.

In Symfony.php line 300:

  [Codeception\Exception\ModuleRequireException]
  [Symfony] module requirements not met --

  Kernel class was not found in /srv/dsp-blacklister/src/Kernel.php. Specify directory where file with Kernel class for your application is located with `app_path` parameter.

But Kernel is situated there:

/srv/dsp-blacklister/src # ls -la
total 4
drwxr-xr-x    7 root     root           224 Feb 28 09:35 .
drwxr-xr-x   26 root     root           832 Feb 28 16:18 ..
drwxr-xr-x    3 root     root            96 Feb 28 08:16 Controller
drwxr-xr-x    5 root     root           160 Feb 28 10:39 Entity
-rw-r--r--    1 root     root          2010 Feb 28 09:35 Kernel.php
drwxr-xr-x    4 root     root           128 Feb 28 11:39 Migrations
drwxr-xr-x    3 root     root            96 Feb 28 09:09 Repository

3 Answers 3

3

Your kernel is in a different namespace. There isn't a fix for this yet, other than the temporary hack below (add to the bottom of your kernel class)

class_alias(Kernel::class, 'App\Kernel', true);
Sign up to request clarification or add additional context in comments.

1 Comment

The problem is on the Symfony.php file on codeception, It tries to load appKernek or app/Kernel. I fixed with the solution shown above.
2

Now you can use the kernel_class parameter to specify the kernel namespace:

modules:
    enabled:
        - \Helper\Functional
        - Symfony:
            kernel_class: AppTest\Kernel

1 Comment

LOL i've made this fix PR to Codeception 6 month ago and than they get other PR for 14 days ago. I like this open source team))
0

For Codeception v5.0.5 adding to all suits:

modules:
    enabled:
        - Symfony:
            app_path: 'src'
            environment: 'test'

worked for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.