Skip to content
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

codeception testing in modular application is not possible in phalcon 2.0.9 #11640

Closed
blog360space opened this issue Apr 7, 2016 · 3 comments
Labels
testing Tests related issue

Comments

@blog360space
Copy link

Hi all,
I use codeception to unit test my modular application with this command

php codecept.phar generate:test unit Example

Some class belong to a module can not auto load when I ran in test environment but in browser is ok.

I could be cause of lazy load or Phalcon\Mvc\Router\Group so my classes can not access in test environment.

Because I set the route group like this

$group = new Group([ 'module' => 'frontend', 'namespace' => 'Frontend\Controllers' ]);

here is my folder structure:

app
  module1
    controllers
    services <---- I can not access classes in this folder in test environment
config
public
tests
vendors

Anyone have solved this problem, please help me.

@Jurigag
Copy link
Contributor

Jurigag commented Apr 7, 2016

You mean that classes have something like registerNamespaces? Then it's not a bug. Those namespaces are registered once the dispatcher will access this module - not earlier, i guess that's why you cant access classes in modules. You just need to register all classes seperately in unit tests.

@sergeyklay sergeyklay added the testing Tests related issue label Apr 7, 2016
@blog360space
Copy link
Author

Thank you, @Jurigag .
Now I currently try to load more in unitest with $loader->registerNamespaces()

@Jurigag
Copy link
Contributor

Jurigag commented Apr 8, 2016

@hunggau also it's normal behaviour, even in normal application, not unit testing those namespaces which you put to register in module configuration are available after dispatcher will enter this module and call this registerNamespaces method.

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

No branches or pull requests

3 participants