r109768 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109767‎ | r109768 | r109769 >
Date:21:57, 22 January 2012
Author:jpostlethwaite
Status:ok
Tags:
Comment:
Adding UnitTest Extension. See r109762.
Modified paths:
  • /trunk/extensions/UnitTest/tests/UnitTest/AllTests.php (added) (history)
  • /trunk/extensions/UnitTest/tests/UnitTest/DebugTestCase.php (added) (history)
  • /trunk/extensions/UnitTest/tests/UnitTest/TemplateTestCase.php (added) (history)
  • /trunk/extensions/UnitTest/tests/UnitTest/VerifySeleniumTestCase.php (added) (history)
  • /trunk/extensions/UnitTest/tests/logs/coverage (added) (history)
  • /trunk/extensions/UnitTest/tests/logs/coverage/clover (added) (history)
  • /trunk/extensions/UnitTest/tests/logs/coverage/html (added) (history)
  • /trunk/extensions/UnitTest/tests/logs/coverage/results (added) (history)

Diff [purge]

Index: trunk/extensions/UnitTest/tests/UnitTest/AllTests.php
@@ -0,0 +1,68 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ *
 18+ * @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org>
 19+ */
 20+
 21+/**
 22+ * TemplateTestCase
 23+ */
 24+require_once 'TemplateTestCase.php';
 25+
 26+/**
 27+ * DebugTestCase
 28+ */
 29+require_once 'DebugTestCase.php';
 30+
 31+/**
 32+ * VerifySeleniumTestCase
 33+ */
 34+require_once 'VerifySeleniumTestCase.php';
 35+
 36+/**
 37+ * UnitTest_AllTests
 38+ */
 39+class UnitTest_AllTests
 40+{
 41+
 42+ /**
 43+ * Run the main test and load any parameters if needed.
 44+ *
 45+ */
 46+ public static function main()
 47+ {
 48+ $parameters = array();
 49+
 50+ PHPUnit_TextUI_TestRunner::run( self::suite(), $parameters );
 51+ }
 52+
 53+ /**
 54+ * Run test suites
 55+ *
 56+ * @return PHPUnit_Framework_TestSuite
 57+ */
 58+ public static function suite()
 59+ {
 60+ $suite = new PHPUnit_Framework_TestSuite( 'UnitTest_AllTests ');
 61+
 62+ //$suite->addTestSuite( 'UnitTest_DebugTestCase' );
 63+ $suite->addTestSuite( 'UnitTest_TemplateTestCase' );
 64+ $suite->addTestSuite( 'UnitTest_VerifySeleniumTestCase' );
 65+
 66+ return $suite;
 67+ }
 68+}
 69+
Property changes on: trunk/extensions/UnitTest/tests/UnitTest/AllTests.php
___________________________________________________________________
Added: svn:eol-style
170 + native
Added: svn:mime-type
271 + text/plain
Added: svn:keywords
372 + Author Date HeadURL Header Id Revision
Index: trunk/extensions/UnitTest/tests/UnitTest/DebugTestCase.php
@@ -0,0 +1,192 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ *
 18+ * @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org>
 19+ */
 20+
 21+/**
 22+ * @see UnitTestTestCase
 23+ */
 24+require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'UnitTestTestCase.php';
 25+
 26+/**
 27+ * DebugTestCase
 28+ *
 29+ * Test the debug class
 30+ */
 31+class UnitTest_DebugTestCase extends UnitTestTestCase
 32+{
 33+
 34+ /**
 35+ * testDumpAnArrayForHtml
 36+ *
 37+ * @covers Debug::dump
 38+ */
 39+ public function testDumpAnArrayForHtml() {
 40+
 41+ global $wgCommandLineMode;
 42+
 43+ $wgCommandLineMode = false;
 44+
 45+ // Turn on output buffering
 46+ ob_start();
 47+
 48+ Debug::dump( $_SERVER, eval(DUMP) . "\$_SERVER" );
 49+
 50+ $buffer = ob_get_contents();
 51+
 52+ // Erase the buffer
 53+ ob_end_clean();
 54+
 55+ $expected = '<div style="clear: both"><hr />';
 56+
 57+ $this->assertStringStartsWith( $expected, $buffer );
 58+ }
 59+
 60+ /**
 61+ * testDumpAnArrayForCli
 62+ *
 63+ * @covers Debug::dump
 64+ */
 65+ public function testDumpAnArrayForCli() {
 66+
 67+ global $wgCommandLineMode;
 68+
 69+ $wgCommandLineMode = true;
 70+ // Turn on output buffering
 71+ ob_start();
 72+
 73+ Debug::dump( $_SERVER, eval(DUMP) . "\$_SERVER" );
 74+
 75+ $buffer = ob_get_contents();
 76+
 77+ // Erase the buffer
 78+ ob_end_clean();
 79+
 80+ $expected = '--------------------------------------------------------------------------------';
 81+
 82+ $this->assertStringStartsWith( $expected, $buffer );
 83+ }
 84+
 85+ /**
 86+ * testDumpAStringForHtml
 87+ *
 88+ * @covers Debug::dump
 89+ */
 90+ public function testDumpAStringForHtml() {
 91+
 92+ global $wgCommandLineMode;
 93+
 94+ $wgCommandLineMode = false;
 95+
 96+ // Turn on output buffering
 97+ ob_start();
 98+
 99+ Debug::dump( __CLASS__, eval(DUMP) . "__CLASS__" );
 100+
 101+ $buffer = ob_get_contents();
 102+
 103+ // Erase the buffer
 104+ ob_end_clean();
 105+
 106+ $expected = '<div style="clear: both"><hr />';
 107+
 108+ $this->assertStringStartsWith( $expected, $buffer );
 109+ }
 110+
 111+ /**
 112+ * testDumpAStringForCli
 113+ *
 114+ * @covers Debug::dump
 115+ */
 116+ public function testDumpAStringForCli() {
 117+
 118+ global $wgCommandLineMode;
 119+
 120+ $wgCommandLineMode = true;
 121+ // Turn on output buffering
 122+ ob_start();
 123+
 124+ Debug::dump( __CLASS__, eval(DUMP) . "__CLASS__" );
 125+
 126+ $buffer = ob_get_contents();
 127+
 128+ // Erase the buffer
 129+ ob_end_clean();
 130+
 131+ $expected = '--------------------------------------------------------------------------------';
 132+
 133+ $this->assertStringStartsWith( $expected, $buffer );
 134+ }
 135+
 136+ /**
 137+ * testDumpAStringForHtml
 138+ *
 139+ * @covers Debug::dump
 140+ * @covers Debug::puke
 141+ */
 142+ public function testPukeAStringForHtml() {
 143+
 144+ global $wgCommandLineMode;
 145+
 146+ $wgCommandLineMode = false;
 147+
 148+ // Turn on output buffering
 149+ ob_start();
 150+
 151+ Debug::puke( __CLASS__, eval(DUMP) . "__CLASS__", false );
 152+
 153+ $buffer = ob_get_contents();
 154+
 155+ // Erase the buffer
 156+ ob_end_clean();
 157+
 158+ $expected = '<div style="clear: both"><hr />';
 159+
 160+ $this->assertStringStartsWith( $expected, $buffer );
 161+
 162+ $this->assertContains( 'DebugTestCase->testPukeAStringForHtml()', $buffer );
 163+ }
 164+
 165+ /**
 166+ * testPukeAStringForCli
 167+ *
 168+ * @covers Debug::dump
 169+ * @covers Debug::puke
 170+ */
 171+ public function testPukeAStringForCli() {
 172+
 173+ global $wgCommandLineMode;
 174+
 175+ $wgCommandLineMode = true;
 176+ // Turn on output buffering
 177+ ob_start();
 178+
 179+ Debug::puke( __CLASS__, eval(DUMP) . "__CLASS__", false );
 180+
 181+ $buffer = ob_get_contents();
 182+
 183+ // Erase the buffer
 184+ ob_end_clean();
 185+
 186+
 187+ $expected = '--------------------------------------------------------------------------------';
 188+
 189+ $this->assertStringStartsWith( $expected, $buffer );
 190+
 191+ $this->assertContains( 'DebugTestCase->testPukeAStringForCli()', $buffer );
 192+ }
 193+}
Property changes on: trunk/extensions/UnitTest/tests/UnitTest/DebugTestCase.php
___________________________________________________________________
Added: svn:eol-style
1194 + native
Added: svn:mime-type
2195 + text/plain
Added: svn:keywords
3196 + Author Date HeadURL Header Id Revision
Index: trunk/extensions/UnitTest/tests/UnitTest/VerifySeleniumTestCase.php
@@ -0,0 +1,56 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ *
 18+ * @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org>
 19+ */
 20+
 21+/**
 22+ * @see UnitTestSeleniumTestCase
 23+ */
 24+require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'UnitTestSeleniumTestCase.php';
 25+
 26+/**
 27+ * UnitTest_VerifySeleniumTestCase
 28+ *
 29+ * @group UnitTest
 30+ */
 31+class UnitTest_VerifySeleniumTestCase extends UnitTestSeleniumTestCase
 32+{
 33+
 34+ /**
 35+ * Test a functioning title
 36+ */
 37+ public function testTitle()
 38+ {
 39+ $this->open( $this->getExtensionsBrowsersUrl() );
 40+
 41+ $this->browserScreenshot( __FUNCTION__ );
 42+
 43+ $this->assertNotTitle('Some very long title that is probably not the real title.');
 44+ }
 45+
 46+# /**
 47+# * Test a non functioning title
 48+# */
 49+# public function testTitleBad()
 50+# {
 51+# $this->open( $this->getExtensionsBrowsersUrl() );
 52+#
 53+# $this->browserScreenshot( __FUNCTION__ );
 54+#
 55+# $this->assertTitle('This is most likely not the real title of this page.');
 56+# }
 57+}
\ No newline at end of file
Property changes on: trunk/extensions/UnitTest/tests/UnitTest/VerifySeleniumTestCase.php
___________________________________________________________________
Added: svn:eol-style
158 + native
Added: svn:mime-type
259 + text/plain
Added: svn:keywords
360 + Author Date HeadURL Header Id Revision
Index: trunk/extensions/UnitTest/tests/UnitTest/TemplateTestCase.php
@@ -0,0 +1,66 @@
 2+<?php
 3+/**
 4+ * Wikimedia Foundation
 5+ *
 6+ * LICENSE
 7+ *
 8+ * This program is free software; you can redistribute it and/or modify
 9+ * it under the terms of the GNU General Public License as published by
 10+ * the Free Software Foundation; either version 2 of the License, or
 11+ * (at your option) any later version.
 12+ *
 13+ * This program is distributed in the hope that it will be useful,
 14+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 15+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 16+ * GNU General Public License for more details.
 17+ *
 18+ * @author Jeremy Postlethwaite <jpostlethwaite@wikimedia.org>
 19+ */
 20+
 21+/**
 22+ * @see UnitTestTestCase
 23+ */
 24+require_once dirname( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'UnitTestTestCase.php';
 25+
 26+/**
 27+ * UnitTestTemplateTestCase
 28+ *
 29+ * The purpose of this test suite is to verify that all of the necessary files
 30+ * exist in the template.
 31+ */
 32+class UnitTest_TemplateTestCase extends UnitTestTestCase
 33+{
 34+ /**
 35+ * testToolsHasFileAllTests
 36+ */
 37+ public function testToolsHasFileAllTests() {
 38+
 39+ // AllTests.php
 40+ $file = TESTS_UNITTEST_EXTENSION_ROOT . '/tools/tests-template/AllTests.php';
 41+ $this->assertFileExists( $file );
 42+
 43+ // TestConfiguration.php.dist
 44+ $file = TESTS_UNITTEST_EXTENSION_ROOT . '/tools/tests-template/TestConfiguration.php.dist';
 45+ $this->assertFileExists( $file );
 46+
 47+ // TestHelper.php
 48+ $file = TESTS_UNITTEST_EXTENSION_ROOT . '/tools/tests-template/TestHelper.php';
 49+ $this->assertFileExists( $file );
 50+
 51+ // phpunit.xml
 52+ $file = TESTS_UNITTEST_EXTENSION_ROOT . '/tools/tests-template/phpunit.xml';
 53+ $this->assertFileExists( $file );
 54+
 55+ // selenium.ini.dst
 56+ $file = TESTS_UNITTEST_EXTENSION_ROOT . '/tools/tests-template/selenium.ini.dst';
 57+ $this->assertFileExists( $file );
 58+
 59+ // unittest.conf.dist
 60+ $file = TESTS_UNITTEST_EXTENSION_ROOT . '/tools/tests-template/unittest.conf.dist';
 61+ $this->assertFileExists( $file );
 62+
 63+ // unittest.sh
 64+ $file = TESTS_UNITTEST_EXTENSION_ROOT . '/tools/tests-template/unittest.sh';
 65+ $this->assertFileExists( $file );
 66+ }
 67+}
Property changes on: trunk/extensions/UnitTest/tests/UnitTest/TemplateTestCase.php
___________________________________________________________________
Added: svn:eol-style
168 + native
Added: svn:mime-type
269 + text/plain
Added: svn:keywords
370 + Author Date HeadURL Header Id Revision
Property changes on: trunk/extensions/UnitTest/tests/logs/coverage/results
___________________________________________________________________
Added: svn:ignore
471 + *
Property changes on: trunk/extensions/UnitTest/tests/logs/coverage/html
___________________________________________________________________
Added: svn:ignore
572 + *
Property changes on: trunk/extensions/UnitTest/tests/logs/coverage/clover
___________________________________________________________________
Added: svn:ignore
673 + *

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r109762Adding UnitTest Extensionjpostlethwaite21:45, 22 January 2012

Status & tagging log