Skip to content

Easy PHPUnit Test Skeleton with a data provider

<?php class UnitTest extends PHPUnitFrameworkTestCase { public static function providerTestFirst() { return array( array(1, 1), array(2, 2), array(2, 1), ); }

/**
 * @dataProvider providerTestFirst
 *
 * @param array $data 
 */
public function testFirst($expected, $value)
{
    $this->assertEquals($expected, $value, $value . ' should be ' . $expected);
}

}

The skeleton is really simple indeed. And it should trow an error ( 2 != 1).

manual 3.5 manual current

Translate to de es fr it pt ja