16 $name =
'Help:' . ucfirst( __FUNCTION__ );
19 $this->
editPage( $name,
'Some text' );
27 $this->assertArrayHasKey(
'delete', $apiResult );
28 $this->assertArrayHasKey(
'title', $apiResult[
'delete'] );
29 $this->assertSame( $name, $apiResult[
'delete'][
'title'] );
30 $this->assertArrayHasKey(
'logid', $apiResult[
'delete'] );
32 $this->assertFalse( Title::newFromText( $name )->exists() );
36 $this->setExpectedException( ApiUsageException::class,
37 "The page you specified doesn't exist." );
41 'title' =>
'This page deliberately left nonexistent',
46 $this->setExpectedException( ApiUsageException::class,
47 'The action you have requested is limited to users in the group:' );
49 $name =
'Help:' . ucfirst( __FUNCTION__ );
52 $this->
editPage( $name,
'Some text' );
60 'token' => $user->getEditToken(),
61 ],
null,
null, $user );
63 $this->assertTrue( Title::newFromText( $name )->exists() );
68 $name =
'Help:' . ucfirst( __FUNCTION__ );
72 $this->
editPage( $name,
'Some text' );
77 'tags' =>
'custom tag',
80 $this->assertFalse( Title::newFromText( $name )->exists() );
83 $this->assertSame(
'custom tag', $dbw->selectField(
84 [
'change_tag',
'logging' ],
88 'log_title' => ucfirst( __FUNCTION__ ),
92 [
'change_tag' => [
'INNER JOIN',
'ct_log_id = log_id' ] ]
97 $this->setExpectedException( ApiUsageException::class,
98 'You do not have permission to apply change tags along with your changes.' );
100 $name =
'Help:' . ucfirst( __FUNCTION__ );
104 [
'user' => [
'applychangetags' =>
true ] ] );
106 $this->
editPage( $name,
'Some text' );
110 'action' =>
'delete',
112 'tags' =>
'custom tag',
115 $this->assertTrue( Title::newFromText( $name )->exists() );
120 $this->setExpectedException( ApiUsageException::class,
121 'Deletion aborted by hook. It gave no explanation.' );
123 $name =
'Help:' . ucfirst( __FUNCTION__ );
125 $this->
editPage( $name,
'Some text' );
136 $this->assertTrue( Title::newFromText( $name )->exists() );
141 $name =
'Help:' . ucfirst( __FUNCTION__ );
142 $user = self::$users[
'sysop']->getUser();
144 $this->
editPage( $name,
'Some text' );
145 $this->assertTrue( Title::newFromText( $name )->exists() );
146 $this->assertFalse( $user->isWatched( Title::newFromText( $name ) ) );
150 $this->assertFalse( Title::newFromText( $name )->exists() );
151 $this->assertTrue( $user->isWatched( Title::newFromText( $name ) ) );
155 $name =
'Help:' . ucfirst( __FUNCTION__ );
156 $user = self::$users[
'sysop']->getUser();
158 $this->
editPage( $name,
'Some text' );
159 $this->assertTrue( Title::newFromText( $name )->exists() );
160 $user->addWatch( Title::newFromText( $name ) );
161 $this->assertTrue( $user->isWatched( Title::newFromText( $name ) ) );
165 $this->assertFalse( Title::newFromText( $name )->exists() );
166 $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()
editPage( $pageName, $text, $summary='', $defaultNs=NS_MAIN)
Edits or creates a page/revision.
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.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...