PHP Fatal error: class "Zend \ Mvc \ Application" not found

So, I followed this tutorial:

http://framework.zend.com/manual/2.0/en/user-guide/routing-and-controllers.html 

I am at the point where I should run phpunit - I run the command phpunit module/Album/src/Album/Controller/AlbumControllerTest.php

and I have a problem:

 PHP Fatal error: Class 'Zend\Mvc\Application' not found in /home/...rest of the folders here.../AlbumControllerTest.php on line 71 

line 71 in AlbumControllerTest.php:

 $bootstrap = \Zend\Mvc\Application::init(include 'config/application.config.php'); 

When I look under Zend / Mvc / i, I see a file called Application, so I assume this is not a problem.

config / application.config.php looks like this:

 <?php // config/application.config.php: return array( 'modules' => array( 'Application', 'Album', // <-- Add this line ), 'module_listener_options' => array( 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.php', ), 'module_paths' => array( './module', './vendor', ), ), ); ?> 

according to the textbook - I believe. Does anyone know how to solve this ?!

+4
source share
1 answer

Obviously your ZF2 does not start up.

To install zf2 and the service manager for your unit tests, you can use https://github.com/ZF-Commons/ZfcBase/blob/master/test/Bootstrap.php

in your test you will use it as follows:

 use YourNamespace\Bootstrap; //... public function setUp() { Bootstrap::init(); //... $this->controller->setServiceLocator(Bootstrap::getServiceManager()); } //... 
0
source

Source: https://habr.com/ru/post/1443895/


All Articles