Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
b5f81c51
Commit
b5f81c51
authored
Jul 23, 2007
by
meus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed very basic code coveage report that prints percentage and total percentage
parent
9fcf6cc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
25 deletions
+38
-25
run.php
tests/run.php
+38
-25
No files found.
tests/run.php
View file @
b5f81c51
...
...
@@ -414,52 +414,65 @@ if(PHP_SAPI === "cli"){
}
else
{
$reporter
=
new
MyReporter
();
}
//uncomment this to run codecoverage
//xdebug_start_code_coverage();
$test
->
run
(
$reporter
);
/*
remote
to
enable
coverage
$path
=
Doctrine
::
getPath
()
.
DIRECTORY_SEPARATOR
;
?>
<?php
/**
<table>
<tr>
<td>
class
</td>
<td>
coverage
</td>
</tr>
<?php
$coverage
=
xdebug_get_code_coverage
();
ksort($coverage)
;
foreach ($coverage as $file => $lines) {
$totallines
=
0
;
$totalcovered
=
0
;
foreach
(
$coverage
as
$file
=>
$lines
)
{
$pos
=
strpos
(
$file
,
$path
);
if
(
$pos
===
false
&&
$pos
!==
0
){
continue
;
}
$values = array_values($lines);
$i = count($values);
$covered
=
0
;
while ($i--) {
if ($values[$i] > 0) {
$covered++;
}
$coveredLines
=
array_values
(
$lines
);
array_walk
(
$coveredLines
,
"countCovered"
);
$class
=
str_replace
(
DIRECTORY_SEPARATOR
,
'_'
,
substr
(
$file
,
strlen
(
$path
),
-
4
));
if
(
strpos
(
$class
,
'_Interface'
))
{
continue
;
}
if ($pos !== false) {
$class = str_replace(DIRECTORY_SEPARATOR, '_', substr($file, strlen($path), -4));
if
(
!
class_exists
(
$class
)){
continue
;
}
$refl
=
new
ReflectionClass
(
$class
);
$total
=
0
;
foreach
(
$refl
->
getMethods
()
as
$method
)
{
$total
+=
(
$method
->
getEndLine
()
-
$method
->
getStartLine
());
}
$totallines
+=
$total
;
$totalcovered
+=
$covered
;
if (strpos($class, '_Interface')) {
continue;
}
if
(
$total
===
0
)
{
$total
=
1
;
}
print
"<tr><td>"
.
$class
.
"</td><td>"
.
round
((
$covered
/
$total
)
*
100
,
2
)
.
" % </td></tr>"
;
}
if
(
$totallines
===
0
)
{
$totallines
=
1
;
}
print
"<tr><td>TOTAL</td><td>"
.
round
((
$totalcovered
/
$totallines
)
*
100
,
2
)
.
" % </td></tr>"
;
$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>";
function
countCovered
(
$value
,
$key
){
global
$covered
;
if
(
$value
>=
1
){
$covered
++
;
}
}
*/
?>
</table>
</body>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment