我可以将PHPUnit打包为phar吗? [英] Can I package PHPUnit as a phar?

查看:98
本文介绍了我可以将PHPUnit打包为phar吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将PHPUnit和其他各种测试依赖项打包到一个phar中,并将其放入svn中.这样,我可以在任何客户端计算机上运行phpunit而不需要pear.能做到吗?

解决方案

当前状态:

phpunit repo ,但生成的phar不稳定且功能不完整.

如果可以的话,将会有官方版本


原始答案:

如果可以的话,我给你500代表,100块钱和我的第一胎.

说真的:

现在至少在3个会议上,我已经将PHPUnit的创建者与这个话题联系在一起...看来这是不可能的.

有两个问题.首先,PHPUnit产生了新的php进程以进行测试隔离.问题是,phar无法分辨哪个php可执行文件调用了它.因此,如果您使用自定义的编译版本启动phpunit,它将使用安装的默认" php来生成隔离的测试.

据我所知,并被告知不可能将静态文件(如图像和CSS)放在phar中.这使得生成代码覆盖面变得更加困难.那将需要在那部分上做一些工作.

还有其他一些我想不起来的问题,那就是xDebug能够为phars(和phpunit依靠不为其自身的代码产生过多的代码)提供代码覆盖,以及其他一些事情.

There once was a phar ,但是据我了解,这是行不通的使用phpunit的当前状态,并且从未真正完全正常工作.


我并不是说不能仅仅因为已经有人放弃创建phpunit.phar(包括开发它的人)而已做不到. (那只是我的印象,我当然不能在这里为塞巴斯蒂安说话,并且可能完全错了,将此作为一个免责声明)

将PHPUnit放入SVN

您不必构建.phar即可!

对于我的公司,我维护一个svnd版本的PHPUnit.这不是推荐的使用方式,但是可以正常使用!

按照phpunit github网站上的 "using from a git checkout"说明.然后,您需要将这些文件放入您的php include路径,然后才能生效.

我的建议是创建一个自定义phpunit.sh,以修改include路径,然后调用原始的phpunit.sh并传递所有参数.这有点工作,但效果很好,比创建phar存档要容易得多:)

I would like to package PHPUnit and various other test dependencies into a phar and put that into svn. This way I can run phpunit on any client machine without needing pear. Can this be done?

解决方案

Current status:

Work on a phpunit.phar has started in the phpunit repo but the generated phar is not stable and not feature complete.

If it gets there there will be official releases


Original answer:

If you can I'll give you 500 rep, a 100 Bucks and my first born.. well no.. just the first two.

To be serious:

I've nagged the creator of PHPUnit about this topic on at least 3 conferences now and well.. it doesn't seem like it's possible.

There are a couple of issues with that. First off PHPUnit spawns new php processes for test isolation. The problem with this is that a phar can't tell which php executable called it. So if you start phpunit with a custom compiled version it would use the "default" php installed to spawn the isolated tests.

Secondly as far as i know and have been told it's not possible to put static files like images and css in a phar. Which makes generating code coverage a lot harder. That would require some work on that part.

There are other issues i can't recall exactly recall right having to do with xDebug being able to provide code coverage for phars (and phpunit relying on not generating overage for it's own code and so) and others things.

There once was a phar but from my understanding that just doesn't work out with the current state of phpunit and never really worked completly.


I'm not saying it can't be done just that various people already have given up on creating a phpunit.phar including the guy how develops it. (That is just my impression, i of course can't speak for Sebastian here and might be completely wrong, take this as a little disclaimer)

Putting PHPUnit into SVN

You don't have to build a .phar to do so!

For my company I maintain a svnd version of PHPUnit. It's not the recommended way of using it but it works without much issues!

Follow the "using from a git checkout" instructions on the phpunit github site. You then need to put those files into your php include path and it works.

My suggestion would be to create a custom phpunit.sh that modifies the include path and then calls the original phpunit.sh passing along all arguments. It's a little bit of work but it works quite well and it is a hell of a lot easier than creating a phar archive :)

这篇关于我可以将PHPUnit打包为phar吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆