在OSX上设置PHPUnit [英] Setting up PHPUnit on OSX
问题描述
尽管我敢肯定其他人最终会设法弄清楚这一点,但我一直在关注各种文档,并且经历了一段艰难的时光.
Though I'm sure others have eventually managed to figure this out, I've been following the various documentation out there and have been having a heck of a rough time of it.
http://www.phpunit.de/manual/current/zh/installation.html
听起来很简单.但是,根据您的设置,您可能要钻一个兔子洞.
Makes it sound pretty easy. However depending on your setup, you might be going down a rabbit hole.
PEAR必须具有高于1.8.1的版本.当时我有1.8.0,所以我去了解如何更新PEAR
PEAR for example must be of a version higher than 1.8.1. I had 1.8.0 at the time, so I went to find out how to update PEAR
PEAR upgrade-all
给出错误.无法访问.
sudo PEAR upgrade-all
可以,但是可以升级用户'sudo'拥有的PEAR安装(而不是您的主要帐户...或类似的东西,短版本是5,这显然不起作用)
Works, but upgrades the PEAR install owned by the user 'sudo' (and not your primary account... or something like that, short version is 5that it plain don't work)
cd ~
pico .bash_profile
添加
export PATH=/usr/local/bin:$PATH
当您键入PEAR时,为您提供正确的PEAR,您终于可以准备安装PHPUnit说明的第1步了.
give you the correct PEAR when you type PEAR, you're finally ready for step 1 of the install PHPUnit instructions.
pear channel-discover pear.phpunit.de
错误.您无权访问/usr/local/temp
Error. You don't have access to /usr/local/temp
sudo chmod 777 /usr/local/temp
错误.您无权访问/usr/local/temp/channel.xml
Error. You don't have access to /usr/local/temp/channel.xml
sudo chmod 777 /usr/local/temp/channel.xml
pear channel-discover pear.phpunit.de
错误.
Registry directory is not writeable by the current user
但是我在MAC上!
/sigh
/facepalm
/tears
我的机器上实际上有一个phpunit的工作副本". (是!)奇怪的问题是 只有当我从一个特定的文件夹中输入phpunit时,它才起作用
I've actually got a "working copy" of phpunit on my machine. (YAY!) the odd problem is that it only works when I type phpunit from one specific folder
cd /usr/local/PEAR
phpunit
^^作品
cd ~
phpunit
^^返回
Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: No such file or directory in /usr/local/bin/phpunit on line 46
Fatal error: require_once(): Failed opening required 'PHPUnit/Util/Filter.php' (include_path='.:/usr/lib/php') in /usr/local/bin/phpunit on line 46
到目前为止还很近...我想知道是否有人对这个家伙正常工作有所投入?
So close yet so far... I'm wondering if anyone has some input on getting this guy working right?
推荐答案
啊……好吧...我想我现在可能已经开始使用它了.
Ahhh.... OK ... I think I might have gotten it working now.
答案存在于PHPUnit文档中. http://www.phpunit.de/manual/3.4/en/installation.html
the answer was present in the PHPUnit documentation. http://www.phpunit.de/manual/3.4/en/installation.html
After the installation you can find the PHPUnit source files inside your local PEAR directory; the path is usually /usr/lib/php/PHPUnit.
如果我运行"SUDO"用户下列出的所有命令,则我正在运行的Mac版本的PEAR确实安装了PHPUnit. 例如:
The Mac version of PEAR that I was running, did install PHPUnit if I ran all the commands listed under the "SUDO" user eg:
sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony-project.com
sudo pear upgrade-all
这时,所有文件都下载到/usr/local/pear,但命令为
At this point, all the files are downloaded to /usr/local/pear but the command
phpunit
是否希望包含来自/usr/lib/php/PHPUnit的文件解决方案?从
is looking to include files from /usr/lib/php/PHPUnit The solution? To copy the PHPUnit folder from
cp /usr/lib/pear/PHPUnit /usr/lib/php
OR
建立符号链接
cd /usr/lib/php
ln -s /usr/lib/pear/PHPUnit PHPUnit
我见过很多有类似问题的人,但是我所见过的任何线程都没有提出这种特殊的解决方案.希望对您有用:) -亚历克斯
I've seen a lot of people with similar problems, but this particular solution hadn't come up in any of the threads I've seen. Hopefully of use to you :) -Alex
这篇关于在OSX上设置PHPUnit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!