Fix ChangeTagsTest failing on Postgres
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Fri, 15 Mar 2019 09:10:33 +0000 (10:10 +0100)
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Fri, 15 Mar 2019 09:10:33 +0000 (10:10 +0100)
The order of elements returned by the SELECT is not guaranteed. But the
assertEquals() can't know this. It does not know how to identify the two
objects, other than by their array index.

Using assertArrayEquals() would fix this. But I honestly don't like this
helper method. It is expensive, for example. So I went for an ORDER BY.

An example for this failure can be seen here:
https://integration.wikimedia.org/ci/job/mediawiki-quibble-vendor-postgres-php70-docker/2484/console

Change-Id: I284d13d21b9bc34270307e78430180d94fc6665e

tests/phpunit/includes/changetags/ChangeTagsTest.php

index 0e209d5..1405680 100644 (file)
@@ -592,7 +592,13 @@ class ChangeTagsTest extends MediaWikiTestCase {
                                'ctd_user_defined' => 1
                        ],
                ];
                                'ctd_user_defined' => 1
                        ],
                ];
-               $res = $dbr->select( 'change_tag_def', [ 'ctd_name', 'ctd_user_defined' ], '' );
+               $res = $dbr->select(
+                       'change_tag_def',
+                       [ 'ctd_name', 'ctd_user_defined' ],
+                       '',
+                       __METHOD__,
+                       [ 'ORDER BY' => 'ctd_name' ]
+               );
                $this->assertEquals( $expected, iterator_to_array( $res, false ) );
        }
 }
                $this->assertEquals( $expected, iterator_to_array( $res, false ) );
        }
 }