X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fchangetags%2FChangeTagsTest.php;h=1405680b6fbc151ec4d1246a108245614c78707d;hb=204d0df4d2bb8139109253f3da1df42cd455850c;hp=f1ee99f6d4e71cbc51f2625da1ae9e3e19200d94;hpb=0770f85a0a293e6c7af6f1d3d3a1dbd2d13c1e09;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/changetags/ChangeTagsTest.php b/tests/phpunit/includes/changetags/ChangeTagsTest.php index f1ee99f6d4..1405680b6f 100644 --- a/tests/phpunit/includes/changetags/ChangeTagsTest.php +++ b/tests/phpunit/includes/changetags/ChangeTagsTest.php @@ -62,7 +62,7 @@ class ChangeTagsTest extends MediaWikiTestCase { // HACK if we call $dbr->buildGroupConcatField() now, it will return the wrong table names // We have to have the test runner call it instead $baseConcats = [ ',', [ 'change_tag', 'change_tag_def' ], 'ctd_name' ]; - $joinConds = [ 'change_tag_def' => [ 'INNER JOIN', 'ct_tag_id=ctd_id' ] ]; + $joinConds = [ 'change_tag_def' => [ 'JOIN', 'ct_tag_id=ctd_id' ] ]; $groupConcats = [ 'recentchanges' => array_merge( $baseConcats, [ 'ct_rc_id=rc_id', $joinConds ] ), 'logging' => array_merge( $baseConcats, [ 'ct_log_id=log_id', $joinConds ] ), @@ -121,7 +121,7 @@ class ChangeTagsTest extends MediaWikiTestCase { 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ], 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], - 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], + 'join_conds' => [ 'change_tag' => [ 'JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'ORDER BY' => 'rc_timestamp DESC' ], ] ], @@ -139,7 +139,7 @@ class ChangeTagsTest extends MediaWikiTestCase { 'tables' => [ 'logging', 'change_tag' ], 'fields' => [ 'log_id', 'ts_tags' => $groupConcats['logging'] ], 'conds' => [ "log_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], - 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_log_id=log_id' ] ], + 'join_conds' => [ 'change_tag' => [ 'JOIN', 'ct_log_id=log_id' ] ], 'options' => [ 'ORDER BY log_timestamp DESC' ], ] ], @@ -157,7 +157,7 @@ class ChangeTagsTest extends MediaWikiTestCase { 'tables' => [ 'revision', 'change_tag' ], 'fields' => [ 'rev_id', 'rev_timestamp', 'ts_tags' => $groupConcats['revision'] ], 'conds' => [ "rev_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], - 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rev_id=rev_id' ] ], + 'join_conds' => [ 'change_tag' => [ 'JOIN', 'ct_rev_id=rev_id' ] ], 'options' => [ 'ORDER BY' => 'rev_timestamp DESC' ], ] ], @@ -175,7 +175,7 @@ class ChangeTagsTest extends MediaWikiTestCase { 'tables' => [ 'archive', 'change_tag' ], 'fields' => [ 'ar_id', 'ar_timestamp', 'ts_tags' => $groupConcats['archive'] ], 'conds' => [ "ar_timestamp > '20170714183203'", 'ct_tag_id' => [ 1 ] ], - 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rev_id=ar_rev_id' ] ], + 'join_conds' => [ 'change_tag' => [ 'JOIN', 'ct_rev_id=ar_rev_id' ] ], 'options' => [ 'ORDER BY' => 'ar_timestamp DESC' ], ] ], @@ -223,7 +223,7 @@ class ChangeTagsTest extends MediaWikiTestCase { 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ], 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1, 2 ] ], - 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], + 'join_conds' => [ 'change_tag' => [ 'JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'ORDER BY' => 'rc_timestamp DESC', 'DISTINCT' ], ] ], @@ -241,7 +241,7 @@ class ChangeTagsTest extends MediaWikiTestCase { 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'rc_timestamp', 'ts_tags' => $groupConcats['recentchanges'] ], 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1, 2 ] ], - 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], + 'join_conds' => [ 'change_tag' => [ 'JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'DISTINCT', 'ORDER BY' => 'rc_timestamp DESC' ], ] ], @@ -259,7 +259,7 @@ class ChangeTagsTest extends MediaWikiTestCase { 'tables' => [ 'recentchanges', 'change_tag' ], 'fields' => [ 'rc_id', 'ts_tags' => $groupConcats['recentchanges'] ], 'conds' => [ "rc_timestamp > '20170714183203'", 'ct_tag_id' => [ 1, 2 ] ], - 'join_conds' => [ 'change_tag' => [ 'INNER JOIN', 'ct_rc_id=rc_id' ] ], + 'join_conds' => [ 'change_tag' => [ 'JOIN', 'ct_rc_id=rc_id' ] ], 'options' => [ 'ORDER BY rc_timestamp DESC', 'DISTINCT' ], ] ], @@ -338,7 +338,8 @@ class ChangeTagsTest extends MediaWikiTestCase { $dbw->delete( 'change_tag_def', '*' ); $rcId = 123; - ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId ); + $revId = 341; + ChangeTags::updateTags( [ 'tag1', 'tag2' ], [], $rcId, $revId ); $dbr = wfGetDB( DB_REPLICA ); @@ -360,20 +361,22 @@ class ChangeTagsTest extends MediaWikiTestCase { $expected2 = [ (object)[ 'ct_tag_id' => 1, - 'ct_rc_id' => 123 + 'ct_rc_id' => 123, + 'ct_rev_id' => 341 ], (object)[ 'ct_tag_id' => 2, - 'ct_rc_id' => 123 + 'ct_rc_id' => 123, + 'ct_rev_id' => 341 ], ]; - $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' ); + $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id', 'ct_rev_id' ], '' ); $this->assertEquals( $expected2, iterator_to_array( $res2, false ) ); $rcId = 124; - ChangeTags::updateTags( [ 'tag1' ], [], $rcId ); - - ChangeTags::updateTags( [ 'tag3' ], [], $rcId ); + $revId = 342; + ChangeTags::updateTags( [ 'tag1' ], [], $rcId, $revId ); + ChangeTags::updateTags( [ 'tag3' ], [], $rcId, $revId ); $dbr = wfGetDB( DB_REPLICA ); @@ -400,22 +403,26 @@ class ChangeTagsTest extends MediaWikiTestCase { $expected2 = [ (object)[ 'ct_tag_id' => 1, - 'ct_rc_id' => 123 + 'ct_rc_id' => 123, + 'ct_rev_id' => 341 ], (object)[ - 'ct_tag_id' => 2, - 'ct_rc_id' => 123 + 'ct_tag_id' => 1, + 'ct_rc_id' => 124, + 'ct_rev_id' => 342 ], (object)[ - 'ct_tag_id' => 1, - 'ct_rc_id' => 124 + 'ct_tag_id' => 2, + 'ct_rc_id' => 123, + 'ct_rev_id' => 341 ], (object)[ 'ct_tag_id' => 3, - 'ct_rc_id' => 124 + 'ct_rc_id' => 124, + 'ct_rev_id' => 342 ], ]; - $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id' ], '' ); + $res2 = $dbr->select( 'change_tag', [ 'ct_tag_id', 'ct_rc_id', 'ct_rev_id' ], '' ); $this->assertEquals( $expected2, iterator_to_array( $res2, false ) ); } @@ -585,7 +592,13 @@ class ChangeTagsTest extends MediaWikiTestCase { '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 ) ); } }