1<?php 2/* 3 * This file is part of PHPUnit. 4 * 5 * (c) Sebastian Bergmann <sebastian@phpunit.de> 6 * 7 * For the full copyright and license information, please view the LICENSE 8 * file that was distributed with this source code. 9 */ 10 11class Framework_TestListenerTest extends PHPUnit_Framework_TestCase implements PHPUnit_Framework_TestListener 12{ 13 protected $endCount; 14 protected $errorCount; 15 protected $failureCount; 16 protected $warningCount; 17 protected $notImplementedCount; 18 protected $riskyCount; 19 protected $skippedCount; 20 protected $result; 21 protected $startCount; 22 23 public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) 24 { 25 $this->errorCount++; 26 } 27 28 public function addWarning(PHPUnit_Framework_Test $test, PHPUnit_Framework_Warning $e, $time) 29 { 30 $this->warningCount++; 31 } 32 33 public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) 34 { 35 $this->failureCount++; 36 } 37 38 public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) 39 { 40 $this->notImplementedCount++; 41 } 42 43 public function addRiskyTest(PHPUnit_Framework_Test $test, Exception $e, $time) 44 { 45 $this->riskyCount++; 46 } 47 48 public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) 49 { 50 $this->skippedCount++; 51 } 52 53 public function startTestSuite(PHPUnit_Framework_TestSuite $suite) 54 { 55 } 56 57 public function endTestSuite(PHPUnit_Framework_TestSuite $suite) 58 { 59 } 60 61 public function startTest(PHPUnit_Framework_Test $test) 62 { 63 $this->startCount++; 64 } 65 66 public function endTest(PHPUnit_Framework_Test $test, $time) 67 { 68 $this->endCount++; 69 } 70 71 protected function setUp() 72 { 73 $this->result = new PHPUnit_Framework_TestResult; 74 $this->result->addListener($this); 75 76 $this->endCount = 0; 77 $this->failureCount = 0; 78 $this->notImplementedCount = 0; 79 $this->riskyCount = 0; 80 $this->skippedCount = 0; 81 $this->startCount = 0; 82 } 83 84 public function testError() 85 { 86 $test = new TestError; 87 $test->run($this->result); 88 89 $this->assertEquals(1, $this->errorCount); 90 $this->assertEquals(1, $this->endCount); 91 } 92 93 public function testFailure() 94 { 95 $test = new Failure; 96 $test->run($this->result); 97 98 $this->assertEquals(1, $this->failureCount); 99 $this->assertEquals(1, $this->endCount); 100 } 101 102 public function testStartStop() 103 { 104 $test = new Success; 105 $test->run($this->result); 106 107 $this->assertEquals(1, $this->startCount); 108 $this->assertEquals(1, $this->endCount); 109 } 110} 111