61d7b4a58d
To run all available tests its enough to call $ phpunit from the root workspace directory; the default phpunit configuration resides in phpunit.xml. A bootstrap script sets some default paths and can be extended later on with other useful stuff. Each test class' path should mimic the name and path of the source class, only that the test class gets an additional "Test" appended so PHPUnit can find it automatically. The data directory can be used in a flat manner; for tests that need test data a separate directory containing these files should be added, and the directory should be named after the test class itself. The first test which uses the new infrastructure is a test for the rewritten diff parser (closes issue 627).
31 lines
883 B
PHP
31 lines
883 B
PHP
<?php
|
|
|
|
include 'IDF/Diff.php';
|
|
|
|
class IDF_DiffTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
public function testParse()
|
|
{
|
|
$datadir = DATADIR.'/'.__CLASS__;
|
|
|
|
foreach (glob($datadir.'/*.diff') as $difffile)
|
|
{
|
|
$diffprefix = 0;
|
|
if (strpos($difffile, '-git-') != false || strpos($difffile, '-hg-') != false)
|
|
{
|
|
$diffprefix = 1;
|
|
}
|
|
|
|
$expectedfile = str_replace('.diff', '.expected', $difffile);
|
|
$expectedcontent = @file_get_contents($expectedfile);
|
|
|
|
$diffcontent = file_get_contents($difffile);
|
|
$diff = new IDF_Diff($diffcontent, $diffprefix);
|
|
$this->assertEquals(unserialize($expectedcontent),
|
|
$diff->parse(),
|
|
'parsed diff '.$difffile.' does not match');
|
|
}
|
|
}
|
|
}
|
|
|