@@ -99,43 +99,93 @@ public function render(PHP_CodeCoverage_Report_Node_Directory $node, $file, $tit
99
99
*/
100
100
protected function renderItem (PHP_CodeCoverage_Report_Node $ item , $ total = FALSE )
101
101
{
102
- $ data = array (
103
- 'numClasses ' => $ item ->getNumClasses (),
104
- 'numTestedClasses ' => $ item ->getNumTestedClasses (),
105
- 'numMethods ' => $ item ->getNumMethods (),
106
- 'numTestedMethods ' => $ item ->getNumTestedMethods (),
107
- 'linesExecutedPercent ' => $ item ->getLineExecutedPercent (FALSE ),
108
- 'linesExecutedPercentAsString ' => $ item ->getLineExecutedPercent (),
109
- 'numExecutedLines ' => $ item ->getNumExecutedLines (),
110
- 'numExecutableLines ' => $ item ->getNumExecutableLines (),
111
- 'testedMethodsPercent ' => $ item ->getTestedMethodsPercent (FALSE ),
112
- 'testedMethodsPercentAsString ' => $ item ->getTestedMethodsPercent (),
113
- 'testedClassesPercent ' => $ item ->getTestedClassesPercent (FALSE ),
114
- 'testedClassesPercentAsString ' => $ item ->getTestedClassesPercent ()
102
+ $ template = new Text_Template (
103
+ $ this ->templatePath . 'directory_item.html '
115
104
);
116
105
117
106
if ($ total ) {
118
- $ data ['itemClass ' ] = 'coverDirectory ' ;
119
- $ data ['name ' ] = 'Total ' ;
107
+ $ icon = '' ;
108
+ $ itemClass = 'coverDirectory ' ;
109
+ $ name = 'Total ' ;
120
110
} else {
121
- $ data [ ' name ' ] = sprintf (
111
+ $ name = sprintf (
122
112
'<a href="%s.html">%s</a> ' ,
123
113
$ item ->getId (),
124
114
$ item ->getName ()
125
115
);
126
116
127
117
if ($ item instanceof PHP_CodeCoverage_Report_Node_Directory) {
128
- $ data [ ' icon ' ] = '<img alt="directory" src="directory.png"/> ' ;
129
- $ data [ ' itemClass ' ] = 'coverDirectory ' ;
118
+ $ icon = '<img alt="directory" src="directory.png"/> ' ;
119
+ $ itemClass = 'coverDirectory ' ;
130
120
} else {
131
- $ data [ ' icon ' ] = '<img alt="file" src="file.png"/> ' ;
132
- $ data [ ' itemClass ' ] = 'coverFile ' ;
121
+ $ icon = '<img alt="file" src="file.png"/> ' ;
122
+ $ itemClass = 'coverFile ' ;
133
123
}
134
124
}
135
125
136
- return $ this ->renderItemTemplate (
137
- new Text_Template ($ this ->templatePath . 'directory_item.html ' ),
138
- $ data
126
+ $ numClasses = $ item ->getNumClasses ();
127
+ $ testedClassesPercent = floor ($ item ->getTestedClassesPercent (FALSE ));
128
+
129
+ if ($ numClasses > 0 ) {
130
+ list ($ classesColor , $ classesLevel ) = $ this ->getColorLevel (
131
+ $ testedClassesPercent
132
+ );
133
+
134
+ $ classesNumber = $ item ->getNumTestedClasses () . ' / ' . $ numClasses ;
135
+ } else {
136
+ $ classesColor = 'snow ' ;
137
+ $ classesLevel = 'None ' ;
138
+ $ classesNumber = ' ' ;
139
+ }
140
+
141
+ $ numMethods = $ item ->getNumMethods ();
142
+ $ testedMethodsPercent = floor ($ item ->getTestedMethodsPercent (FALSE ));
143
+
144
+ if ($ numMethods > 0 ) {
145
+ list ($ methodsColor , $ methodsLevel ) = $ this ->getColorLevel (
146
+ $ testedMethodsPercent
147
+ );
148
+
149
+ $ methodsNumber = $ item ->getNumTestedMethods () . ' / ' . $ numMethods ;
150
+ } else {
151
+ $ methodsColor = 'snow ' ;
152
+ $ methodsLevel = 'None ' ;
153
+ $ methodsNumber = ' ' ;
154
+ }
155
+
156
+ $ linesExecutedPercent = floor ($ item ->getLineExecutedPercent (FALSE ));
157
+
158
+ list ($ linesColor , $ linesLevel ) = $ this ->getColorLevel (
159
+ $ linesExecutedPercent
139
160
);
161
+
162
+ $ template ->setVar (
163
+ array (
164
+ 'itemClass ' => $ itemClass ,
165
+ 'icon ' => $ icon ,
166
+ 'name ' => $ name ,
167
+ 'lines_color ' => $ linesColor ,
168
+ 'lines_executed_width ' => $ linesExecutedPercent ,
169
+ 'lines_not_executed_width ' => 100 - $ linesExecutedPercent ,
170
+ 'lines_executed_percent ' => $ item ->getLineExecutedPercent (),
171
+ 'lines_level ' => $ linesLevel ,
172
+ 'num_executed_lines ' => $ item ->getNumExecutedLines (),
173
+ 'num_executable_lines ' => $ item ->getNumExecutableLines (),
174
+ 'methods_color ' => $ methodsColor ,
175
+ 'methods_tested_width ' => $ testedMethodsPercent ,
176
+ 'methods_not_tested_width ' => 100 - $ testedMethodsPercent ,
177
+ 'methods_tested_percent ' => $ item ->getTestedMethodsPercent (),
178
+ 'methods_level ' => $ methodsLevel ,
179
+ 'methods_number ' => $ methodsNumber ,
180
+ 'classes_color ' => $ classesColor ,
181
+ 'classes_tested_width ' => $ testedClassesPercent ,
182
+ 'classes_not_tested_width ' => 100 - $ testedClassesPercent ,
183
+ 'classes_tested_percent ' => $ item ->getTestedClassesPercent (),
184
+ 'classes_level ' => $ classesLevel ,
185
+ 'classes_number ' => $ classesNumber
186
+ )
187
+ );
188
+
189
+ return $ template ->render ();
140
190
}
141
191
}
0 commit comments