2011-04-03 33 views
0

我試圖測試php-activerecord,它有一些測試。當運行:運行php-activerecord的phpunit失敗

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); 
    } 

任何想法?

enter image description here

+0

主分支作品對我來說,3次測試,5個斷言。你使用哪個版本?儘管我在GNU/Linux上運行它們。 'testOne'顯然應該是'test_one'。 – greut 2011-04-03 10:37:56

+0

@greut號爲什麼它必須是'test_one'?只要它在前面進行測試,PHPUnit會將其視爲測試。 – Gordon 2011-04-03 10:44:00

+0

如果有什麼它應該是公共功能setup()而不是set_up() – Gordon 2011-04-03 10:50:45

回答

5

你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版本升級到當前版本

pear upgrade-all 

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 
*/ 

但在兩個抑制包括在它的日誌依賴

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

這可能是爲什麼你沒有得到的CLI的任何結果,在所有的原因,因此要確保你也做

pear install --force --alldeps Log 

那應該可以。

編輯:的1.0版本,可從PHPActiveRecord網站不具備上述文檔塊和日誌依賴使用require_once。這是當前主版本的變化,所以你可能想嘗試夜間或檢查出從GitHub主分支:

+0

'PEAR :: Log'和'memcache'不需要運行測試,特別是不需要這個測試。 – greut 2011-04-03 11:33:22

+0

@greut看到我的編輯。 1。可從網站獲得的0版本具有'require_once'調用日誌依賴性。出於某種原因,這在OP的安裝中被壓制了,這就是爲什麼沒有任何錯誤。 – Gordon 2011-04-03 11:48:30

+1

是的,明確使用夜間主分支。 – greut 2011-04-03 17:20:16