Mantis - Quercus
Viewing Issue Advanced Details
3312 block always 01-30-09 18:45 02-04-09 21:41
koreth  
nam  
normal  
closed 4.0.0  
fixed  
none    
none 4.0.0  
0003312: PHPUnit data providers don't work (can't find annotation)
http://sebastian-bergmann.de/archives/702-Data-Providers-in-PHPUnit-3.2.html [^] describes PHPUnit's data provider interface.

<?php
include_once 'PHPUnit/Framework.php';
include_once 'PHPUnit/TextUI/ResultPrinter.php';
class MyTest extends PHPUnit_Framework_TestCase {
  public static function provider() {
    return array(array(1,2,4), array(4,5,6));
  }
  /**
   * @dataProvider provider
   */
  public function testAddition($a,$b,$c) {
    $this->assertEquals($c, $a+$b+1);
  }
}
$suite = new PHPUnit_Framework_TestSuite('MyTest');
$result = new PHPUnit_Framework_TestResult;
$printer = new PHPUnit_TextUI_ResultPrinter;
$result->addListener($printer);
$result = $suite->run($result);
$result->flushListeners();
$printer->printResult($result);

Under regular PHP, this runs the test method twice; the first time passes and the second fails. Under Quercus, I get three "Warning: required argument missing" messages and the test is only run once. Apparently the PHPUnit framework is not able to detect the @dataProvider annotation.

Notes
(0003805)
nam   
02-04-09 21:41   
php/5217
php/5218
php/523a
php/523b
php/524j
php/524k
php/5267

PHPUnit annotations should work, though untested.