GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
No description provided.
Remove ZendTest from Composer
We'll still need to pull in the Composer autoloader for things like doctrine/annotations, the proxymanager, etc. The primary point is that in addition to this, we also need to use the StandardAutoloader to autoload the test classes.
Have both composer and standard autoloader
Not needed \o/
Closing parenthetical misaligned with opening one
Perfect, @bakura10 -- thanks!
Merge pull request #4744 from bakura10/remove-zend-test
Remove ZendTest from Composer
Merge branch 'hotfix/4744' into develop
Forward port #4744
What's the reason why the ZendTest namespace is removed? We are inheriting some ZendTest classes in our testsuite and relying on Composer autoloading.
Since a few release, test folder is not included when you download ZF 2 through composer (you need to explicitly add the --prefer-source option to composer so that it retrieves the tests also). However, this was problematic when you were dumping an optimized class map autoloader because Composer assumed there was a ZendTest folder, but didn't find the files, and crashed.
@arjanvdbos -- the namespace is still present, we're simply using the StandardAutoloader in order to load that namespace. You can do similarly in your own test suite if you need to use any of our test assets -- just point the autoloader at the test directory.
@weierophinney -- I’ll understand, but the downside of this approach is that we always manually have to modify the autoloading when we add a dependency and consuming their tests. It would be nice when Composer implement a autoload-dev, which imho would be a nicer solution. See Added an autoload-dev section.
Doesn't this break autoloading without using composer? i.e. clone zf2, cd into tests dir, run phpunit ZendTest/Escaper/EscaperTest.php and you get errors:
PHP Fatal error: Class 'Zend\Loader\StandardAutoloader' not found in /path/to/zf2/tests/_autoload.php on line 8
I had to fix it by adding back what was removed.
@gerardroche We require that you run a composer.phar install in order to run unit tests. As such, the StandardAutoloader will be autoloadable, allowing us to configure it.
We went this route because it makes the following more straight-forward for contributors:
So, no, no fix is needed -- just install the composer dependencies to ensure you have what is needed to run the tests.
@weierophinney The thing is I didn't need composer or any dependencies to get what I needed done. I only needed to test one component so I reverted this change and added a file_exists for __DIR__ . '/../vendor/autoload.php' because it was spitting out a php warning about the file not existing.
__DIR__ . '/../vendor/autoload.php'
Can we not have both? i.e. you can run tests without composer or dependencies but all bets are off if you do.
@gerardroche No, we cannot have both, as that would mean we then have to maintain more code to allow tests to work. Right now, the situation is:
We do not need to worry about PHPUnit incompatibilities, autoloading issues due to include_path issues, etc. It's a single toolchain for everybody.
:) cool, thanks.