Commit 362b844c authored by zYne's avatar zYne

--no commit message

--no commit message
parent 95b5bc1a
...@@ -3,6 +3,13 @@ class GroupTest ...@@ -3,6 +3,13 @@ class GroupTest
{ {
protected $_testCases = array(); 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) public function addTestCase(UnitTestCase $testCase)
{ {
$this->_testCases[] = $testCase; $this->_testCases[] = $testCase;
......
...@@ -101,6 +101,8 @@ class Doctrine_UnitTestCase extends UnitTestCase ...@@ -101,6 +101,8 @@ class Doctrine_UnitTestCase extends UnitTestCase
break; break;
} }
$module = $e[1];
if(count($e) > 3) { if(count($e) > 3) {
$driver = $e[2]; $driver = $e[2];
switch($e[2]) { switch($e[2]) {
...@@ -148,12 +150,23 @@ class Doctrine_UnitTestCase extends UnitTestCase ...@@ -148,12 +150,23 @@ class Doctrine_UnitTestCase extends UnitTestCase
$this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener); $this->manager->setAttribute(Doctrine::ATTR_LISTENER, $this->listener);
} }
if ($this->driverName !== 'main') { if ($this->driverName !== 'main') {
$this->export = $this->connection->export;
$this->transaction = $this->connection->transaction; 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; $this->dataDict = $this->connection->dataDict;
$this->expr = $this->connection->expression; break;
$this->sequence = $this->connection->sequence; }
$this->import = $this->connection->import; }
} }
$this->unitOfWork = $this->connection->unitOfWork; $this->unitOfWork = $this->connection->unitOfWork;
$this->connection->setListener(new Doctrine_EventListener()); $this->connection->setListener(new Doctrine_EventListener());
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
ini_set('max_execution_time', 900); ini_set('max_execution_time', 900);
function autoload($class) { function autoload($class) {
if(strpos($class, 'TestCase') === false) if(strpos($class, 'TestCase') === false) {
return false; return false;
}
$e = explode('_', $class); $e = explode('_', $class);
$count = count($e); $count = count($e);
...@@ -63,7 +64,6 @@ $test = new GroupTest('Doctrine Framework Unit Tests'); ...@@ -63,7 +64,6 @@ $test = new GroupTest('Doctrine Framework Unit Tests');
// DATABASE ABSTRACTION tests // DATABASE ABSTRACTION tests
/** */
// Temp tests // Temp tests
/** /**
...@@ -323,7 +323,7 @@ $test->addTestCase(new Doctrine_Record_SaveBlankRecord_TestCase()); ...@@ -323,7 +323,7 @@ $test->addTestCase(new Doctrine_Record_SaveBlankRecord_TestCase());
$test->addTestCase(new Doctrine_Template_TestCase()); $test->addTestCase(new Doctrine_Template_TestCase());
/** */
//$test->addTestCase(new Doctrine_IntegrityAction_TestCase()); //$test->addTestCase(new Doctrine_IntegrityAction_TestCase());
//$test->addTestCase(new Doctrine_AuditLog_TestCase()); //$test->addTestCase(new Doctrine_AuditLog_TestCase());
...@@ -375,7 +375,53 @@ class MyReporter extends HtmlReporter { ...@@ -375,7 +375,53 @@ class MyReporter extends HtmlReporter {
<?php <?php
$test->run(new MyReporter()); $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> </body>
</html> </html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment