运行php-activerecord的phpunit失败

che*_*nge 0 php phpunit phpactiverecord

我正在尝试测试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);
    }
Run Code Online (Sandbox Code Playgroud)

任何的想法?

在此输入图像描述

Gor*_*don 5

您的PHPUnit版本有点过时了.让我们确保你是最新的.请做

pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
Run Code Online (Sandbox Code Playgroud)

然后

pear install --force --alldeps phpunit/PHPUnit again
Run Code Online (Sandbox Code Playgroud)

这应该导致

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
Run Code Online (Sandbox Code Playgroud)

如果有任何错误,请尝试将PEAR版本升级到当前版本

pear upgrade-all
Run Code Online (Sandbox Code Playgroud)

为PHPActiveRecord的测试文档块助手说:

/**
* 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
*/
Run Code Online (Sandbox Code Playgroud)

但是对于Log依赖项有两个被抑制的包含

@include_once 'Log.php';
@include_once 'Log/file.php';
Run Code Online (Sandbox Code Playgroud)

这可能是你根本没有在CLI上得到任何结果的原因,所以一定要确保你也这样做

pear install --force --alldeps Log
Run Code Online (Sandbox Code Playgroud)

这应该工作.

编辑: PHPActiveRecord网站上提供的1.0版本没有上述DocBlock并require_once用于Log依赖项.这在当前的主版本中已更改,因此您可能希望每晚尝试或从GitHub检出主分支: