PHPUnit - 15+浪费了几个小时但仍然不起作用
所以我想启动 PHUnit,这样我就可以运行 selenium 服务器,但我悲伤地意识到这可能永远不会发生在我身上。我已经尝试过许多不同版本的 WAMP 和 XAMPP(我认为这不是我的问题),但我总是最终碰壁,发生以下两种情况之一:
找不到包,即:“没有可用于包“pear.phpunit.de/File_Iterator”安装失败的版本”,并且我确实发现了所有正确的渠道。
我完成了安装(一种或另一种方式),最终出现了类似“致命错误:在 C:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php 中找不到'PHPUnit_Runner_BaseTestRunner' 的错误” 60" - 将 'PHPUnit_Runner_BaseTestRunner' 替换为应包含的任何其他文件。
我感到难以置信的沮丧,因为不仅与 PHPUnit 而且与 pear 都缺乏全面的一致性。看起来我必须跑完 50 个步骤,等待行星在我的椅子上对齐并旋转十几次 - 顺时针......
抱歉咆哮 - 我的问题:
是否有一个简单,直接的教程来做到这一点,你们已经成功了吗?或者也许有一个 tut + zip 可以用来绕过 pear 安装并复制文件? - 因为这似乎就是梨所做的一切。任何类型的服务器(Wamp、Xampp 等)和版本都可以 - 我将执行全新安装,并且不需要在该计算机上运行任何其他内容,因此我想要的就是让它正常工作。
编辑:
所以我手动检查了所有文件,并在所有需要的地方添加了 require_once() 。然后我从 http://pear.phpunit.de/ 下载剩余的文件并将它们放在所需的位置。没有错误!但现在当我运行 'c:\xampp\php > 时phpunit',什么也没有发生!我刚刚得到另一个命令行 - 当我尝试运行类似 'c:\xampp\php > 的东西时也会发生这种情况phpunit test1',即使我不确定需要在哪里存储 test1.php 文件...
编辑2:
我很确定 phpunit 的 .bat 文件有问题,因为当我尝试运行时任何命令(即:phpunit --help、--version 等)都不会发生,我只是得到另一个命令行。我应该删除 .bat 文件和 phpunit 文件夹并重试吗?我还认为存在防火墙问题,因为我能够在不属于我公司域的另一台计算机上运行相同的命令。
So I want to get PHUnit up so I can run selenium server, but I've come to that sad realization that this will likely never happen for me. I have tried it with numerous different versions of WAMP and XAMPP (which I don't think is my problem) but I always end up hitting a wall where either one of two things happens:
A package cannot be found ie: "No releases available for package "pear.phpunit.de/File_Iterator" install failed", and I do have all of the proper channels discovered.
I get through the install (one way of another) and I end up with a error like "Fatal error: 'PHPUnit_Runner_BaseTestRunner' not found in C:\xampp\php\PEAR\PHPUnit\TextUI\TestRunner.php on line 60" - swap 'PHPUnit_Runner_BaseTestRunner' for any other file that should be included.
I'm incredibility frustrated because of the lack of consistency across the board with not only PHPUnit but pear as well. It seems like I have to run through 50 steps, wait for the planets to align and rotate in my chair a dozen times - clockwise...
Sorry for the rant - my question:
Is there a simple, straight forward tutorial for doing this, that you guys have had success with? Or perhaps is there a tut + zip somewhere that I can use to just bypass the pear install and just copy over the files? - because it seems like that is all pear is doing anyways. Any type of server (Wamp, Xampp, etc) and version is fine - I'll perform a fresh install and I don't need to run anything else on that machine so all i want is to get this working.
Edit:
So I've manually went through all of the files and added require_once()'s everywhere that it appeared that they were needed. Then I downloaded the remaining files from http://pear.phpunit.de/ and place them in there required locations. No Errors! But now when I run 'c:\xampp\php > phpunit', nothing happens! I just get another command line - this also happens when I try to run something like, 'c:\xampp\php > phpunit test1', even though I'm not sure exactly where I need to be storing the test1.php file...
Edit 2:
I'm pretty sure something is wrong with the .bat file for phpunit because when I try to run any command (ie: phpunit --help, --version, etc.) nothing happens, I just get another command line. Should i delete the .bat file and the phpunit folder and try again? I also think that there is a firewall issue because I'm able to run the same command on a different machine that isn't apart of my company's domain.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这可能有几个原因:
您需要更新通道信息
$ pear channel-update pear.phpunit.de
您的网络连接有问题,即防火墙不允许或您需要设置代理。
要调试它,请尝试
如果有效,则可以安装它。
否则,尝试强制执行:
如果仍然不起作用,请访问 http://pear.phpunit.de 并手动下载包。
安装它
This can have several reasons:
You need to update the channel information
$ pear channel-update pear.phpunit.de
Your network connection has problems, i.e. firewall doesn't allow it or you need to setup the proxy.
To debug it, try a
If that works, you can install it.
Otherwise, try to force it:
if that still does not work, visit http://pear.phpunit.de and download the package manually.
install it with
下载并安装 XAMPP Windows 1.7.3 安装程序。
文件名:xampp-win32-1.7.3.exe
我不建议使用任何较新的版本,它可能会破坏此过程。
1.将 XAMPP 安装到
C:\
xampp
目录,这就是我的回答...否
是
是
2。打开 C:\xampp\php\php.ini 并启用
curl
3.安装 PHPUnit 3.X 所需的新 PEAR 版本
C:\xampp\php
以管理员身份运行
C:\xampp\php
cd xampp
cd php
php go-pear.phar
(安装新的 PEAR)system
-wide 安装All
组件是
include_path = ".;\xampp\php\PEAR"
第 796 行C:\ xampp\php\PEAR_ENV.reg
4.安装 PHPUnit
C:\xampp\php
中,pear channel-discover Components.ez.no
(这是 PHPUnit 所需要的)pear channel-discover pear.symfony-project.com
(PHPUnit 也需要)pear channel-discover pear.phpunit.de
(这是 phpunit)梨update-channels
(更新通道定义)pear Upgrade --alldeps
(升级所有现有软件包和 pear)pear install --alldeps phpunit/PHPUnit
(安装 PHPUnit 和所有依赖项)不客气!这花了几个小时才能解决:)
如果有任何要添加/删除的内容,请发表评论。
Download and install XAMPP Windows 1.7.3 Installer.
Filename: xampp-win32-1.7.3.exe
I would NOT recommend to use any newer version, it MAY break this procedure.
1. Install XAMPP to
C:\
xampp
directory automatically, here's what I answered...No
Yes
Yes
2. Open
C:\xampp\php\php.ini
and enablecurl
3. Install new PEAR Version
needed for PHPUnit 3.X
C:\xampp\php
Run as administrator
C:\xampp\php
cd xampp
cd php
php go-pear.phar
(Installs new PEAR)system
-wide installationAll
componentsYes
include_path = ".;\xampp\php\PEAR"
line 796C:\xampp\php\PEAR_ENV.reg
4. Install PHPUnit
C:\xampp\php
pear channel-discover components.ez.no
(this is needed for PHPUnit)pear channel-discover pear.symfony-project.com
(also needed by PHPUnit)pear channel-discover pear.phpunit.de
(This IS phpunit)pear update-channels
(updates channel definitions)pear upgrade --alldeps
(upgrades all existing packages and pear)pear install --alldeps phpunit/PHPUnit
(installs PHPUnit and all dependencies)You're welcome! This took multiple hours to solve :)
If there's anything to add/remove, please leave a comment.
我之前也遇到过同样的问题,但没有找到有关此问题的教程。
过了一段时间我终于解决了。
您可以尝试按照这些步骤操作。
下载 PHPUnit 及其依赖项:https://github.com/sebastianbergmann
将 PHPUnit 及其每个依赖项提取到您选择的文件夹中。
打开文件
添加以下代码,同时用路径替换文本:
在您提取的 phpunit 文件夹中打开文件“phpunit.bat”。 (类似于 PHPUnit-3.5.13)
用以下代码替换所有底线:
通过添加路径来编辑环境变量
通过添加 php.exe 文件的路径来编辑您的环境变量。
您可能会遇到一些已弃用的函数警告,只需将这些函数替换为未弃用的函数即可。
我希望这一切有所帮助。
I had the same problem before and I didn't find any tutorial about this issue.
I finally solved it after a while.
You can try following thoses steps.
Download PHPUnit and his dependencies at : https://github.com/sebastianbergmann
Extract PHPUnit and each of his dependancies in the folder of your choice.
Open the file
Add the following code while replacing text by the paths :
Open the file "phpunit.bat" in the phpunit folder that you extracted. (Something like PHPUnit-3.5.13)
Replace all the bottom lines by the following code :
Edit your evironnement variables by adding the path to the
Edit your evironnement variables by adding the path to the php.exe file.
You may have some deprecated function warnings, just replace the functions by a not deprecated one.
I hope all this helps.
在尝试使用 PEAR 安装任何东西之前尝试一下:
我遇到了各种各样的问题,没有找到任何包,但现在它可以工作了。每当我使用 pear 执行任何操作时,我都会先清除缓存
try this before trying to install anything using PEAR:
I had all kinds of problems, no packages were found, and now it works. whenever i do anything using pear, i clear the cache first
phpunit 可执行文件位于那里吗?查找:
“脚本”是正确的位置。直接执行此命令或将目录放入系统的 PATH 变量< /a> (在 Windows 上也可用)。
运行测试
PHPUnit 期望文件位于 PSR-0 兼容路径中,即
class Foo_BarTest
位于Foo/BarTest.php
中。如果是这种情况,请使用or
or
(执行所有测试)。
Is the phpunit executable located there? Find out with:
The "script" is the correct location. Execute this directly or put the directory in your system's PATH variable (which is available on windows, too).
Running tests
PHPUnit expects the files to be in PSR-0 compatible paths, i.e.
class Foo_BarTest
to be inFoo/BarTest.php
. If that's the case, useor
or
(to execute all tests).
//使用此命令
C:\wamp\bin\php\php5.4.3>pear install --force --alldeps phpunit/PHPUnit
//响应控制台
未知远程通道:pear.symfony.com
警告:phpunit/PHPUnit 需要包“channel://pear.symfony.com/Yaml”(版本 >= 2.0.0,版本 <= 2.99.99)
警告:phpunit/PHP_Invoker 需要 PHP 扩展“pcntl”
正在下载 PHPUnit-3.7.21.tgz ...
开始下载 PHPUnit-3.7.21.tgz(118,818 字节)
.....完成:118,818 字节
正在下载 PHP_Invoker-1.1.2.tgz ...
开始下载 PHP_Invoker-1.1.2.tgz(3,705 字节)
...完成:3,705 字节
安装好:channel://pear.phpunit.de/PHPUnit-3.7.21
安装成功:channel://pear.phpunit.de/PHP_Invoker-1.1.2
//结果成功,您可以开始使用您的测试用例,!!!祝你好运
C:\wamp\bin\php\php5.4.3>phpunit
PHPUnit 3.7.21 由 Sebastian Bergmann 编写。
//Use This command
C:\wamp\bin\php\php5.4.3>pear install --force --alldeps phpunit/PHPUnit
//Response the console
Unknown remote channel: pear.symfony.com
warning: phpunit/PHPUnit requires package "channel://pear.symfony.com/Yaml" (version >= 2.0.0, version <= 2.99.99)
warning: phpunit/PHP_Invoker requires PHP extension "pcntl"
downloading PHPUnit-3.7.21.tgz ...
Starting to download PHPUnit-3.7.21.tgz (118,818 bytes)
.....done: 118,818 bytes
downloading PHP_Invoker-1.1.2.tgz ...
Starting to download PHP_Invoker-1.1.2.tgz (3,705 bytes)
...done: 3,705 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.7.21
install ok: channel://pear.phpunit.de/PHP_Invoker-1.1.2
//Result succesfully, and you can start work with your test cases, !!! Goodluck
C:\wamp\bin\php\php5.4.3>phpunit
PHPUnit 3.7.21 by Sebastian Bergmann.