Codeception / module-symfony

Codeception module for testing apps using Symfony framework
MIT License
88 stars 24 forks source link

Symfony 6 support #152

Closed codedge closed 2 years ago

codedge commented 2 years ago

Currently it is not possible to use the module with Symfony 6 as the reqs in composer.json only a Symfony 4 and 5. Any plans to support Symfony 6?

TavoNiievez commented 2 years ago

Hi @codedge ,

So far there is no codeception/codeception release tagged with Symfony 6 support, that's our blocker right now.

Support has already been implemented in 5.0 branch but, 5.0.0 in turn is blocked by PHPUnit 10.0.0 which will probably be released next month.

codedge commented 2 years ago

According to this issue https://github.com/Codeception/Codeception/issues/6294 I hope the 5.0 release is going to happen in the next days as PHPUnit seem to be out of scope for 5.0.

TavoNiievez commented 2 years ago

The last comment in that thread is a month old, we decided to keep waiting for PHPUnit 10 after that...

semaz commented 2 years ago

Hello. To support php 8 and symfony 6, two lines in the file src/Codeception/Module/Symfony/SessionAssertionsTrait.php need to be corrected:

  1. Replace the content of the "getCurrentSession()" method with return $this->grabService('session.factory')->createSession();
  2. In the amLoggedInAs function, you need to remove the second argument from the UsernamePasswordToken class so line 43 must looks like this $token = new UsernamePasswordToken($user, $firewallName, $user->getRoles());

So far, I've made these changes to my helper class. But I hope that you will add them to the module code.

TavoNiievez commented 2 years ago

@semaz Cool. The tests in symfony-module-tests also need to be adapted, for example making the change to getCurrentSession() prints:

 Step  See in session "_security_main"
 Fail  No session attribute with name '_security_main'

it may be that this session variable has been renamed, if you have time you can try to send PRs to add this support, I will be very attentive to review it, otherwise I'll do both myself.

semaz commented 2 years ago

157 Hi @TavoNiievez. I created first PR in my life)

Please review it.

TavoNiievez commented 2 years ago

It seems to be a special occasion, I'm glad that Codeception is the project that receives your first PR. Friendly reminder: we have some contribution guides in case you want to learn more about our workflow and how module-symfony uses symfony-module-tests to perform tests.