We are developing our Magento 2 extensions and running continuous integration against them. In the interest of failing fast, we're running our extension unit tests without having a full Magento 2 installation up and running. In order to achieve this we get specific (as I think we should) about our actual requirements on the Magento 2 codebase in our composer.json
, resulting in a file looking like:
...
"require": {
"magento/framework": "100.0.*",
"magento/module-backend": "100.0.*",
"magento/module-store": "100.0.*"
},
"require-dev": {
"phpunit/phpunit": "4.1.0"
},
...
When attempting to use classes available in magento/framework
we get "class not found" fatal errors due to Zend\Http
not be explicitly listed as a requirement of the package.
"magento/framework": "100.0.*"
as a requirement in your own project's composer.json
composer install
to install dependenciesWrite a unit test that uses Magento\Framework\TestFramework\Unit\Helper\ObjectManager
to mock a Magento\Framework\App\Request\Http
.
Test passes.
phpunit --verbose
PHPUnit 4.1.0 by Sebastian Bergmann.
Configuration read from phpunit.xml
........PHP Fatal error: Class 'Zend\Http\PhpEnvironment\Request' not found in /Users/nrj/Desktop/builder/vendor/magento/framework/HTTP/PhpEnvironment/Request.php on line 16
Fatal error: Class 'Zend\Http\PhpEnvironment\Request' not found in /Users/nrj/Desktop/builder/vendor/magento/framework/HTTP/PhpEnvironment/Request.php on line 16
Related internal ticket MAGETWO-31454
This was fixed in https://github.com/magento/magento2/pull/10114.
Most helpful comment
Similar: