18 $this->tablesUsed = array_merge(
20 [
'change_tag',
'change_tag_def',
'logging' ]
25 $name =
'Help:' . ucfirst( __FUNCTION__ );
28 $this->
editPage( $name,
'Some text' );
36 $this->assertArrayHasKey(
'delete', $apiResult );
37 $this->assertArrayHasKey(
'title', $apiResult[
'delete'] );
38 $this->assertSame( $name, $apiResult[
'delete'][
'title'] );
39 $this->assertArrayHasKey(
'logid', $apiResult[
'delete'] );
41 $this->assertFalse( Title::newFromText( $name )->exists() );
47 $name =
'Help:' . ucfirst( __FUNCTION__ );
48 for ( $i = 1; $i <= 3; $i++ ) {
49 $this->
editPage( $name,
"Revision $i" );
57 $this->assertArrayHasKey(
'delete', $apiResult );
58 $this->assertArrayHasKey(
'title', $apiResult[
'delete'] );
59 $this->assertSame( $name, $apiResult[
'delete'][
'title'] );
60 $this->assertArrayHasKey(
'scheduled', $apiResult[
'delete'] );
61 $this->assertTrue( $apiResult[
'delete'][
'scheduled'] );
62 $this->assertArrayNotHasKey(
'logid', $apiResult[
'delete'] );
65 JobQueueGroup::destroySingletons();
70 $this->assertFalse( Title::newFromText( $name )->exists( Title::GAID_FOR_UPDATE ) );
74 $this->setExpectedException( ApiUsageException::class,
75 "The page you specified doesn't exist." );
79 'title' =>
'This page deliberately left nonexistent',
84 $this->setExpectedException( ApiUsageException::class,
85 'The action you have requested is limited to users in the group:' );
87 $name =
'Help:' . ucfirst( __FUNCTION__ );
90 $this->
editPage( $name,
'Some text' );
98 'token' => $user->getEditToken(),
99 ],
null,
null, $user );
101 $this->assertTrue( Title::newFromText( $name )->exists() );
107 $name =
'Help:' . ucfirst( __FUNCTION__ );
109 ChangeTags::defineTag(
'custom tag' );
111 $this->
editPage( $name,
'Some text' );
114 'action' =>
'delete',
116 'tags' =>
'custom tag',
119 $this->assertFalse( Title::newFromText( $name )->exists() );
122 $this->assertSame(
'custom tag', $dbw->selectField(
123 [
'change_tag',
'logging' ],
127 'log_title' => ucfirst( __FUNCTION__ ),
131 [
'change_tag' => [
'INNER JOIN',
'ct_log_id = log_id' ] ]
137 $name =
'Help:' . ucfirst( __FUNCTION__ );
139 ChangeTags::defineTag(
'custom tag' );
141 $this->
editPage( $name,
'Some text' );
144 'action' =>
'delete',
146 'tags' =>
'custom tag',
149 $this->assertFalse( Title::newFromText( $name )->exists() );
152 $this->assertSame(
'custom tag', $dbw->selectField(
153 [
'change_tag',
'logging',
'change_tag_def' ],
157 'log_title' => ucfirst( __FUNCTION__ ),
162 'change_tag' => [
'INNER JOIN',
'ct_log_id = log_id' ],
163 'change_tag_def' => [
'INNER JOIN',
'ctd_id = ct_tag_id' ]
169 $this->setExpectedException( ApiUsageException::class,
170 'You do not have permission to apply change tags along with your changes.' );
172 $name =
'Help:' . ucfirst( __FUNCTION__ );
174 ChangeTags::defineTag(
'custom tag' );
176 [
'user' => [
'applychangetags' =>
true ] ] );
178 $this->
editPage( $name,
'Some text' );
182 'action' =>
'delete',
184 'tags' =>
'custom tag',
187 $this->assertTrue( Title::newFromText( $name )->exists() );
192 $this->setExpectedException( ApiUsageException::class,
193 'Deletion aborted by hook. It gave no explanation.' );
195 $name =
'Help:' . ucfirst( __FUNCTION__ );
197 $this->
editPage( $name,
'Some text' );
208 $this->assertTrue( Title::newFromText( $name )->exists() );
213 $name =
'Help:' . ucfirst( __FUNCTION__ );
214 $user = self::$users[
'sysop']->getUser();
216 $this->
editPage( $name,
'Some text' );
217 $this->assertTrue( Title::newFromText( $name )->exists() );
218 $this->assertFalse( $user->isWatched( Title::newFromText( $name ) ) );
222 $this->assertFalse( Title::newFromText( $name )->exists() );
223 $this->assertTrue( $user->isWatched( Title::newFromText( $name ) ) );
227 $name =
'Help:' . ucfirst( __FUNCTION__ );
228 $user = self::$users[
'sysop']->getUser();
230 $this->
editPage( $name,
'Some text' );
231 $this->assertTrue( Title::newFromText( $name )->exists() );
232 $user->addWatch( Title::newFromText( $name ) );
233 $this->assertTrue( $user->isWatched( Title::newFromText( $name ) ) );
237 $this->assertFalse( Title::newFromText( $name )->exists() );
238 $this->assertFalse( $user->isWatched( Title::newFromText( $name ) ) );
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Tests for MediaWiki api.php?action=delete.
testDeleteAbortedByHook()
testDeleteWithoutTagPermission()
testDeletionWithoutPermission()
testDeleteWithTagNewBackend()
doApiRequestWithToken(array $params, array $session=null, User $user=null, $tokenType='auto')
Convenience function to access the token parameter of doApiRequest() more succinctly.
doApiRequest(array $params, array $session=null, $appendModule=false, User $user=null, $tokenType=null)
Does the API request and returns the result.
loadParamsAndArgs( $self=null, $opts=null, $args=null)
Process command line arguments $mOptions becomes an array with keys set to the option names $mArgs be...
Maintenance script that runs pending jobs.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
const MIGRATION_WRITE_BOTH