Install multiple version of PHPUnit via composer

懵懂的女人 提交于 2019-12-12 01:59:49

问题


I am working with ZendFramework 1.x & 2.x, unfortunately ZendFramework 1.x supports only PHPUnit 3.x & Zend Framework 2.x requires PHPUnit 4.x

For this i want to install 2 versions of PHPUnit, here is the composer.json file i tried.

{
    "repositories": [{
        "type": "pear",
        "url": "http://pear.symfony-project.com"
    },{
        "type": "pear",
        "url": "http://pear.phpunit.de"
    }],
    "require-dev": {
        "pear-pear.phpunit.de/PHPUnit": "3.4.*",
        "phpunit/phpunit": "*"
    }
}

I am getting following message.

Skipped installation of bin phpunit for package phpunit/phpunit: name conflicts with an existing file

Is there anyway that i can tell composer to use different names when installing in vendor/bin directory? for instance "pear-pear.phpunit.de/PHPUnit": "3.4.*" uses vendor/bin/pu34 & "phpunit/phpunit": "*" uses vendor/bin/pu

is it possible to do this in composer?


回答1:


Composer does not support installing multiple versions of the same package.

The only thing you could do is install one (or both of them) as phar. But then they will not be defined in the composer.json.




回答2:


I would challenge the assumption that Zend Framework 1 does only support PHPUnit 3.x.

The changes I saw between 3.7 and 4.0 were not really bc-breaking in the area you usually work in, i.e. PHPUnit_Framework_TestCase. What has changed is the whole stuff of listeners etc. that has to react to the new notion of "risky test" now, but I am not aware of any to be used by Zend Framework.

I'd say two things:

  1. It isn't Zend Framework that supports PHPUnit in a version, it should be YOU. You are responsible to write tests, and in case of an application being migrated from ZF1 to ZF2, you should also migrate the test integration. If that means to change the Zend_Test_PHPUnit_ControllerTestCase to make it work with PHPUnit 4, then go for it! :)
  2. Please try to NOT use the PEAR distribution channels of PHPUnit or Symfony anymore. These will be turned off in a while,


来源:https://stackoverflow.com/questions/27090705/install-multiple-version-of-phpunit-via-composer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!