jenkins-bot has submitted this change and it was merged.
Change subject: Special:RC tests: ignore order when asserting conditions
......................................................................
Special:RC tests: ignore order when asserting conditions
Normalize condition object to ignore order and ignore the
following equivalent formats:
$conds['column'] = 'value';
$conds[] = "column = 'value'";
This makes the tests more resilient to minor refactoring
that doesn't affect functionality.
Change-Id: I440f230c81182694a952de801cb37b9ddbad5599
---
M tests/phpunit/includes/specials/SpecialRecentchangesTest.php
1 file changed, 20 insertions(+), 10 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
index c51217c..6fb0d23 100644
--- a/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
+++ b/tests/phpunit/includes/specials/SpecialRecentchangesTest.php
@@ -48,9 +48,19 @@
);
$this->assertEquals(
- $expected,
- $queryConditions,
+ self::normalizeCondition( $expected ),
+ self::normalizeCondition( $queryConditions ),
$message
+ );
+ }
+
+ private static function normalizeCondition( $conds ) {
+ return array_map(
+ function ( $k, $v ) {
+ return is_numeric( $k ) ? $v : "$k = $v";
+ },
+ array_keys( $conds ),
+ $conds
);
}
@@ -63,8 +73,8 @@
$this->assertConditions(
[ # expected
'rc_bot' => 0,
- 0 => "rc_type != '6'",
- 1 => "rc_namespace = '0'",
+ "rc_type != '6'",
+ "rc_namespace = '0'",
],
[
'namespace' => NS_MAIN,
@@ -77,8 +87,8 @@
$this->assertConditions(
[ # expected
'rc_bot' => 0,
- 0 => "rc_type != '6'",
- 1 => sprintf( "rc_namespace != '%s'", NS_MAIN ),
+ "rc_type != '6'",
+ "rc_namespace != '0'",
],
[
'namespace' => NS_MAIN,
@@ -96,8 +106,8 @@
$this->assertConditions(
[ # expected
'rc_bot' => 0,
- 0 => "rc_type != '6'",
- 1 => sprintf( "(rc_namespace = '%s' OR
rc_namespace = '%s')", $ns1, $ns2 ),
+ "rc_type != '6'",
+ "(rc_namespace = '$ns1' OR rc_namespace =
'$ns2')",
],
[
'namespace' => $ns1,
@@ -115,8 +125,8 @@
$this->assertConditions(
[ # expected
'rc_bot' => 0,
- 0 => "rc_type != '6'",
- 1 => sprintf( "(rc_namespace != '%s' AND
rc_namespace != '%s')", $ns1, $ns2 ),
+ "rc_type != '6'",
+ "(rc_namespace != '$ns1' AND rc_namespace !=
'$ns2')",
],
[
'namespace' => $ns1,
--
To view, visit https://gerrit.wikimedia.org/r/321477
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I440f230c81182694a952de801cb37b9ddbad5599
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sbisson <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits