Skip to content

Commit 879ad65

Browse files
Add skeletons for PHP_CodeCoverage_Report_HTML_Directory and PHP_CodeCoverage_Report_HTML_File.
1 parent b779a6c commit 879ad65

File tree

5 files changed

+245
-1
lines changed

5 files changed

+245
-1
lines changed

PHP/CodeCoverage/Autoload.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ function php_codecoverage_autoload($class) {
6262
'php_codecoverage_report_factory' => '/CodeCoverage/Report/Factory.php',
6363
'php_codecoverage_report_html' => '/CodeCoverage/Report/HTML.php',
6464
'php_codecoverage_report_html_dashboard' => '/CodeCoverage/Report/HTML/Dashboard.php',
65+
'php_codecoverage_report_html_directory' => '/CodeCoverage/Report/HTML/Directory.php',
66+
'php_codecoverage_report_html_file' => '/CodeCoverage/Report/HTML/File.php',
6567
'php_codecoverage_report_node' => '/CodeCoverage/Report/Node.php',
6668
'php_codecoverage_report_node_directory' => '/CodeCoverage/Report/Node/Directory.php',
6769
'php_codecoverage_report_node_file' => '/CodeCoverage/Report/Node/File.php',

PHP/CodeCoverage/Report/HTML.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,31 @@ public function process(PHP_CodeCoverage $coverage, $target)
130130
$this->options['generator']
131131
);
132132

133+
$directory = new PHP_CodeCoverage_Report_HTML_Directory(
134+
$this->templatePath,
135+
$this->options['charset'],
136+
$this->options['generator']
137+
);
138+
139+
$file = new PHP_CodeCoverage_Report_HTML_File(
140+
$this->templatePath,
141+
$this->options['charset'],
142+
$this->options['generator'],
143+
$this->options['yui']
144+
);
145+
133146
$dashboard->render(
134147
$report, $target . 'index.dashboard.html', $this->options['title']
135148
);
136149

137150
foreach ($report as $node) {
151+
$id = PHP_CodeCoverage_Util::nodeToId($node);
152+
138153
if ($node instanceof PHP_CodeCoverage_Report_Node_Directory) {
139-
$dashboard->render($node, $target . PHP_CodeCoverage_Util::nodeToId($node) . '.dashboard.html');
154+
$dashboard->render($node, $target . $id . '.dashboard.html');
155+
$directory->render($node, $target . $id . '.html');
156+
} else {
157+
$file->render($node, $target . $id . '.html');
140158
}
141159
}
142160

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* PHP_CodeCoverage
4+
*
5+
* Copyright (c) 2009-2011, Sebastian Bergmann <[email protected]>.
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions
10+
* are met:
11+
*
12+
* * Redistributions of source code must retain the above copyright
13+
* notice, this list of conditions and the following disclaimer.
14+
*
15+
* * Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in
17+
* the documentation and/or other materials provided with the
18+
* distribution.
19+
*
20+
* * Neither the name of Sebastian Bergmann nor the names of his
21+
* contributors may be used to endorse or promote products derived
22+
* from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
* POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
* @category PHP
38+
* @package CodeCoverage
39+
* @author Sebastian Bergmann <[email protected]>
40+
* @copyright 2009-2011 Sebastian Bergmann <[email protected]>
41+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
42+
* @link http://github.com/sebastianbergmann/php-code-coverage
43+
* @since File available since Release 1.1.0
44+
*/
45+
46+
/**
47+
* Renders a PHP_CodeCoverage_Report_Node_Directory node.
48+
*
49+
* @category PHP
50+
* @package CodeCoverage
51+
* @author Sebastian Bergmann <[email protected]>
52+
* @copyright 2009-2011 Sebastian Bergmann <[email protected]>
53+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
54+
* @version Release: @package_version@
55+
* @link http://github.com/sebastianbergmann/php-code-coverage
56+
* @since Class available since Release 1.1.0
57+
*/
58+
class PHP_CodeCoverage_Report_HTML_Directory
59+
{
60+
/**
61+
* @var string
62+
*/
63+
protected $templatePath;
64+
65+
/**
66+
* @var string
67+
*/
68+
protected $charset;
69+
70+
/**
71+
* @var string
72+
*/
73+
protected $generator;
74+
75+
/**
76+
* Constructor.
77+
*
78+
* @param array $options
79+
*/
80+
public function __construct($templatePath, $charset, $generator)
81+
{
82+
$this->templatePath = $templatePath;
83+
$this->charset = $charset;
84+
$this->generator = $generator;
85+
}
86+
87+
/**
88+
* @param PHP_CodeCoverage_Report_Node_Directory $node
89+
* @param string $file
90+
* @param string $title
91+
*/
92+
public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file, $title = NULL)
93+
{
94+
if ($title === NULL) {
95+
$title = $node->getName();
96+
}
97+
98+
$template = new Text_Template(
99+
$this->templatePath . 'directory.html'
100+
);
101+
102+
$template->renderTo($file);
103+
}
104+
}

PHP/CodeCoverage/Report/HTML/File.php

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
/**
3+
* PHP_CodeCoverage
4+
*
5+
* Copyright (c) 2009-2011, Sebastian Bergmann <[email protected]>.
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions
10+
* are met:
11+
*
12+
* * Redistributions of source code must retain the above copyright
13+
* notice, this list of conditions and the following disclaimer.
14+
*
15+
* * Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in
17+
* the documentation and/or other materials provided with the
18+
* distribution.
19+
*
20+
* * Neither the name of Sebastian Bergmann nor the names of his
21+
* contributors may be used to endorse or promote products derived
22+
* from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
* POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
* @category PHP
38+
* @package CodeCoverage
39+
* @author Sebastian Bergmann <[email protected]>
40+
* @copyright 2009-2011 Sebastian Bergmann <[email protected]>
41+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
42+
* @link http://github.com/sebastianbergmann/php-code-coverage
43+
* @since File available since Release 1.1.0
44+
*/
45+
46+
/**
47+
* Renders a PHP_CodeCoverage_Report_Node_File node.
48+
*
49+
* @category PHP
50+
* @package CodeCoverage
51+
* @author Sebastian Bergmann <[email protected]>
52+
* @copyright 2009-2011 Sebastian Bergmann <[email protected]>
53+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
54+
* @version Release: @package_version@
55+
* @link http://github.com/sebastianbergmann/php-code-coverage
56+
* @since Class available since Release 1.1.0
57+
*/
58+
class PHP_CodeCoverage_Report_HTML_File
59+
{
60+
/**
61+
* @var string
62+
*/
63+
protected $templatePath;
64+
65+
/**
66+
* @var string
67+
*/
68+
protected $charset;
69+
70+
/**
71+
* @var string
72+
*/
73+
protected $generator;
74+
75+
/**
76+
* @var boolean
77+
*/
78+
protected $yui;
79+
80+
/**
81+
* Constructor.
82+
*
83+
* @param array $options
84+
*/
85+
public function __construct($templatePath, $charset, $generator, $yui)
86+
{
87+
$this->templatePath = $templatePath;
88+
$this->charset = $charset;
89+
$this->generator = $generator;
90+
$this->yui = $yui;
91+
}
92+
93+
/**
94+
* @param PHP_CodeCoverage_Report_Node_File $node
95+
* @param string $file
96+
* @param string $title
97+
*/
98+
public function render(PHP_CodeCoverage_Report_Node_File $node, $file, $title = NULL)
99+
{
100+
if ($title === NULL) {
101+
$title = $node->getName();
102+
}
103+
104+
if ($this->yui) {
105+
$template = new Text_Template($this->templatePath . 'file.html');
106+
} else {
107+
$template = new Text_Template(
108+
$this->templatePath . 'file_no_yui.html'
109+
);
110+
}
111+
112+
$template->renderTo($file);
113+
}
114+
}

package.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
<file baseinstalldir="/" name="Dashboard.php" role="php">
7070
<tasks:replace from="@package_version@" to="version" type="package-info" />
7171
</file>
72+
<file baseinstalldir="/" name="Directory.php" role="php">
73+
<tasks:replace from="@package_version@" to="version" type="package-info" />
74+
</file>
75+
<file baseinstalldir="/" name="File.php" role="php">
76+
<tasks:replace from="@package_version@" to="version" type="package-info" />
77+
</file>
7278
</dir>
7379
<file baseinstalldir="/" name="Clover.php" role="php">
7480
<tasks:replace from="@package_version@" to="version" type="package-info" />

0 commit comments

Comments
 (0)