PHPUnit - 15+浪费了几个小时但仍然不起作用

发布于 2024-11-15 09:01:07 字数 1198 浏览 2 评论 0原文

所以我想启动 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

潇烟暮雨 2024-11-22 09:01:08

“没有可用的版本”pear.phpunit.de/File_Iterator 包

这可能有几个原因:

  1. 您需要更新通道信息

    $ pear channel-update pear.phpunit.de

  2. 您的网络连接有问题,即防火墙不允许或您需要设置代理。

要调试它,请尝试

# pear remote-info pear.phpunit.de/File_Iterator
Package details:
================
Latest      1.2.6
Installed   1.2.6

如果有效,则可以安装它。
否则,尝试强制执行:

$ pear install -f pear.phpunit.de/File_Iterator

如果仍然不起作用,请访问 http://pear.phpunit.de 并手动下载包。
安装它

$ pear install File_iterator-1.2.6.tgz

"No releases available for package "pear.phpunit.de/File_Iterator

This can have several reasons:

  1. You need to update the channel information

    $ pear channel-update pear.phpunit.de

  2. Your network connection has problems, i.e. firewall doesn't allow it or you need to setup the proxy.

To debug it, try a

# pear remote-info pear.phpunit.de/File_Iterator
Package details:
================
Latest      1.2.6
Installed   1.2.6

If that works, you can install it.
Otherwise, try to force it:

$ pear install -f pear.phpunit.de/File_Iterator

if that still does not work, visit http://pear.phpunit.de and download the package manually.
install it with

$ pear install File_iterator-1.2.6.tgz
荒路情人 2024-11-22 09:01:08

下载并安装 XAMPP Windows 1.7.3 安装程序。

文件名:xampp-win32-1.7.3.exe

我不建议使用任何较新的版本,它可能会破坏此过程。

1.将 XAMPP 安装到 C:\

  • 版本 1.7.3 会自动创建 xampp 目录,这就是我的回答...
    • 我应该添加开始菜单/桌面的快捷方式吗?
    • 我应该正确找到 XAMPP 路径吗?
    • 便携式?
    • 输入、输入、退出等。

2。打开 C:\xampp\php\php.ini 并启用 curl

  • 取消注释第 952 行
  • extension=php_curl.dll

3.安装 PHPUnit 3.X 所需的新 PEAR 版本

  • 下载: http://pear.php.net/go-pear.phar
  • 将其保存在:C:\xampp\php
  • 使用管理员权限打开命令提示符
    • 右键单击“命令提示符”图标并选择以管理员身份运行
  • 将目录更改为C:\xampp\php
    • cd xampp
    • cd php
  • 类型 php go-pear.phar (安装新的 PEAR)
  • 选择 system -wide 安装
  • 安装 All 组件
  • 您想要更改 php.ini
    • 回答
    • 这会将 PEAR 添加到路径 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:\

  • Version 1.7.3 will create xampp directory automatically, here's what I answered...
    • Should I add shortcuts to the startmenu/desktop? No
    • Should I locate the XAMPP paths correctly? Yes
    • Portable? Yes
    • Enter enter exit etc.

2. Open C:\xampp\php\php.ini and enable curl

  • uncomment line 952
  • extension=php_curl.dll

3. Install new PEAR Version needed for PHPUnit 3.X

  • Download: http://pear.php.net/go-pear.phar
  • Save it under: C:\xampp\php
  • Open a Command Prompt with Administrator privileges
    • Right-click on Command Prompt -icon and choose Run as administrator
  • Change directory to C:\xampp\php
    • cd xampp
    • cd php
  • Type php go-pear.phar (Installs new PEAR)
  • Choose system -wide installation
  • Install All components
  • Would you like alter php.ini
    • Answer Yes
    • This will add PEAR to the path include_path = ".;\xampp\php\PEAR" line 796
  • After installing run C:\xampp\php\PEAR_ENV.reg

4. Install PHPUnit

  • Be sure you're still in C:\xampp\php
  • Type pear channel-discover components.ez.no (this is needed for PHPUnit)
  • Type pear channel-discover pear.symfony-project.com (also needed by PHPUnit)
  • Type pear channel-discover pear.phpunit.de (This IS phpunit)
  • Type pear update-channels (updates channel definitions)
  • Type pear upgrade --alldeps (upgrades all existing packages and pear)
  • Type 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.

绳情 2024-11-22 09:01:08

我之前也遇到过同样的问题,但没有找到有关此问题的教程。

过了一段时间我终于解决了。

您可以尝试按照这些步骤操作。

  1. 下载 PHPUnit 及其依赖项:https://github.com/sebastianbergmann

    • PHP 单元
    • PHP 令牌流
    • PHP 定时器
    • PHP 文本模板
    • PHP 文件迭代器
    • PHP 代码覆盖率
  2. 将 PHPUnit 及其每个依赖项提取到您选择的文件夹中。

  3. 打开文件

    FolderWhereYouExtractedEverything/PHPUnit-3.5.13OrAnotherVersion/phpunit.php
    
  4. 添加以下代码,同时用路径替换文本:

    $originalpath = 'PathToTheFolderWhereYouExtractedEverything';
    $path = $originalpath .'PathToThePHPUnitFolderContainedInTheFolderExtracted';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPCodeCoverageFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPFileIteratorFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTextTemplateFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTokenStreamFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTimerFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    
  5. 在您提取的 phpunit 文件夹中打开文件“phpunit.bat”。 (类似于 PHPUnit-3.5.13)

  6. 用以下代码替换所有底线:

    设置 PHPBIN="PathToThephp.exeFile"
    
    php -d safe_mode=关闭“PathToThephpunit.phpFile”%*
    
  7. 通过添加路径来编辑环境变量

    PathToThePHPUnitFolderContainedInThePHPUnitFolderExtracted 
    
  8. 通过添加 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.

  1. Download PHPUnit and his dependencies at : https://github.com/sebastianbergmann

    • PHP Unit
    • PHP Token Stream
    • PHP Timer
    • PHP TextTemplate
    • PHP File Itérator
    • PHP CodeCoverage
  2. Extract PHPUnit and each of his dependancies in the folder of your choice.

  3. Open the file

    FolderWhereYouExtractedEverything/PHPUnit-3.5.13OrAnotherVersion/phpunit.php
    
  4. Add the following code while replacing text by the paths :

    $originalpath = 'PathToTheFolderWhereYouExtractedEverything';
    $path = $originalpath .'PathToThePHPUnitFolderContainedInTheFolderExtracted';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPCodeCoverageFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPFileIteratorFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTextTemplateFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTokenStreamFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    $path = $originalpath .'PathToThePHPTimerFolder';
    set_include_path(get_include_path() . PATH_SEPARATOR . $path);
    
  5. Open the file "phpunit.bat" in the phpunit folder that you extracted. (Something like PHPUnit-3.5.13)

  6. Replace all the bottom lines by the following code :

    set PHPBIN="PathToThephp.exeFile"
    
    php -d safe_mode=Off "PathToThephpunit.phpFile" %*
    
  7. Edit your evironnement variables by adding the path to the

    PathToThePHPUnitFolderContainedInThePHPUnitFolderExtracted 
    
  8. 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.

原谅我要高飞 2024-11-22 09:01:08

在尝试使用 PEAR 安装任何东西之前尝试一下:

pear clear-cache

我遇到了各种各样的问题,没有找到任何包,但现在它可以工作了。每当我使用 pear 执行任何操作时,我都会先清除缓存

try this before trying to install anything using PEAR:

pear clear-cache

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

人生戏 2024-11-22 09:01:08

但是现在当我运行 'c:\xampp\php > 时phpunit',什么也没有发生!

phpunit 可执行文件位于那里吗?查找:

$ pear list pear.phpunit.de/phpunit
...
script /usr/bin/phpunit

“脚本”是正确的位置。直接执行此命令或将目录放入系统的 PATH 变量< /a> (在 Windows 上也可用)。

运行测试

PHPUnit 期望文件位于 PSR-0 兼容路径中,即 class Foo_BarTest 位于 Foo/BarTest.php 中。如果是这种情况,请使用

$ phpunit Foo_BarTest

or

$ phpunit Foo/BarTest.php

or

$ phpunit .

(执行所有测试)。

But now when I run 'c:\xampp\php > phpunit', nothing happens!

Is the phpunit executable located there? Find out with:

$ pear list pear.phpunit.de/phpunit
...
script /usr/bin/phpunit

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 in Foo/BarTest.php. If that's the case, use

$ phpunit Foo_BarTest

or

$ phpunit Foo/BarTest.php

or

$ phpunit .

(to execute all tests).

绿光 2024-11-22 09:01:08

//使用此命令

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文