Codeception / module-yii2

Codeception module for Yii2 framework
MIT License
16 stars 36 forks source link

ModuleException is undefined in FunctionalTesterActions class, because it's not imported with 'use' statement. #42

Closed Mikk36 closed 2 years ago

Mikk36 commented 6 years ago

What are you trying to achieve?

Use $I->amLoggedIn without IDE stating that it's throwing a ModuleException while not being able to mitigate it.

What do you get instead?

IDE error stating that ModuleException is undefined.

Details

If an used module (Yii2 -> ModuleException, for example) uses some other classes as input, output or for throwing, those use statements should also be inserted into the generated ...Actions.php file.

Naktibalda commented 6 years ago

Does setting a fully qualified class name in the docblock solve your issue? Please make a pull request.

DBX12 commented 2 years ago

I can confirm that the issue occurs. When the method Codeception\Module\Yii2::amLoggedInAs() is annotated with @throws ModuleException the command codecept build assembles the FunctionalTesterActions trait with just the class name. Annotating it with a FQN of the exception assembles the trait with the FQN. No big surprises so far, given that build only copy-pastes the doc block from the module. But it does not copy-paste imports and that is why the ModuleException is undefined in the traits. Annotating exceptions with FQNs will fix that, I'm preparing a PR.

SamMousa commented 2 years ago

This was fixed some time ago.