r85618 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85617‎ | r85618 | r85619 >
Date:14:54, 7 April 2011
Author:pcopp
Status:ok
Tags:
Comment:
Various fixes for PHPUnit tests:

* Block.php: Set mExpiry to the value we store in the database, so that Block::equals() returns true. Fixes BlockTest::testInitializerFunctionsReturnCorrectBlock.
* In Title::checkUserBlock(): Convert message parameters to plain strings to make strict comparisons work. Fixes TitlePermissionTest::testUserBlock().
* ApiBlock.php: Follow-Up r85166, add 'Confirm' parameter to data array. Fixes ApiBlockTest::testMakeNormalBlock().
* ApiQueryTest.php: Use $wgMetaNamespace instead of $wgSitename to account for customizations.
* RandomImageGenerator.php: Use default value for constructor param to prevent fatals.
* ApiTestCaseUpload.php:
** Fix undefined variable $fileName.
** Remove stray ini_set statements, they don't belong there. Especially ini_set( 'error_reporting', 1 ) will effectively disable all reporting, which makes errors hard to track.
* ArticleTablesTest.php: Put testbug14404() in group Broken, as the fix for the bug has been reverted in r83868.
Modified paths:
  • /trunk/phase3/includes/Block.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/includes/api/ApiBlock.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/api/ApiTestCaseUpload.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/api/RandomImageGenerator.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/ArticleTablesTest.php
@@ -18,7 +18,10 @@
1919 $wgContLang = new StubContLang;
2020 $wgLang = new StubUserLang;
2121 }
22 -
 22+
 23+ /**
 24+ * @group Broken
 25+ */
2326 function testbug14404() {
2427 global $wgUser, $wgContLang, $wgLanguageCode, $wgLang;
2528
Index: trunk/phase3/tests/phpunit/includes/TitlePermissionTest.php
@@ -625,7 +625,7 @@
626626 $this->user->mBlock->mTimestamp = 0;
627627 $this->assertEquals( array( array( 'autoblockedtext',
628628 '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
629 - 'Useruser', 0, 'infinite', '127.0.8.1',
 629+ 'Useruser', null, 'infinite', '127.0.8.1',
630630 $wgLang->timeanddate( wfTimestamp( TS_MW, $prev ), true ) ) ),
631631 $this->title->getUserPermissionsErrors( 'move-target',
632632 $this->user ) );
@@ -639,7 +639,7 @@
640640 $this->user->mBlock = new Block( '127.0.8.1', 2, 1, 'no reason given', $now, 0, 10 );
641641 $this->assertEquals( array( array( 'blockedtext',
642642 '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
643 - 'Useruser', 0, '23:00, 31 December 1969', '127.0.8.1',
 643+ 'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
644644 $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ) ),
645645 $this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
646646
Index: trunk/phase3/tests/phpunit/includes/api/ApiTestCaseUpload.php
@@ -18,10 +18,6 @@
1919 $wgEnableAPI = true;
2020 wfSetupSession();
2121
22 - ini_set( 'log_errors', 1 );
23 - ini_set( 'error_reporting', 1 );
24 - ini_set( 'display_errors', 1 );
25 -
2622 $this->clearFakeUploads();
2723 }
2824
@@ -51,7 +47,7 @@
5248 $article->doDeleteArticle( "removing for test" );
5349
5450 // see if it now doesn't exist; reload
55 - $title = Title::newFromText( $fileName, NS_FILE );
 51+ $title = Title::newFromText( $title->getText(), NS_FILE );
5652 }
5753 return ! ( $title && $title instanceof Title && $title->exists() );
5854 }
Index: trunk/phase3/tests/phpunit/includes/api/RandomImageGenerator.php
@@ -34,7 +34,7 @@
3535 private $circlesToDraw = 5;
3636 private $imageWriteMethod;
3737
38 - public function __construct( $options ) {
 38+ public function __construct( $options = array() ) {
3939 global $wgUseImageMagick, $wgImageMagickConvertCommand;
4040 foreach ( array( 'dictionaryFile', 'minWidth', 'minHeight', 'maxHeight', 'circlesToDraw' ) as $property ) {
4141 if ( isset( $options[$property] ) ) {
Index: trunk/phase3/tests/phpunit/includes/api/ApiQueryTest.php
@@ -14,7 +14,7 @@
1515
1616 function testTitlesGetNormalized() {
1717
18 - global $wgSitename;
 18+ global $wgMetaNamespace;
1919
2020 $data = $this->doApiRequest( array(
2121 'action' => 'query',
@@ -27,7 +27,7 @@
2828 $this->assertEquals(
2929 array(
3030 'from' => 'Project:articleA',
31 - 'to' => $wgSitename . ':ArticleA'
 31+ 'to' => $wgMetaNamespace . ':ArticleA'
3232 ),
3333 $data[0]['query']['normalized'][0]
3434 );
Index: trunk/phase3/includes/api/ApiBlock.php
@@ -90,6 +90,7 @@
9191 'DisableUTEdit' => $params['allowusertalk'],
9292 'AlreadyBlocked' => $params['reblock'],
9393 'Watch' => $params['watchuser'],
 94+ 'Confirm' => true,
9495 );
9596
9697 $retval = SpecialBlock::processForm( $data );
Index: trunk/phase3/includes/Title.php
@@ -1563,12 +1563,12 @@
15641564 $blockExpiry = $user->mBlock->mExpiry;
15651565 $blockTimestamp = $wgLang->timeanddate( wfTimestamp( TS_MW, $user->mBlock->mTimestamp ), true );
15661566 if ( $blockExpiry == 'infinity' ) {
1567 - $blockExpiry = wfMessage( 'infiniteblock' );
 1567+ $blockExpiry = wfMessage( 'infiniteblock' )->text();
15681568 } else {
15691569 $blockExpiry = $wgLang->timeanddate( wfTimestamp( TS_MW, $blockExpiry ), true );
15701570 }
15711571
1572 - $intended = $user->mBlock->getTarget();
 1572+ $intended = strval( $user->mBlock->getTarget() );
15731573
15741574 $errors[] = array( ( $block->mAuto ? 'autoblockedtext' : 'blockedtext' ), $link, $reason, $ip, $name,
15751575 $blockid, $blockExpiry, $intended, $blockTimestamp );
Index: trunk/phase3/includes/Block.php
@@ -444,6 +444,7 @@
445445 if( !$db ){
446446 $db = wfGetDB( DB_SLAVE );
447447 }
 448+ $this->mExpiry = $db->encodeExpiry( $this->mExpiry );
448449
449450 $a = array(
450451 'ipb_address' => (string)$this->target,
@@ -456,7 +457,7 @@
457458 'ipb_anon_only' => !$this->isHardblock(),
458459 'ipb_create_account' => $this->prevents( 'createaccount' ),
459460 'ipb_enable_autoblock' => $this->isAutoblocking(),
460 - 'ipb_expiry' => $db->encodeExpiry( $this->mExpiry ),
 461+ 'ipb_expiry' => $this->mExpiry,
461462 'ipb_range_start' => $this->getRangeStart(),
462463 'ipb_range_end' => $this->getRangeEnd(),
463464 'ipb_deleted' => intval( $this->mHideName ), // typecast required for SQLite

Follow-up revisions

RevisionCommit summaryAuthorDate
r85798Follow-Up r85618:...pcopp16:41, 11 April 2011
r89706Reinstate r79122 (fix for bug 14404), reverting r83868. The real bug seem to ...platonides22:28, 7 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r83868Revert r79122, causes bug 27891 (old version seen immediately after edit).tstarling04:26, 14 March 2011
r85166Follow-up r85025: fix the you're-trying-to-block-yourself-you-twit warning, a...happy-melon23:13, 1 April 2011

Status & tagging log