Skip to content

Fix event name assertion #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Yarre
Copy link

@Yarre Yarre commented Oct 22, 2021

$actualEvent array has the following structure (at least when use seeEventTriggered):

(
    [event] => member.settings.change
    [priority] => 0
    [pretty] => App\Welcome\WelcomeListener::onMemberSettingsChange
    [stub] => App\Welcome\WelcomeListener::onMemberSettingsChange(MemberSettingsChangeEvent $changeEvent)
)

So pretty key contains the listener and the event is the actual name that should be compared.

Used versions:

symfony/stopwatch                              v5.3.4 
symfony/web-profiler-bundle                    v5.3.8
symfony/framework-bundle                       v5.3.8
codeception/module-symfony                     2.0.5

p.s. Orphan Events don't go to this array but I don't have solution for that.

Fix: `pretty` key contains the listener name and the `event` is the actual name that should be compared with the expected name.
@Yarre
Copy link
Author

Yarre commented Oct 22, 2021

I just checked symfony-module-tests/blob/main/tests/Functional/EventsCest.php
So probably it is desired behaviour - but as for me it is a very strange way to assert if the Event was fired by the listener name. It is counterintuitive and the opposite is described in the documentation

@TavoNiievez
Copy link
Member

@Yarre I agree with you. When I added these functions I was more concerned with making the name of the functions match what you can find in the other Framework modules of Codeception. I probably went too far in this particular case. If you propose to rename these functions with a more intuitive name, I will gladly accept the change and deprecate the use of the old names.

@TavoNiievez
Copy link
Member

For example, a better name for seeEventTriggered is seeCalledListener.

@Yarre
Copy link
Author

Yarre commented Oct 22, 2021

@TavoNiievez thank you for clarification. In this case the documentation is not correct.

@TavoNiievez
Copy link
Member

Hi @Yarre, I'm closing this PR in favor of #168 .
Your opinions are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants