19 $this->tablesUsed = [
'change_tag',
'change_tag_def',
'updatelog' ];
36 'ct_tag' =>
'One Tag',
41 'ct_tag' =>
'Two Tags',
46 'ct_tag' =>
'Two Tags',
51 'ct_tag' =>
'Three Tags',
56 'ct_tag' =>
'Three Tags',
61 'ct_tag' =>
'Three Tags',
69 $this->maintenance->loadWithArgv( [
'--sleep',
'0' ] );
71 $this->maintenance->execute();
75 'ctd_name' =>
'One Tag',
79 'ctd_name' =>
'Two Tags',
83 'ctd_name' =>
'Three Tags',
90 [
'ctd_name',
'ctd_count' ],
93 [
'ORDER BY' =>
'ctd_count' ]
96 $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs,
false ) );
100 [
'change_tag',
'change_tag_def' ],
101 [
'ct_tag',
'ct_tag_id',
'ctd_count' ],
105 [
'change_tag_def' => [
'LEFT JOIN',
'ct_tag_id=ctd_id' ] ]
112 foreach ( $actualChangeTags
as $row ) {
113 $this->assertNotNull( $row->ct_tag_id );
114 $this->assertEquals( $row->ctd_count, $mapping[$row->ct_tag] );
120 $changeTagDefBadRows = [
122 'ctd_name' =>
'One Tag',
123 'ctd_user_defined' => 0,
127 'ctd_name' =>
'Two Tags',
128 'ctd_user_defined' => 0,
132 'ctd_name' =>
'Three Tags',
133 'ctd_user_defined' => 0,
147 foreach ( $mapping
as $tagName => $tagId ) {
150 [
'ct_tag_id' => $tagId ],
151 [
'ct_tag' => $tagName ]
155 $this->maintenance->loadWithArgv( [
'--sleep',
'0' ] );
157 $this->maintenance->execute();
159 $changeTagDefRows = [
161 'ctd_name' =>
'One Tag',
165 'ctd_name' =>
'Two Tags',
169 'ctd_name' =>
'Three Tags',
175 [
'change_tag_def' ],
176 [
'ctd_name',
'ctd_count' ],
179 [
'ORDER BY' =>
'ctd_count' ]
182 $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs,
false ) );
187 $changeTagDefBadRows = [
189 'ctd_name' =>
'One Tag',
190 'ctd_user_defined' => 0,
194 'ctd_name' =>
'Two Tags',
195 'ctd_user_defined' => 0,
199 'ctd_name' =>
'Three Tags',
200 'ctd_user_defined' => 0,
209 $this->maintenance->loadWithArgv( [
'--sleep',
'0' ] );
211 $this->maintenance->execute();
213 $changeTagDefRows = [
215 'ctd_name' =>
'One Tag',
219 'ctd_name' =>
'Two Tags',
223 'ctd_name' =>
'Three Tags',
229 [
'change_tag_def' ],
230 [
'ctd_name',
'ctd_count' ],
233 [
'ORDER BY' =>
'ctd_count' ]
236 $this->assertEquals( $changeTagDefRows, iterator_to_array( $actualChangeTagDefs,
false ) );
241 $this->maintenance->loadWithArgv( [
'--dry-run',
'--sleep',
'0' ] );
243 $this->maintenance->execute();
246 [
'change_tag_def' ],
247 [
'ctd_id',
'ctd_name' ]
250 $this->assertEquals( [], iterator_to_array( $actualChangeTagDefs,
false ) );
254 [
'ct_tag_id',
'ct_tag' ]
257 foreach ( $actualChangeTags
as $row ) {
258 $this->assertNull( $row->ct_tag_id );
259 $this->assertNotNull( $row->ct_tag );
265 $this->maintenance->loadWithArgv( [
'--dry-run',
'--sleep',
'0' ] );
267 $this->maintenance->execute();
270 [
'change_tag_def' ],
271 [
'ctd_id',
'ctd_name' ]
274 $this->assertEquals( [], iterator_to_array( $actualChangeTagDefs,
false ) );
278 [
'ct_tag_id',
'ct_tag' ]
281 foreach ( $actualChangeTags
as $row ) {
282 $this->assertNull( $row->ct_tag_id );
283 $this->assertNotNull( $row->ct_tag );