| Line # | Frequency | Source Line | | 1 | | <?php |
| 2 | | /** |
| 3 | | * base include file for SimpleTest |
| 4 | | * @package SimpleTest |
| 5 | | * @subpackage UnitTester |
| 6 | | * @version $Id: scorer.php 1672 2008-03-02 04:47:34Z edwardzyang $ |
| 7 | | */ |
| 8 | | |
| 9 | | /**#@+*/ |
| 10 | | require_once(dirname(__FILE__) . '/invoker.php'); |
| 11 | | /**#@-*/ |
| 12 | | |
| 13 | | /** |
| 14 | | * Can recieve test events and display them. Display |
| 15 | | * is achieved by making display methods available |
| 16 | | * and visiting the incoming event. |
| 17 | | * @package SimpleTest |
| 18 | | * @subpackage UnitTester |
| 19 | | * @abstract |
| 20 | | */ |
| 21 | | class SimpleScorer { |
| 22 | | var $_passes; |
| 23 | | var $_fails; |
| 24 | | var $_exceptions; |
| 25 | | var $_is_dry_run; |
| 26 | | |
| 27 | | /** |
| 28 | | * Starts the test run with no results. |
| 29 | | * @access public |
| 30 | | */ |
| 31 | | function SimpleScorer() { |
| 32 | 1 | $this->_passes = 0; |
| 33 | 1 | $this->_fails = 0; |
| 34 | 1 | $this->_exceptions = 0; |
| 35 | 1 | $this->_is_dry_run = false; |
| 36 | | } |
| 37 | | |
| 38 | | /** |
| 39 | | * Signals that the next evaluation will be a dry |
| 40 | | * run. That is, the structure events will be |
| 41 | | * recorded, but no tests will be run. |
| 42 | | * @param boolean $is_dry Dry run if true. |
| 43 | | * @access public |
| 44 | | */ |
| 45 | | function makeDry($is_dry = true) { |
| 46 | | $this->_is_dry_run = $is_dry; |
| 47 | | } |
| 48 | | |
| 49 | | /** |
| 50 | | * The reporter has a veto on what should be run. |
| 51 | | * @param string $test_case_name name of test case. |
| 52 | | * @param string $method Name of test method. |
| 53 | | * @access public |
| 54 | | */ |
| 55 | | function shouldInvoke($test_case_name, $method) { |
| 56 | 1 | return ! $this->_is_dry_run; |
| 57 | | } |
| 58 | | |
| 59 | | /** |
| 60 | | * Can wrap the invoker in preperation for running |
| 61 | | * a test. |
| 62 | | * @param SimpleInvoker $invoker Individual test runner. |
| 63 | | * @return SimpleInvoker Wrapped test runner. |
| 64 | | * @access public |
| 65 | | */ |
| 66 | | function &createInvoker(&$invoker) { |
| 67 | 1 | return $invoker; |
| 68 | | } |
| 69 | | |
| 70 | | /** |
| 71 | | * Accessor for current status. Will be false |
| 72 | | * if there have been any failures or exceptions. |
| 73 | | * Used for command line tools. |
| 74 | | * @return boolean True if no failures. |
| 75 | | * @access public |
| 76 | | */ |
| 77 | | function getStatus() { |
| 78 | 1 | if ($this->_exceptions + $this->_fails > 0) { |
| 79 | | return false; |
| 80 | | } |
| 81 | 1 | return true; |
| 82 | | } |
| 83 | | |
| 84 | | /** |
| 85 | | * Paints the start of a group test. |
| 86 | | * @param string $test_name Name of test or other label. |
| 87 | | * @param integer $size Number of test cases starting. |
| 88 | | * @access public |
| 89 | | */ |
| 90 | | function paintGroupStart($test_name, $size) { |
| 91 | | } |
| 92 | | |
| 93 | | /** |
| 94 | | * Paints the end of a group test. |
| 95 | | * @param string $test_name Name of test or other label. |
| 96 | | * @access public |
| 97 | | */ |
| 98 | | function paintGroupEnd($test_name) { |
| 99 | | } |
| 100 | | |
| 101 | | /** |
| 102 | | * Paints the start of a test case. |
| 103 | | * @param string $test_name Name of test or other label. |
| 104 | | * @access public |
| 105 | | */ |
| 106 | | function paintCaseStart($test_name) { |
| 107 | | } |
| 108 | | |
| 109 | | /** |
| 110 | | * Paints the end of a test case. |
| 111 | | * @param string $test_name Name of test or other label. |
| 112 | | * @access public |
| 113 | | */ |
| 114 | | function paintCaseEnd($test_name) { |
| 115 | | } |
| 116 | | |
| 117 | | /** |
| 118 | | * Paints the start of a test method. |
| 119 | | * @param string $test_name Name of test or other label. |
| 120 | | * @access public |
| 121 | | */ |
| 122 | | function paintMethodStart($test_name) { |
| 123 | | } |
| 124 | | |
| 125 | | /** |
| 126 | | * Paints the end of a test method. |
| 127 | | * @param string $test_name Name of test or other label. |
| 128 | | * @access public |
| 129 | | */ |
| 130 | | function paintMethodEnd($test_name) { |
| 131 | | } |
| 132 | | |
| 133 | | /** |
| 134 | | * Increments the pass count. |
| 135 | | * @param string $message Message is ignored. |
| 136 | | * @access public |
| 137 | | */ |
| 138 | | function paintPass($message) { |
| 139 | 1 | $this->_passes++; |
| 140 | | } |
| 141 | | |
| 142 | | /** |
| 143 | | * Increments the fail count. |
| 144 | | * @param string $message Message is ignored. |
| 145 | | * @access public |
| 146 | | */ |
| 147 | | function paintFail($message) { |
| 148 | | $this->_fails++; |
| 149 | | } |
| 150 | | |
| 151 | | /** |
| 152 | | * Deals with PHP 4 throwing an error. |
| 153 | | * @param string $message Text of error formatted by |
| 154 | | * the test case. |
| 155 | | * @access public |
| 156 | | */ |
| 157 | | function paintError($message) { |
| 158 | | $this->_exceptions++; |
| 159 | | } |
| 160 | | |
| 161 | | /** |
| 162 | | * Deals with PHP 5 throwing an exception. |
| 163 | | * @param Exception $exception The actual exception thrown. |
| 164 | | * @access public |
| 165 | | */ |
| 166 | | function paintException($exception) { |
| 167 | | $this->_exceptions++; |
| 168 | | } |
| 169 | | |
| 170 | | /** |
| 171 | | * Prints the message for skipping tests. |
| 172 | | * @param string $message Text of skip condition. |
| 173 | | * @access public |
| 174 | | */ |
| 175 | | function paintSkip($message) { |
| 176 | | } |
| 177 | | |
| 178 | | /** |
| 179 | | * Accessor for the number of passes so far. |
| 180 | | * @return integer Number of passes. |
| 181 | | * @access public |
| 182 | | */ |
| 183 | | function getPassCount() { |
| 184 | 1 | return $this->_passes; |
| 185 | | } |
| 186 | | |
| 187 | | /** |
| 188 | | * Accessor for the number of fails so far. |
| 189 | | * @return integer Number of fails. |
| 190 | | * @access public |
| 191 | | */ |
| 192 | | function getFailCount() { |
| 193 | 1 | return $this->_fails; |
| 194 | | } |
| 195 | | |
| 196 | | /** |
| 197 | | * Accessor for the number of untrapped errors |
| 198 | | * so far. |
| 199 | | * @return integer Number of exceptions. |
| 200 | | * @access public |
| 201 | | */ |
| 202 | | function getExceptionCount() { |
| 203 | 1 | return $this->_exceptions; |
| 204 | | } |
| 205 | | |
| 206 | | /** |
| 207 | | * Paints a simple supplementary message. |
| 208 | | * @param string $message Text to display. |
| 209 | | * @access public |
| 210 | | */ |
| 211 | | function paintMessage($message) { |
| 212 | | } |
| 213 | | |
| 214 | | /** |
| 215 | | * Paints a formatted ASCII message such as a |
| 216 | | * variable dump. |
| 217 | | * @param string $message Text to display. |
| 218 | | * @access public |
| 219 | | */ |
| 220 | | function paintFormattedMessage($message) { |
| 221 | | } |
| 222 | | |
| 223 | | /** |
| 224 | | * By default just ignores user generated events. |
| 225 | | * @param string $type Event type as text. |
| 226 | | * @param mixed $payload Message or object. |
| 227 | | * @access public |
| 228 | | */ |
| 229 | | function paintSignal($type, $payload) { |
| 230 | | } |
| 231 | | } |
| 232 | | |
| 233 | | /** |
| 234 | | * Recipient of generated test messages that can display |
| 235 | | * page footers and headers. Also keeps track of the |
| 236 | | * test nesting. This is the main base class on which |
| 237 | | * to build the finished test (page based) displays. |
| 238 | | * @package SimpleTest |
| 239 | | * @subpackage UnitTester |
| 240 | | */ |
| 241 | | class SimpleReporter extends SimpleScorer { |
| 242 | | var $_test_stack; |
| 243 | | var $_size; |
| 244 | | var $_progress; |
| 245 | | |
| 246 | | /** |
| 247 | | * Starts the display with no results in. |
| 248 | | * @access public |
| 249 | | */ |
| 250 | | function SimpleReporter() { |
| 251 | 1 | $this->SimpleScorer(); |
| 252 | 1 | $this->_test_stack = array(); |
| 253 | 1 | $this->_size = null; |
| 254 | 1 | $this->_progress = 0; |
| 255 | | } |
| 256 | | |
| 257 | | /** |
| 258 | | * Gets the formatter for variables and other small |
| 259 | | * generic data items. |
| 260 | | * @return SimpleDumper Formatter. |
| 261 | | * @access public |
| 262 | | */ |
| 263 | | function getDumper() { |
| 264 | 1 | return new SimpleDumper(); |
| 265 | | } |
| 266 | | |
| 267 | | /** |
| 268 | | * Paints the start of a group test. Will also paint |
| 269 | | * the page header and footer if this is the |
| 270 | | * first test. Will stash the size if the first |
| 271 | | * start. |
| 272 | | * @param string $test_name Name of test that is starting. |
| 273 | | * @param integer $size Number of test cases starting. |
| 274 | | * @access public |
| 275 | | */ |
| 276 | | function paintGroupStart($test_name, $size) { |
| 277 | | if (! isset($this->_size)) { |
| 278 | | $this->_size = $size; |
| 279 | | } |
| 280 | | if (count($this->_test_stack) == 0) { |
| 281 | | $this->paintHeader($test_name); |
| 282 | | } |
| 283 | | $this->_test_stack[] = $test_name; |
| 284 | | } |
| 285 | | |
| 286 | | /** |
| 287 | | * Paints the end of a group test. Will paint the page |
| 288 | | * footer if the stack of tests has unwound. |
| 289 | | * @param string $test_name Name of test that is ending. |
| 290 | | * @param integer $progress Number of test cases ending. |
| 291 | | * @access public |
| 292 | | */ |
| 293 | | function paintGroupEnd($test_name) { |
| 294 | | array_pop($this->_test_stack); |
| 295 | | if (count($this->_test_stack) == 0) { |
| 296 | | $this->paintFooter($test_name); |
| 297 | | } |
| 298 | | } |
| 299 | | |
| 300 | | /** |
| 301 | | * Paints the start of a test case. Will also paint |
| 302 | | * the page header and footer if this is the |
| 303 | | * first test. Will stash the size if the first |
| 304 | | * start. |
| 305 | | * @param string $test_name Name of test that is starting. |
| 306 | | * @access public |
| 307 | | */ |
| 308 | | function paintCaseStart($test_name) { |
| 309 | | if (! isset($this->_size)) { |
| 310 | | $this->_size = 1; |
| 311 | | } |
| 312 | | if (count($this->_test_stack) == 0) { |
| 313 | | $this->paintHeader($test_name); |
| 314 | | } |
| 315 | | $this->_test_stack[] = $test_name; |
| 316 | | } |
| 317 | | |
| 318 | | /** |
| 319 | | * Paints the end of a test case. Will paint the page |
| 320 | | * footer if the stack of tests has unwound. |
| 321 | | * @param string $test_name Name of test that is ending. |
| 322 | | * @access public |
| 323 | | */ |
| 324 | | function paintCaseEnd($test_name) { |
| 325 | | $this->_progress++; |
| 326 | | array_pop($this->_test_stack); |
| 327 | | if (count($this->_test_stack) == 0) { |
| 328 | | $this->paintFooter($test_name); |
| 329 | | } |
| 330 | | } |
| 331 | | |
| 332 | | /** |
| 333 | | * Paints the start of a test method. |
| 334 | | * @param string $test_name Name of test that is starting. |
| 335 | | * @access public |
| 336 | | */ |
| 337 | | function paintMethodStart($test_name) { |
| 338 | 1 | $this->_test_stack[] = $test_name; |
| 339 | | } |
| 340 | | |
| 341 | | /** |
| 342 | | * Paints the end of a test method. Will paint the page |
| 343 | | * footer if the stack of tests has unwound. |
| 344 | | * @param string $test_name Name of test that is ending. |
| 345 | | * @access public |
| 346 | | */ |
| 347 | | function paintMethodEnd($test_name) { |
| 348 | 1 | array_pop($this->_test_stack); |
| 349 | | } |
| 350 | | |
| 351 | | /** |
| 352 | | * Paints the test document header. |
| 353 | | * @param string $test_name First test top level |
| 354 | | * to start. |
| 355 | | * @access public |
| 356 | | * @abstract |
| 357 | | */ |
| 358 | | function paintHeader($test_name) { |
| 359 | | } |
| 360 | | |
| 361 | | /** |
| 362 | | * Paints the test document footer. |
| 363 | | * @param string $test_name The top level test. |
| 364 | | * @access public |
| 365 | | * @abstract |
| 366 | | */ |
| 367 | | function paintFooter($test_name) { |
| 368 | | } |
| 369 | | |
| 370 | | /** |
| 371 | | * Accessor for internal test stack. For |
| 372 | | * subclasses that need to see the whole test |
| 373 | | * history for display purposes. |
| 374 | | * @return array List of methods in nesting order. |
| 375 | | * @access public |
| 376 | | */ |
| 377 | | function getTestList() { |
| 378 | | return $this->_test_stack; |
| 379 | | } |
| 380 | | |
| 381 | | /** |
| 382 | | * Accessor for total test size in number |
| 383 | | * of test cases. Null until the first |
| 384 | | * test is started. |
| 385 | | * @return integer Total number of cases at start. |
| 386 | | * @access public |
| 387 | | */ |
| 388 | | function getTestCaseCount() { |
| 389 | | return $this->_size; |
| 390 | | } |
| 391 | | |
| 392 | | /** |
| 393 | | * Accessor for the number of test cases |
| 394 | | * completed so far. |
| 395 | | * @return integer Number of ended cases. |
| 396 | | * @access public |
| 397 | | */ |
| 398 | | function getTestCaseProgress() { |
| 399 | 1 | return $this->_progress; |
| 400 | | } |
| 401 | | |
| 402 | | /** |
| 403 | | * Static check for running in the comand line. |
| 404 | | * @return boolean True if CLI. |
| 405 | | * @access public |
| 406 | | * @static |
| 407 | | */ |
| 408 | | function inCli() { |
| 409 | | return php_sapi_name() == 'cli'; |
| 410 | | } |
| 411 | | } |
| 412 | | |
| 413 | | /** |
| 414 | | * For modifying the behaviour of the visual reporters. |
| 415 | | * @package SimpleTest |
| 416 | | * @subpackage UnitTester |
| 417 | | */ |
| 418 | | class SimpleReporterDecorator { |
| 419 | | var $_reporter; |
| 420 | | |
| 421 | | /** |
| 422 | | * Mediates between the reporter and the test case. |
| 423 | | * @param SimpleScorer $reporter Reporter to receive events. |
| 424 | | */ |
| 425 | | function SimpleReporterDecorator(&$reporter) { |
| 426 | | $this->_reporter = &$reporter; |
| 427 | | } |
| 428 | | |
| 429 | | /** |
| 430 | | * Signals that the next evaluation will be a dry |
| 431 | | * run. That is, the structure events will be |
| 432 | | * recorded, but no tests will be run. |
| 433 | | * @param boolean $is_dry Dry run if true. |
| 434 | | * @access public |
| 435 | | */ |
| 436 | | function makeDry($is_dry = true) { |
| 437 | | $this->_reporter->makeDry($is_dry); |
| 438 | | } |
| 439 | | |
| 440 | | /** |
| 441 | | * Accessor for current status. Will be false |
| 442 | | * if there have been any failures or exceptions. |
| 443 | | * Used for command line tools. |
| 444 | | * @return boolean True if no failures. |
| 445 | | * @access public |
| 446 | | */ |
| 447 | | function getStatus() { |
| 448 | | return $this->_reporter->getStatus(); |
| 449 | | } |
| 450 | | |
| 451 | | /** |
| 452 | | * The reporter has a veto on what should be run. |
| 453 | | * @param string $test_case_name name of test case. |
| 454 | | * @param string $method Name of test method. |
| 455 | | * @return boolean True if test should be run. |
| 456 | | * @access public |
| 457 | | */ |
| 458 | | function shouldInvoke($test_case_name, $method) { |
| 459 | | return $this->_reporter->shouldInvoke($test_case_name, $method); |
| 460 | | } |
| 461 | | |
| 462 | | /** |
| 463 | | * Can wrap the invoker in preperation for running |
| 464 | | * a test. |
| 465 | | * @param SimpleInvoker $invoker Individual test runner. |
| 466 | | * @return SimpleInvoker Wrapped test runner. |
| 467 | | * @access public |
| 468 | | */ |
| 469 | | function &createInvoker(&$invoker) { |
| 470 | | return $this->_reporter->createInvoker($invoker); |
| 471 | | } |
| 472 | | |
| 473 | | /** |
| 474 | | * Gets the formatter for variables and other small |
| 475 | | * generic data items. |
| 476 | | * @return SimpleDumper Formatter. |
| 477 | | * @access public |
| 478 | | */ |
| 479 | | function getDumper() { |
| 480 | | return $this->_reporter->getDumper(); |
| 481 | | } |
| 482 | | |
| 483 | | /** |
| 484 | | * Paints the start of a group test. |
| 485 | | * @param string $test_name Name of test or other label. |
| 486 | | * @param integer $size Number of test cases starting. |
| 487 | | * @access public |
| 488 | | */ |
| 489 | | function paintGroupStart($test_name, $size) { |
| 490 | | $this->_reporter->paintGroupStart($test_name, $size); |
| 491 | | } |
| 492 | | |
| 493 | | /** |
| 494 | | * Paints the end of a group test. |
| 495 | | * @param string $test_name Name of test or other label. |
| 496 | | * @access public |
| 497 | | */ |
| 498 | | function paintGroupEnd($test_name) { |
| 499 | | $this->_reporter->paintGroupEnd($test_name); |
| 500 | | } |
| 501 | | |
| 502 | | /** |
| 503 | | * Paints the start of a test case. |
| 504 | | * @param string $test_name Name of test or other label. |
| 505 | | * @access public |
| 506 | | */ |
| 507 | | function paintCaseStart($test_name) { |
| 508 | | $this->_reporter->paintCaseStart($test_name); |
| 509 | | } |
| 510 | | |
| 511 | | /** |
| 512 | | * Paints the end of a test case. |
| 513 | | * @param string $test_name Name of test or other label. |
| 514 | | * @access public |
| 515 | | */ |
| 516 | | function paintCaseEnd($test_name) { |
| 517 | | $this->_reporter->paintCaseEnd($test_name); |
| 518 | | } |
| 519 | | |
| 520 | | /** |
| 521 | | * Paints the start of a test method. |
| 522 | | * @param string $test_name Name of test or other label. |
| 523 | | * @access public |
| 524 | | */ |
| 525 | | function paintMethodStart($test_name) { |
| 526 | | $this->_reporter->paintMethodStart($test_name); |
| 527 | | } |
| 528 | | |
| 529 | | /** |
| 530 | | * Paints the end of a test method. |
| 531 | | * @param string $test_name Name of test or other label. |
| 532 | | * @access public |
| 533 | | */ |
| 534 | | function paintMethodEnd($test_name) { |
| 535 | | $this->_reporter->paintMethodEnd($test_name); |
| 536 | | } |
| 537 | | |
| 538 | | /** |
| 539 | | * Chains to the wrapped reporter. |
| 540 | | * @param string $message Message is ignored. |
| 541 | | * @access public |
| 542 | | */ |
| 543 | | function paintPass($message) { |
| 544 | | $this->_reporter->paintPass($message); |
| 545 | | } |
| 546 | | |
| 547 | | /** |
| 548 | | * Chains to the wrapped reporter. |
| 549 | | * @param string $message Message is ignored. |
| 550 | | * @access public |
| 551 | | */ |
| 552 | | function paintFail($message) { |
| 553 | | $this->_reporter->paintFail($message); |
| 554 | | } |
| 555 | | |
| 556 | | /** |
| 557 | | * Chains to the wrapped reporter. |
| 558 | | * @param string $message Text of error formatted by |
| 559 | | * the test case. |
| 560 | | * @access public |
| 561 | | */ |
| 562 | | function paintError($message) { |
| 563 | | $this->_reporter->paintError($message); |
| 564 | | } |
| 565 | | |
| 566 | | /** |
| 567 | | * Chains to the wrapped reporter. |
| 568 | | * @param Exception $exception Exception to show. |
| 569 | | * @access public |
| 570 | | */ |
| 571 | | function paintException($exception) { |
| 572 | | $this->_reporter->paintException($exception); |
| 573 | | } |
| 574 | | |
| 575 | | /** |
| 576 | | * Prints the message for skipping tests. |
| 577 | | * @param string $message Text of skip condition. |
| 578 | | * @access public |
| 579 | | */ |
| 580 | | function paintSkip($message) { |
| 581 | | $this->_reporter->paintSkip($message); |
| 582 | | } |
| 583 | | |
| 584 | | /** |
| 585 | | * Chains to the wrapped reporter. |
| 586 | | * @param string $message Text to display. |
| 587 | | * @access public |
| 588 | | */ |
| 589 | | function paintMessage($message) { |
| 590 | | $this->_reporter->paintMessage($message); |
| 591 | | } |
| 592 | | |
| 593 | | /** |
| 594 | | * Chains to the wrapped reporter. |
| 595 | | * @param string $message Text to display. |
| 596 | | * @access public |
| 597 | | */ |
| 598 | | function paintFormattedMessage($message) { |
| 599 | | $this->_reporter->paintFormattedMessage($message); |
| 600 | | } |
| 601 | | |
| 602 | | /** |
| 603 | | * Chains to the wrapped reporter. |
| 604 | | * @param string $type Event type as text. |
| 605 | | * @param mixed $payload Message or object. |
| 606 | | * @return boolean Should return false if this |
| 607 | | * type of signal should fail the |
| 608 | | * test suite. |
| 609 | | * @access public |
| 610 | | */ |
| 611 | | function paintSignal($type, &$payload) { |
| 612 | | $this->_reporter->paintSignal($type, $payload); |
| 613 | | } |
| 614 | | } |
| 615 | | |
| 616 | | /** |
| 617 | | * For sending messages to multiple reporters at |
| 618 | | * the same time. |
| 619 | | * @package SimpleTest |
| 620 | | * @subpackage UnitTester |
| 621 | | */ |
| 622 | | class MultipleReporter { |
| 623 | | var $_reporters = array(); |
| 624 | | |
| 625 | | /** |
| 626 | | * Adds a reporter to the subscriber list. |
| 627 | | * @param SimpleScorer $reporter Reporter to receive events. |
| 628 | | * @access public |
| 629 | | */ |
| 630 | | function attachReporter(&$reporter) { |
| 631 | | $this->_reporters[] = &$reporter; |
| 632 | | } |
| 633 | | |
| 634 | | /** |
| 635 | | * Signals that the next evaluation will be a dry |
| 636 | | * run. That is, the structure events will be |
| 637 | | * recorded, but no tests will be run. |
| 638 | | * @param boolean $is_dry Dry run if true. |
| 639 | | * @access public |
| 640 | | */ |
| 641 | | function makeDry($is_dry = true) { |
| 642 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 643 | | $this->_reporters[$i]->makeDry($is_dry); |
| 644 | | } |
| 645 | | } |
| 646 | | |
| 647 | | /** |
| 648 | | * Accessor for current status. Will be false |
| 649 | | * if there have been any failures or exceptions. |
| 650 | | * If any reporter reports a failure, the whole |
| 651 | | * suite fails. |
| 652 | | * @return boolean True if no failures. |
| 653 | | * @access public |
| 654 | | */ |
| 655 | | function getStatus() { |
| 656 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 657 | | if (! $this->_reporters[$i]->getStatus()) { |
| 658 | | return false; |
| 659 | | } |
| 660 | | } |
| 661 | | return true; |
| 662 | | } |
| 663 | | |
| 664 | | /** |
| 665 | | * The reporter has a veto on what should be run. |
| 666 | | * It requires all reporters to want to run the method. |
| 667 | | * @param string $test_case_name name of test case. |
| 668 | | * @param string $method Name of test method. |
| 669 | | * @access public |
| 670 | | */ |
| 671 | | function shouldInvoke($test_case_name, $method) { |
| 672 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 673 | | if (! $this->_reporters[$i]->shouldInvoke($test_case_name, $method)) { |
| 674 | | return false; |
| 675 | | } |
| 676 | | } |
| 677 | | return true; |
| 678 | | } |
| 679 | | |
| 680 | | /** |
| 681 | | * Every reporter gets a chance to wrap the invoker. |
| 682 | | * @param SimpleInvoker $invoker Individual test runner. |
| 683 | | * @return SimpleInvoker Wrapped test runner. |
| 684 | | * @access public |
| 685 | | */ |
| 686 | | function &createInvoker(&$invoker) { |
| 687 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 688 | | $invoker = &$this->_reporters[$i]->createInvoker($invoker); |
| 689 | | } |
| 690 | | return $invoker; |
| 691 | | } |
| 692 | | |
| 693 | | /** |
| 694 | | * Gets the formatter for variables and other small |
| 695 | | * generic data items. |
| 696 | | * @return SimpleDumper Formatter. |
| 697 | | * @access public |
| 698 | | */ |
| 699 | | function getDumper() { |
| 700 | | return new SimpleDumper(); |
| 701 | | } |
| 702 | | |
| 703 | | /** |
| 704 | | * Paints the start of a group test. |
| 705 | | * @param string $test_name Name of test or other label. |
| 706 | | * @param integer $size Number of test cases starting. |
| 707 | | * @access public |
| 708 | | */ |
| 709 | | function paintGroupStart($test_name, $size) { |
| 710 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 711 | | $this->_reporters[$i]->paintGroupStart($test_name, $size); |
| 712 | | } |
| 713 | | } |
| 714 | | |
| 715 | | /** |
| 716 | | * Paints the end of a group test. |
| 717 | | * @param string $test_name Name of test or other label. |
| 718 | | * @access public |
| 719 | | */ |
| 720 | | function paintGroupEnd($test_name) { |
| 721 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 722 | | $this->_reporters[$i]->paintGroupEnd($test_name); |
| 723 | | } |
| 724 | | } |
| 725 | | |
| 726 | | /** |
| 727 | | * Paints the start of a test case. |
| 728 | | * @param string $test_name Name of test or other label. |
| 729 | | * @access public |
| 730 | | */ |
| 731 | | function paintCaseStart($test_name) { |
| 732 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 733 | | $this->_reporters[$i]->paintCaseStart($test_name); |
| 734 | | } |
| 735 | | } |
| 736 | | |
| 737 | | /** |
| 738 | | * Paints the end of a test case. |
| 739 | | * @param string $test_name Name of test or other label. |
| 740 | | * @access public |
| 741 | | */ |
| 742 | | function paintCaseEnd($test_name) { |
| 743 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 744 | | $this->_reporters[$i]->paintCaseEnd($test_name); |
| 745 | | } |
| 746 | | } |
| 747 | | |
| 748 | | /** |
| 749 | | * Paints the start of a test method. |
| 750 | | * @param string $test_name Name of test or other label. |
| 751 | | * @access public |
| 752 | | */ |
| 753 | | function paintMethodStart($test_name) { |
| 754 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 755 | | $this->_reporters[$i]->paintMethodStart($test_name); |
| 756 | | } |
| 757 | | } |
| 758 | | |
| 759 | | /** |
| 760 | | * Paints the end of a test method. |
| 761 | | * @param string $test_name Name of test or other label. |
| 762 | | * @access public |
| 763 | | */ |
| 764 | | function paintMethodEnd($test_name) { |
| 765 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 766 | | $this->_reporters[$i]->paintMethodEnd($test_name); |
| 767 | | } |
| 768 | | } |
| 769 | | |
| 770 | | /** |
| 771 | | * Chains to the wrapped reporter. |
| 772 | | * @param string $message Message is ignored. |
| 773 | | * @access public |
| 774 | | */ |
| 775 | | function paintPass($message) { |
| 776 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 777 | | $this->_reporters[$i]->paintPass($message); |
| 778 | | } |
| 779 | | } |
| 780 | | |
| 781 | | /** |
| 782 | | * Chains to the wrapped reporter. |
| 783 | | * @param string $message Message is ignored. |
| 784 | | * @access public |
| 785 | | */ |
| 786 | | function paintFail($message) { |
| 787 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 788 | | $this->_reporters[$i]->paintFail($message); |
| 789 | | } |
| 790 | | } |
| 791 | | |
| 792 | | /** |
| 793 | | * Chains to the wrapped reporter. |
| 794 | | * @param string $message Text of error formatted by |
| 795 | | * the test case. |
| 796 | | * @access public |
| 797 | | */ |
| 798 | | function paintError($message) { |
| 799 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 800 | | $this->_reporters[$i]->paintError($message); |
| 801 | | } |
| 802 | | } |
| 803 | | |
| 804 | | /** |
| 805 | | * Chains to the wrapped reporter. |
| 806 | | * @param Exception $exception Exception to display. |
| 807 | | * @access public |
| 808 | | */ |
| 809 | | function paintException($exception) { |
| 810 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 811 | | $this->_reporters[$i]->paintException($exception); |
| 812 | | } |
| 813 | | } |
| 814 | | |
| 815 | | /** |
| 816 | | * Prints the message for skipping tests. |
| 817 | | * @param string $message Text of skip condition. |
| 818 | | * @access public |
| 819 | | */ |
| 820 | | function paintSkip($message) { |
| 821 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 822 | | $this->_reporters[$i]->paintSkip($message); |
| 823 | | } |
| 824 | | } |
| 825 | | |
| 826 | | /** |
| 827 | | * Chains to the wrapped reporter. |
| 828 | | * @param string $message Text to display. |
| 829 | | * @access public |
| 830 | | */ |
| 831 | | function paintMessage($message) { |
| 832 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 833 | | $this->_reporters[$i]->paintMessage($message); |
| 834 | | } |
| 835 | | } |
| 836 | | |
| 837 | | /** |
| 838 | | * Chains to the wrapped reporter. |
| 839 | | * @param string $message Text to display. |
| 840 | | * @access public |
| 841 | | */ |
| 842 | | function paintFormattedMessage($message) { |
| 843 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 844 | | $this->_reporters[$i]->paintFormattedMessage($message); |
| 845 | | } |
| 846 | | } |
| 847 | | |
| 848 | | /** |
| 849 | | * Chains to the wrapped reporter. |
| 850 | | * @param string $type Event type as text. |
| 851 | | * @param mixed $payload Message or object. |
| 852 | | * @return boolean Should return false if this |
| 853 | | * type of signal should fail the |
| 854 | | * test suite. |
| 855 | | * @access public |
| 856 | | */ |
| 857 | | function paintSignal($type, &$payload) { |
| 858 | | for ($i = 0; $i < count($this->_reporters); $i++) { |
| 859 | | $this->_reporters[$i]->paintSignal($type, $payload); |
| 860 | | } |
| 861 | | } |
| 862 | | } |
| 863 | | ? |