r94678 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94677‎ | r94678 | r94679 >
Date:19:18, 16 August 2011
Author:demon
Status:resolved
Tags:
Comment:
Remove ParserHelpers. NewParserTest still needs some cleanup, but it doesn't rely on this. All tests still pass.
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php (deleted) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/parser/ParserHelpers.php
@@ -1,136 +0,0 @@
2 -<?php
3 -
4 -class PHPUnitParserTest extends ParserTest {
5 - function showTesting( $desc ) {
6 - /* Do nothing since we don't want to show info during PHPUnit testing. */
7 - }
8 -
9 - public function showSuccess( $desc ) {
10 - PHPUnit_Framework_Assert::assertTrue( true, $desc );
11 - return true;
12 - }
13 -
14 - public function showFailure( $desc, $expected, $got ) {
15 - PHPUnit_Framework_Assert::assertEquals( $expected, $got, $desc );
16 - return false;
17 - }
18 -
19 - public function setupRecorder( $options ) {
20 - $this->recorder = new PHPUnitTestRecorder( $this );
21 - }
22 -}
23 -
24 -class ParserUnitTest extends MediaWikiTestCase {
25 - private $test = "";
26 -
27 - public function __construct( $suite, $test = null ) {
28 - parent::__construct();
29 - $this->test = $test;
30 - $this->suite = $suite;
31 - }
32 -
33 - function count() { return 1; }
34 -
35 - public function run( PHPUnit_Framework_TestResult $result = null ) {
36 - PHPUnit_Framework_Assert::resetCount();
37 - if ( $result === NULL ) {
38 - $result = new PHPUnit_Framework_TestResult;
39 - }
40 -
41 - $this->suite->publishTestArticles(); // Add articles needed by the tests.
42 - $backend = new ParserTestSuiteBackend;
43 - $result->startTest( $this );
44 -
45 - // Support the transition to PHPUnit 3.5 where PHPUnit_Util_Timer is replaced with PHP_Timer
46 - if ( class_exists( 'PHP_Timer' ) ) {
47 - PHP_Timer::start();
48 - } else {
49 - PHPUnit_Util_Timer::start();
50 - }
51 -
52 - $r = false;
53 - try {
54 - # Run the test.
55 - # On failure, the subclassed backend will throw an exception with
56 - # the details.
57 - $pt = new PHPUnitParserTest;
58 - $r = $pt->runTest( $this->test['test'], $this->test['input'],
59 - $this->test['result'], $this->test['options'], $this->test['config']
60 - );
61 - }
62 - catch ( PHPUnit_Framework_AssertionFailedError $e ) {
63 -
64 - // PHPUnit_Util_Timer -> PHP_Timer support (see above)
65 - if ( class_exists( 'PHP_Timer' ) ) {
66 - $result->addFailure( $this, $e, PHP_Timer::stop() );
67 - } else {
68 - $result->addFailure( $this, $e, PHPUnit_Util_Timer::stop() );
69 - }
70 - }
71 - catch ( Exception $e ) {
72 - // PHPUnit_Util_Timer -> PHP_Timer support (see above)
73 - if ( class_exists( 'PHP_Timer' ) ) {
74 - $result->addFailure( $this, $e, PHP_Timer::stop() );
75 - } else {
76 - $result->addFailure( $this, $e, PHPUnit_Util_Timer::stop() );
77 - }
78 - }
79 -
80 - // PHPUnit_Util_Timer -> PHP_Timer support (see above)
81 - if ( class_exists( 'PHP_Timer' ) ) {
82 - $result->endTest( $this, PHP_Timer::stop() );
83 - } else {
84 - $result->endTest( $this, PHPUnit_Util_Timer::stop() );
85 - }
86 -
87 - $backend->recorder->record( $this->test['test'], $r );
88 - $this->addToAssertionCount( PHPUnit_Framework_Assert::getCount() );
89 -
90 - return $result;
91 - }
92 -
93 - public function toString() {
94 - return $this->test['test'];
95 - }
96 -
97 -}
98 -
99 -class ParserTestSuiteBackend extends PHPUnit_FrameWork_TestSuite {
100 - public $recorder;
101 - public $term;
102 - static $usePHPUnit = false;
103 -
104 - function __construct() {
105 - parent::__construct();
106 - $this->setupRecorder(null);
107 - self::$usePHPUnit = method_exists('PHPUnit_Framework_Assert', 'assertEquals');
108 - }
109 -
110 - function showTesting( $desc ) {
111 - }
112 -
113 - function showRunFile( $path ) {
114 - }
115 -
116 - function showTestResult( $desc, $result, $out ) {
117 - if ( $result === $out ) {
118 - return self::showSuccess( $desc, $result, $out );
119 - } else {
120 - return self::showFailure( $desc, $result, $out );
121 - }
122 - }
123 -
124 - public function setupRecorder( $options ) {
125 - $this->recorder = new PHPUnitTestRecorder( $this );
126 - }
127 -}
128 -
129 -class PHPUnitTestRecorder extends TestRecorder {
130 - function record( $test, $result ) {
131 - $this->total++;
132 - $this->success += $result;
133 -
134 - }
135 -
136 - function reportPercentage( $success, $total ) { }
137 -}

Follow-up revisions

RevisionCommit summaryAuthorDate
r94679Followup r94678: remove some include and autoload entries. tests still passingdemon19:25, 16 August 2011

Status & tagging log