1
0
mirror of synced 2025-01-17 22:11:41 +03:00
This commit is contained in:
zYne 2007-07-06 12:37:02 +00:00
parent 95b5bc1afe
commit 362b844cab
3 changed files with 75 additions and 9 deletions

View File

@ -3,6 +3,13 @@ class GroupTest
{
protected $_testCases = array();
public function __construct()
{
if (extension_loaded('xdebug')) {
//xdebug_start_code_coverage(XDEBUG_CC_DEAD_CODE | XDEBUG_CC_UNUSED);
}
}
public function addTestCase(UnitTestCase $testCase)
{
$this->_testCases[] = $testCase;

View File

@ -100,6 +100,8 @@ class Doctrine_UnitTestCase extends UnitTestCase
$this->driverName = 'Sqlite';
break;
}
$module = $e[1];
if(count($e) > 3) {
$driver = $e[2];
@ -148,12 +150,23 @@ class Doctrine_UnitTestCase extends UnitTestCase
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
}
if ($this->driverName !== 'main') {
$this->export = $this->connection->export;
$this->transaction = $this->connection->transaction;
$this->dataDict = $this->connection->dataDict;
$this->expr = $this->connection->expression;
$this->sequence = $this->connection->sequence;
$this->import = $this->connection->import;
if (isset($module)) {
switch($module) {
case 'Export':
case 'Import':
case 'Transaction':
case 'Sequence':
case 'Expression':
$lower = strtolower($module);
$this->$lower = $this->connection->$lower;
break;
case 'DataDict':
$this->dataDict = $this->connection->dataDict;
break;
}
}
}
$this->unitOfWork = $this->connection->unitOfWork;
$this->connection->setListener(new Doctrine_EventListener());

View File

@ -3,8 +3,9 @@
ini_set('max_execution_time', 900);
function autoload($class) {
if(strpos($class, 'TestCase') === false)
if(strpos($class, 'TestCase') === false) {
return false;
}
$e = explode('_', $class);
$count = count($e);
@ -63,7 +64,6 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
// DATABASE ABSTRACTION tests
/** */
// Temp tests
/**
@ -323,7 +323,7 @@ $test->addTestCase(new Doctrine_Record_SaveBlankRecord_TestCase());
$test->addTestCase(new Doctrine_Template_TestCase());
/** */
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase());
@ -375,7 +375,53 @@ class MyReporter extends HtmlReporter {
<?php
$test->run(new MyReporter());
$path = Doctrine::getPath() . DIRECTORY_SEPARATOR;
?>
<?php
/**
<table>
<tr>
<td>class</td>
<td>coverage</td>
</tr>
$coverage = xdebug_get_code_coverage();
ksort($coverage);
foreach ($coverage as $file => $lines) {
$pos = strpos($file, $path);
$values = array_values($lines);
$i = count($values);
$covered = 0;
while ($i--) {
if ($values[$i] > 0) {
$covered++;
}
}
if ($pos !== false) {
$class = str_replace(DIRECTORY_SEPARATOR, '_', substr($file, strlen($path), -4));
if (strpos($class, '_Interface')) {
continue;
}
$refl = new ReflectionClass($class);
$total = 0;
foreach ($refl->getMethods() as $method) {
$total += ($method->getEndLine() - $method->getStartLine());
}
if ($total === 0) {
$total = 1;
}
print "<tr><td>" . $class . "</td><td>" . round(($covered / $total) * 100, 2) . " % </td></tr>";
}
}
*/
?>
</table>
</body>
</html>