r89400 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89399‎ | r89400 | r89401 >
Date:06:22, 3 June 2011
Author:demon
Status:reverted (Comments)
Tags:
Comment:
Fix some of the weird freaky interaction between ApiBlockTest and BlockTest.
* By using the same summary for both, we allow both sets of tests to pass with --filter Block
* Just testing includes/BlockTest.php still passes
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/BlockTest.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/BlockTest.php
@@ -2,9 +2,10 @@
33
44 /**
55 * @group Database
6 - * @group Broken
76 */
8 -class BlockTest extends MediaWikiLangTestCase {
 7+class BlockTest extends MediaWikiTestCase {
 8+
 9+ const REASON = "Some reason";
910
1011 private $block, $madeAt;
1112
@@ -29,7 +30,7 @@
3031 }
3132
3233 $this->block = new Block( 'UTBlockee', 1, 0,
33 - 'Parce que'
 34+ self::REASON
3435 );
3536 $this->madeAt = wfTimestamp( TS_MW );
3637
@@ -55,7 +56,7 @@
5657 // $this->dumpBlocks();
5758
5859 $this->assertTrue( $this->block->equals( Block::newFromTarget('UTBlockee') ), "newFromTarget() returns the same block as the one that was made");
59 -
 60+
6061 $this->assertTrue( $this->block->equals( Block::newFromID( $this->blockId ) ), "newFromID() returns the same block as the one that was made");
6162
6263 }
Index: trunk/phase3/tests/phpunit/includes/api/ApiBlockTest.php
@@ -49,7 +49,7 @@
5050 $data = $this->doApiRequest( array(
5151 'action' => 'block',
5252 'user' => 'UTBlockee',
53 - 'reason' => 'Some reason',
 53+ 'reason' => BlockTest::REASON,
5454 'token' => $pageinfo['blocktoken'] ), $data );
5555
5656 $block = Block::newFromTarget('UTBlockee');

Follow-up revisions

RevisionCommit summaryAuthorDate
r94061Mostly revert r89400: not needed since Brion fixed the tests in other waysdemon16:08, 8 August 2011

Comments

#Comment by 😂 (talk | contribs)   06:24, 3 June 2011

Truncated message summary, last bit was: "Still have a failure for the 2nd assertion in testInitializerFunctionsReturnCorrectBlock(), narrowed it down to $dbw->nextSequenceValue( 'ipblocks_ipb_id_seq' ) returning null in Block::insert() (also, Block should set $mId after it's insert()ed)"

#Comment by Catrope (talk | contribs)   09:24, 3 June 2011

nextSequenceValue() always returns null in MySQL. This is on purpose. You can only really get the ID after the insertion with insertId() or something.

#Comment by 😂 (talk | contribs)   16:01, 3 June 2011

Yeah, there's something weird going on in Block that I'm just not getting. nextSequenceValue() is obviously wrong here. Tried with insertId(), but something's not right (insertId() *does* return int(1) which is a step in the right direction....)

#Comment by Hashar (talk | contribs)   07:47, 3 June 2011

Why do you need the same reason anyway? The block made by ApiBlockTest and the one by BlockTest are, to me, different successive blocks of the same user ( UTBlockee ).

#Comment by 😂 (talk | contribs)   08:03, 3 June 2011

They should be, but they aren't for some reason. I suspect it's ApiBlockTest's fault. When you run the two tests together --filter Block, you'll see the failures I'm mentioning.

Status & tagging log