运行 php-activerecord 的 phpunit 失败

发布于 2024-10-29 19:27:05 字数 553 浏览 1 评论 0原文

我正在尝试测试 php-activerecord,它有一些测试。运行时:

phpunit sometestname

没有任何反应。我检查了代码,

include 'helpers/config.php';

require_once dirname(__FILE__) . '/../lib/Inflector.php';

class InflectorTest extends SnakeCase_PHPUnit_Framework_TestCase

{
    public function set_up()
    {
        $this->inflector = ActiveRecord\Inflector::instance();
    }

    public function testOne()
    {
        $this->assertTrue(2+2==4);
    }

有什么想法吗?

在此处输入图像描述

I am trying to test php-activerecord, it has some tests. When run:

phpunit sometestname

nothing happened. I checked the code,

include 'helpers/config.php';

require_once dirname(__FILE__) . '/../lib/Inflector.php';

class InflectorTest extends SnakeCase_PHPUnit_Framework_TestCase

{
    public function set_up()
    {
        $this->inflector = ActiveRecord\Inflector::instance();
    }

    public function testOne()
    {
        $this->assertTrue(2+2==4);
    }

Any idea?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

拧巴小姐 2024-11-05 19:27:05

您的 PHPUnit 版本有点过时。让我们确保您是最新的。请这样做

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com

,然后

pear install --force --alldeps phpunit/PHPUnit again

这应该会导致

downloading PHPUnit-3.5.13.tgz ...
Starting to download PHPUnit-3.5.13.tgz (118,553 bytes)
..........................done: 118,553 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.5.13

如果有任何错误,请尝试使用

pear upgrade-all

PHPActiveRecord 测试助手的 DocBlock 说

/**
* In order to run these unit tests, you need to install:
* - PHPUnit
* - PEAR Log (otherwise logging SQL queries will be disabled)
* - Memcache (otherwise Caching tests will not be executed)
*
* To run all tests : phpunit AllTests.php --slow-tests
* To run a specific test : phpunit ????Test.php
*/

但其中有两个针对 Log 依赖项的抑制包含

@include_once 'Log.php';
@include_once 'Log/file.php';

,这可能是您在 CLI 上没有得到任何结果的原因所有,所以请确保您也这样做

pear install --force --alldeps Log

那应该可行。

编辑: PHPActiveRecord 网站提供的 1.0 版本没有上述 DocBlock,并使用 require_once 作为日志依赖项。这在当前的主版本中已更改,因此您可能需要尝试每晚或从 GitHub 查看主分支:

Your PHPUnit version is a bit outdated. Let's make sure you are current. Please do

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com

and then

pear install --force --alldeps phpunit/PHPUnit again

this should result in

downloading PHPUnit-3.5.13.tgz ...
Starting to download PHPUnit-3.5.13.tgz (118,553 bytes)
..........................done: 118,553 bytes
install ok: channel://pear.phpunit.de/PHPUnit-3.5.13

If there is any errors try upgrade your PEAR version to the current version with

pear upgrade-all

The DocBlock for the test helper of PHPActiveRecord says

/**
* In order to run these unit tests, you need to install:
* - PHPUnit
* - PEAR Log (otherwise logging SQL queries will be disabled)
* - Memcache (otherwise Caching tests will not be executed)
*
* To run all tests : phpunit AllTests.php --slow-tests
* To run a specific test : phpunit ????Test.php
*/

but there is two suppressed includes in it for the Log dependency

@include_once 'Log.php';
@include_once 'Log/file.php';

which could be the reason why you are not getting any result on CLI at all, so make sure you also do

pear install --force --alldeps Log

That should work then.

EDIT: the 1.0 Version that is available from the PHPActiveRecord Website does not have the above DocBlock and uses require_once for the Log dependency. This is changed in the current master version, so you might want to try the nightly or check out the master branch from GitHub:

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