From: Jack Phoenix Date: Fri, 30 Apr 2010 22:21:36 +0000 (+0000) Subject: more follow-up to r65715: coding style tweaks, etc. X-Git-Tag: 1.31.0-rc.0~36973 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=373ae16b857af3f8b7110598aaa26ee527398d00;p=lhc%2Fweb%2Fwiklou.git more follow-up to r65715: coding style tweaks, etc. --- diff --git a/maintenance/tests/RunSeleniumTests.php b/maintenance/tests/RunSeleniumTests.php index bae7234c45..5c6478f585 100644 --- a/maintenance/tests/RunSeleniumTests.php +++ b/maintenance/tests/RunSeleniumTests.php @@ -1,49 +1,50 @@ addListener(new SeleniumTestListener($logger)); +$result->addListener( new SeleniumTestListener( $logger ) ); $wgSeleniumTestSuites = array(); @@ -82,12 +87,11 @@ $wgSeleniumTestSuites = array(); #include_once ''; // Here, you can override standard setting -if (file_exists('LocalSeleniumSettings.php')) -{ +if ( file_exists( 'LocalSeleniumSettings.php' ) ) { include_once 'LocalSeleniumSettings.php'; } // run tests -foreach ($wgSeleniumTestSuites as $suite) - $suite->run($result); -?> +foreach ( $wgSeleniumTestSuites as $suite ) { + $suite->run( $result ); +} \ No newline at end of file diff --git a/maintenance/tests/selenium/Selenium.php b/maintenance/tests/selenium/Selenium.php index a1518ff1bb..a04001066d 100644 --- a/maintenance/tests/selenium/Selenium.php +++ b/maintenance/tests/selenium/Selenium.php @@ -4,53 +4,47 @@ * This is implemented as a singleton. */ -if (!defined('MEDIAWIKI') || !defined('SELENIUMTEST')) { +if ( !defined( 'MEDIAWIKI' ) || !defined( 'SELENIUMTEST' ) ) { echo "This script cannot be run standalone"; - exit(1); + exit( 1 ); } -class Selenium extends Testing_Selenium -{ +class Selenium extends Testing_Selenium { protected static $_instance = null; public $isStarted = false; - public static function getInstance() - { + + public static function getInstance() { global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost, $wgSeleniumTestsUseBrowser; - if (null === self::$_instance) - { - self::$_instance = new self($wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], $wgSeleniumTestsSeleniumHost); + if ( null === self::$_instance ) { + self::$_instance = new self( $wgSeleniumTestsBrowsers[$wgSeleniumTestsUseBrowser], $wgSeleniumTestsSeleniumHost ); } return self::$_instance; } - public function start() - { + public function start() { global $wgSeleniumTestsBrowsers, $wgSeleniumTestsSeleniumHost; parent::start(); $this->isStarted = true; } - public function stop() - { + public function stop() { parent::stop(); $this->isStarted = false; } - public function login() - { + public function login() { global $wgSeleniumTestsWikiUser, $wgSeleniumTestsWikiPassword, $wgSeleniumTestsWikiUrl; - $this->open($wgSeleniumTestsWikiUrl.'/index.php?title=Special:Userlogin'); - $this->type("wpName1", $wgSeleniumTestsWikiUser); - $this->type("wpPassword1", $wgSeleniumTestsWikiPassword); - $this->click("//input[@id='wpLoginAttempt']"); - $value = $this->doCommand('assertTitle', array('Anmeldung erfolgreich*')); + $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=Special:Userlogin' ); + $this->type( 'wpName1', $wgSeleniumTestsWikiUser ); + $this->type( 'wpPassword1', $wgSeleniumTestsWikiPassword ); + $this->click( "//input[@id='wpLoginAttempt']" ); + $value = $this->doCommand( 'assertTitle', array( 'Anmeldung erfolgreich*' ) ); } - public function loadPage($title, $action) - { + public function loadPage( $title, $action ) { global $wgSeleniumTestsWikiUrl; - $this->open($wgSeleniumTestsWikiUrl.'/index.php?title='.$title.'&action='.$action); + $this->open( $wgSeleniumTestsWikiUrl . '/index.php?title=' . $title . '&action=' . $action ); } // Prevent external cloning diff --git a/maintenance/tests/selenium/SeleniumTestCase.php b/maintenance/tests/selenium/SeleniumTestCase.php index 86c2f0dd55..6f0a4a0843 100644 --- a/maintenance/tests/selenium/SeleniumTestCase.php +++ b/maintenance/tests/selenium/SeleniumTestCase.php @@ -1,43 +1,34 @@ selenium = Selenium::getInstance(); - //print_r($this->suite); } - public function tearDown() - { + public function tearDown() { } - public function __call($method, $args) - { - return call_user_func_array (array($this->selenium, $method), $args); + public function __call( $method, $args ) { + return call_user_func_array( array( $this->selenium, $method ), $args ); } - public function assertSeleniumAttributeEquals($attribute, $value) - { - $attr = $this->getAttribute($attribute); - $this->assertEquals($attr, $value); + public function assertSeleniumAttributeEquals( $attribute, $value ) { + $attr = $this->getAttribute( $attribute ); + $this->assertEquals( $attr, $value ); } - public function assertSeleniumHTMLContains($element, $text) - { - $innerHTML = $this->getText($element); - //or assertContains - $this->assertRegExp("/$text/", $innerHTML ); + public function assertSeleniumHTMLContains( $element, $text ) { + $innerHTML = $this->getText( $element ); + // or assertContains + $this->assertRegExp( "/$text/", $innerHTML ); } -} - -?> +} \ No newline at end of file diff --git a/maintenance/tests/selenium/SeleniumTestConsoleLogger.php b/maintenance/tests/selenium/SeleniumTestConsoleLogger.php index b554796759..8c14210988 100644 --- a/maintenance/tests/selenium/SeleniumTestConsoleLogger.php +++ b/maintenance/tests/selenium/SeleniumTestConsoleLogger.php @@ -1,28 +1,28 @@ '; - $out .= htmlentities($message); - //if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= ''; - if ($mode != MW_TESTLOGGER_CONTINUE_LINE) $out .= "\n"; + public function write( $message, $mode = false ) { + $out = ''; + //if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= ''; + $out .= htmlentities( $message ); + //if ( $mode == MW_TESTLOGGER_RESULT_OK ) $out .= ''; + if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) { + $out .= "\n"; + } echo $out; } diff --git a/maintenance/tests/selenium/SeleniumTestHTMLLogger.php b/maintenance/tests/selenium/SeleniumTestHTMLLogger.php index 354e58614a..084a04b599 100644 --- a/maintenance/tests/selenium/SeleniumTestHTMLLogger.php +++ b/maintenance/tests/selenium/SeleniumTestHTMLLogger.php @@ -1,42 +1,45 @@ pre { - overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */ - white-space: pre-wrap; /* css-3 */ - white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - /* width: 99%; */ - word-wrap: break-word; /* Internet Explorer 5.5+ */ + overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */ + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + /* width: 99%; */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ } '; - - } - public function write($message, $mode = false) - { - $out .= ''; - if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= ''; - $out .= htmlentities($message); - if ($mode == MW_TESTLOGGER_RESULT_OK) $out .= ''; - if ($mode != MW_TESTLOGGER_CONTINUE_LINE) $out .= '
'; + public function write( $message, $mode = false ) { + $out = ''; + if ( $mode == MW_TESTLOGGER_RESULT_OK ) { + $out .= ''; + } + $out .= htmlentities( $message ); + if ( $mode == MW_TESTLOGGER_RESULT_OK ) { + $out .= ''; + } + if ( $mode != MW_TESTLOGGER_CONTINUE_LINE ) { + $out .= '
'; + } echo $out; } diff --git a/maintenance/tests/selenium/SeleniumTestListener.php b/maintenance/tests/selenium/SeleniumTestListener.php index 266eb3b90e..2dfb5649ad 100644 --- a/maintenance/tests/selenium/SeleniumTestListener.php +++ b/maintenance/tests/selenium/SeleniumTestListener.php @@ -1,74 +1,69 @@ logger = $loggerInstance; } - public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) - { - $this->logger->write("Error: ".$e->getMessage()); + public function addError( PHPUnit_Framework_Test $test, Exception $e, $time ) { + $this->logger->write( 'Error: ' . $e->getMessage() ); $this->tests_failed++; } - public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time) + public function addFailure( PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time ) { - $this->logger->write("Failed: ".$e->getMessage()); + $this->logger->write( 'Failed: ' . $e->getMessage() ); $this->tests_failed++; - } - public function addIncompleteTest(PHPUnit_Framework_Test $test, Exception $e, $time) + public function addIncompleteTest( PHPUnit_Framework_Test $test, Exception $e, $time ) { - $this->logger->write("Incomplete."); + $this->logger->write( 'Incomplete.' ); $this->tests_failed++; } - public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) + public function addSkippedTest( PHPUnit_Framework_Test $test, Exception $e, $time ) { - $this->logger->write("Skipped."); + $this->logger->write( 'Skipped.' ); $this->tests_failed++; } - public function startTest(PHPUnit_Framework_Test $test) - { - $this->logger->write("Testing ".$test->getName()." ... ", MW_TESTLOGGER_CONTINUE_LINE); + public function startTest( PHPUnit_Framework_Test $test ) { + $this->logger->write( + 'Testing ' . $test->getName() . ' ... ', + MW_TESTLOGGER_CONTINUE_LINE + ); } - public function endTest(PHPUnit_Framework_Test $test, $time) - { - if (!$test->hasFailed()) - { - $this->logger->write("OK", MW_TESTLOGGER_RESULT_OK); + public function endTest( PHPUnit_Framework_Test $test, $time ) { + if ( !$test->hasFailed() ) { + $this->logger->write( 'OK', MW_TESTLOGGER_RESULT_OK ); $this->tests_ok++; } } - public function startTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->logger->write("Testsuite ".$suite->getName()." started."); + public function startTestSuite( PHPUnit_Framework_TestSuite $suite ) { + $this->logger->write( 'Testsuite ' . $suite->getName() . ' started.' ); $this->tests_ok = 0; } - public function endTestSuite(PHPUnit_Framework_TestSuite $suite) - { - $this->logger->write("Testsuite ".$suite->getName()." ended. OK: ".$this->tests_ok." Failed: ".$this->tests_failed); - + public function endTestSuite( PHPUnit_Framework_TestSuite $suite ) { + $this->logger->write( + 'Testsuite ' . $suite->getName() . ' ended. OK: ' . + $this->tests_ok . ' Failed: ' . $this->tests_failed + ); } - public function statusMessage($message) - { - $this->logger->write($message); + public function statusMessage( $message ) { + $this->logger->write( $message ); } } diff --git a/maintenance/tests/selenium/SeleniumTestSuite.php b/maintenance/tests/selenium/SeleniumTestSuite.php index 112db745d0..a248ad694f 100644 --- a/maintenance/tests/selenium/SeleniumTestSuite.php +++ b/maintenance/tests/selenium/SeleniumTestSuite.php @@ -1,40 +1,34 @@ selenium = Selenium::getInstance(); $this->selenium->start(); $this->login(); - //$this->loadPage('Testpage', 'edit'); + //$this->loadPage( 'Testpage', 'edit' ); } - public function tearDown() - { + public function tearDown() { $this->selenium->stop(); } - public function login() - { + public function login() { $this->selenium->login(); } - public function loadPage($title, $action) - { - $this->selenium->loadPage($title, $action); + public function loadPage( $title, $action ) { + $this->selenium->loadPage( $title, $action ); } }