2017-12-25 02:41:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use MediaWiki\Linker\LinkTarget;
|
2020-04-15 21:50:29 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @group API
|
|
|
|
|
* @group Database
|
|
|
|
|
* @group medium
|
|
|
|
|
*
|
|
|
|
|
* @covers ApiQueryRecentChanges
|
|
|
|
|
*/
|
|
|
|
|
class ApiQueryRecentChangesIntegrationTest extends ApiTestCase {
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
protected $tablesUsed = [
|
|
|
|
|
'recentchanges',
|
|
|
|
|
'page',
|
|
|
|
|
];
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
private function getLoggedInTestUser() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
return $this->getTestUser()->getUser();
|
2017-12-25 02:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-27 12:23:17 +00:00
|
|
|
private function doPageEdit( User $user, LinkTarget $target, $summary ) {
|
|
|
|
|
static $i = 0;
|
|
|
|
|
|
2017-12-25 02:41:49 +00:00
|
|
|
$title = Title::newFromLinkTarget( $target );
|
|
|
|
|
$page = WikiPage::factory( $title );
|
2021-06-24 08:42:19 +00:00
|
|
|
$page->doUserEditContent(
|
2017-12-27 12:23:17 +00:00
|
|
|
ContentHandler::makeContent( __CLASS__ . $i++, $title ),
|
2021-06-24 08:42:19 +00:00
|
|
|
$user,
|
|
|
|
|
$summary
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 12:23:17 +00:00
|
|
|
private function doMinorPageEdit( User $user, LinkTarget $target, $summary ) {
|
2017-12-25 02:41:49 +00:00
|
|
|
$title = Title::newFromLinkTarget( $target );
|
|
|
|
|
$page = WikiPage::factory( $title );
|
2021-06-24 08:42:19 +00:00
|
|
|
$page->doUserEditContent(
|
2017-12-27 12:23:17 +00:00
|
|
|
ContentHandler::makeContent( __CLASS__, $title ),
|
2021-06-24 08:42:19 +00:00
|
|
|
$user,
|
2017-12-25 02:41:49 +00:00
|
|
|
$summary,
|
2021-06-24 08:42:19 +00:00
|
|
|
EDIT_MINOR
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 12:23:17 +00:00
|
|
|
private function doBotPageEdit( User $user, LinkTarget $target, $summary ) {
|
2017-12-25 02:41:49 +00:00
|
|
|
$title = Title::newFromLinkTarget( $target );
|
|
|
|
|
$page = WikiPage::factory( $title );
|
2021-06-24 08:42:19 +00:00
|
|
|
$page->doUserEditContent(
|
2017-12-27 12:23:17 +00:00
|
|
|
ContentHandler::makeContent( __CLASS__, $title ),
|
2021-06-24 08:42:19 +00:00
|
|
|
$user,
|
2017-12-25 02:41:49 +00:00
|
|
|
$summary,
|
2021-06-24 08:42:19 +00:00
|
|
|
EDIT_FORCE_BOT
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 12:23:17 +00:00
|
|
|
private function doAnonPageEdit( LinkTarget $target, $summary ) {
|
2017-12-25 02:41:49 +00:00
|
|
|
$title = Title::newFromLinkTarget( $target );
|
|
|
|
|
$page = WikiPage::factory( $title );
|
2021-06-24 08:42:19 +00:00
|
|
|
$page->doUserEditContent(
|
2017-12-27 12:23:17 +00:00
|
|
|
ContentHandler::makeContent( __CLASS__, $title ),
|
2021-06-24 08:42:19 +00:00
|
|
|
User::newFromId( 0 ),
|
|
|
|
|
$summary
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function deletePage( LinkTarget $target, $reason ) {
|
|
|
|
|
$title = Title::newFromLinkTarget( $target );
|
|
|
|
|
$page = WikiPage::factory( $title );
|
2020-03-19 00:47:20 +00:00
|
|
|
$page->doDeleteArticleReal( $reason, $this->getTestSysop()->getUser() );
|
2017-12-25 02:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Performs a batch of page edits as a specified user
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @param array $editData associative array, keys:
|
|
|
|
|
* - target => LinkTarget page to edit
|
|
|
|
|
* - summary => string edit summary
|
|
|
|
|
* - minorEdit => bool mark as minor edit if true (defaults to false)
|
|
|
|
|
* - botEdit => bool mark as bot edit if true (defaults to false)
|
|
|
|
|
*/
|
|
|
|
|
private function doPageEdits( User $user, array $editData ) {
|
|
|
|
|
foreach ( $editData as $singleEditData ) {
|
|
|
|
|
if ( array_key_exists( 'minorEdit', $singleEditData ) && $singleEditData['minorEdit'] ) {
|
|
|
|
|
$this->doMinorPageEdit(
|
|
|
|
|
$user,
|
|
|
|
|
$singleEditData['target'],
|
|
|
|
|
$singleEditData['summary']
|
|
|
|
|
);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if ( array_key_exists( 'botEdit', $singleEditData ) && $singleEditData['botEdit'] ) {
|
|
|
|
|
$this->doBotPageEdit(
|
|
|
|
|
$user,
|
|
|
|
|
$singleEditData['target'],
|
|
|
|
|
$singleEditData['summary']
|
|
|
|
|
);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
$this->doPageEdit(
|
|
|
|
|
$user,
|
|
|
|
|
$singleEditData['target'],
|
|
|
|
|
$singleEditData['summary']
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-27 12:23:17 +00:00
|
|
|
private function doListRecentChangesRequest( array $params = [] ) {
|
2017-12-25 02:41:49 +00:00
|
|
|
return $this->doApiRequest(
|
|
|
|
|
array_merge(
|
|
|
|
|
[ 'action' => 'query', 'list' => 'recentchanges' ],
|
|
|
|
|
$params
|
|
|
|
|
),
|
|
|
|
|
null,
|
2018-03-28 14:01:46 +00:00
|
|
|
false,
|
|
|
|
|
$this->getLoggedInTestUser()
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function doGeneratorRecentChangesRequest( array $params = [] ) {
|
|
|
|
|
return $this->doApiRequest(
|
|
|
|
|
array_merge(
|
|
|
|
|
[ 'action' => 'query', 'generator' => 'recentchanges' ],
|
|
|
|
|
$params
|
2018-03-28 14:01:46 +00:00
|
|
|
),
|
|
|
|
|
null,
|
|
|
|
|
false,
|
|
|
|
|
$this->getLoggedInTestUser()
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
private function getItemsFromRecentChangesResult( array $result ) {
|
|
|
|
|
return $result[0]['query']['recentchanges'];
|
2017-12-25 02:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testListRecentChanges_returnsRCInfo() {
|
|
|
|
|
$target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$result = $this->doListRecentChangesRequest();
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$items = $this->getItemsFromRecentChangesResult( $result );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
// Default contains at least props for 'title', 'timestamp', and 'ids'.
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->assertCount( 1, $items );
|
|
|
|
|
$item = $items[0];
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
foreach ( [
|
|
|
|
|
'pageid',
|
|
|
|
|
'revid',
|
|
|
|
|
'old_revid',
|
|
|
|
|
'rcid',
|
|
|
|
|
'timestamp',
|
|
|
|
|
] as $key ) {
|
|
|
|
|
// Assert key but ignore value
|
|
|
|
|
$this->assertArrayHasKey( $key, $item );
|
|
|
|
|
unset( $item[ $key ] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The rest must equal exactly, with no additional keys (e.g. 'minor' or 'bot').
|
|
|
|
|
$this->assertEquals(
|
2017-12-25 02:41:49 +00:00
|
|
|
[
|
2017-12-27 12:23:17 +00:00
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'ApiQueryRecentChangesIntegrationTestPage',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
2017-12-27 12:23:17 +00:00
|
|
|
$item
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testIdsPropParameter() {
|
|
|
|
|
$target = new TitleValue( 0, 'ApiQueryRecentChangesIntegrationTestPage' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the page' );
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'ids' ] );
|
|
|
|
|
$items = $this->getItemsFromRecentChangesResult( $result );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertCount( 1, $items );
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$item = $items[0];
|
|
|
|
|
foreach ( [
|
|
|
|
|
'pageid',
|
|
|
|
|
'revid',
|
|
|
|
|
'old_revid',
|
|
|
|
|
'rcid',
|
|
|
|
|
] as $key ) {
|
|
|
|
|
// Assert key but ignore value
|
|
|
|
|
$this->assertArrayHasKey( $key, $item );
|
|
|
|
|
unset( $item[ $key ] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
],
|
|
|
|
|
$item
|
|
|
|
|
);
|
2017-12-25 02:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testTitlePropParameter() {
|
|
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Thing' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 1, 'Thing' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'summary' => 'Create Talk page',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Thing',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Thing',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testFlagsPropParameter() {
|
|
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'summary' => 'Create the page',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Regularpage' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'summary' => 'Create the page for minor change',
|
|
|
|
|
'target' => new TitleValue( 0, 'Minorpage' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'summary' => 'Make minor content',
|
|
|
|
|
'target' => new TitleValue( 0, 'Minorpage' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'minorEdit' => true,
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'summary' => 'Create the page as a bot',
|
|
|
|
|
'target' => new TitleValue( 0, 'Botpage' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'botEdit' => true,
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'flags' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'new' => true,
|
|
|
|
|
'minor' => false,
|
|
|
|
|
'bot' => true,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'edit',
|
|
|
|
|
'new' => false,
|
|
|
|
|
'minor' => true,
|
|
|
|
|
'bot' => false,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'new' => true,
|
|
|
|
|
'minor' => false,
|
|
|
|
|
'bot' => false,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'new' => true,
|
|
|
|
|
'minor' => false,
|
|
|
|
|
'bot' => false,
|
|
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUserPropParameter() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$userEditTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$anonEditTarget = new TitleValue( 0, 'Bar' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $userEditTarget, 'Create the page' );
|
|
|
|
|
$this->doAnonPageEdit( $anonEditTarget, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'user' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'anon' => true,
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'user' => '127.0.0.1',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'user' => $this->getLoggedInTestUser()->getName(),
|
|
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUserIdPropParameter() {
|
|
|
|
|
$user = $this->getLoggedInTestUser();
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$userEditTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$anonEditTarget = new TitleValue( 0, 'Bar' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $user, $userEditTarget, 'Create the page' );
|
|
|
|
|
$this->doAnonPageEdit( $anonEditTarget, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'userid' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'anon' => true,
|
|
|
|
|
'userid' => 0,
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'userid' => $user->getId(),
|
|
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCommentPropParameter() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the <b>page</b>' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'comment' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'comment' => 'Create the <b>page</b>',
|
|
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testParsedCommentPropParameter() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the <b>page</b>' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'parsedcomment' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'parsedcomment' => 'Create the <b>page</b>',
|
|
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testTimestampPropParameter() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'timestamp' ] );
|
|
|
|
|
$items = $this->getItemsFromRecentChangesResult( $result );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertCount( 1, $items );
|
2019-12-13 14:29:10 +00:00
|
|
|
$this->assertIsString( $items[0]['timestamp'] );
|
2017-12-25 02:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSizesPropParameter() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'sizes' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
'oldlen' => 0,
|
2017-12-27 12:23:17 +00:00
|
|
|
'newlen' => 38,
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createPageAndDeleteIt( LinkTarget $target ) {
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(),
|
2017-12-25 02:41:49 +00:00
|
|
|
$target,
|
|
|
|
|
'Create the page that will be deleted'
|
|
|
|
|
);
|
|
|
|
|
$this->deletePage( $target, 'Important Reason' );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLoginfoPropParameter() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$this->createPageAndDeleteIt( $target );
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'loginfo' ] );
|
|
|
|
|
$items = $this->getItemsFromRecentChangesResult( $result );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->assertCount( 1, $items );
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
foreach ( [
|
|
|
|
|
'logid',
|
|
|
|
|
] as $key ) {
|
|
|
|
|
// Assert key but ignore value
|
|
|
|
|
$this->assertArrayHasKey( $key, $items[0] );
|
|
|
|
|
unset( $items[0][ $key ] );
|
|
|
|
|
}
|
|
|
|
|
$this->assertEquals(
|
2017-12-25 02:41:49 +00:00
|
|
|
[
|
2017-12-27 12:23:17 +00:00
|
|
|
'type' => 'log',
|
|
|
|
|
'logtype' => 'delete',
|
|
|
|
|
'logaction' => 'delete',
|
|
|
|
|
'logparams' => [],
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
2017-12-27 12:23:17 +00:00
|
|
|
$items[0]
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testEmptyPropParameter() {
|
|
|
|
|
$user = $this->getLoggedInTestUser();
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $user, $target, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => '' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
|
|
|
|
]
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testNamespaceParam() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$subjectTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$talkTarget = new TitleValue( 1, 'Foo' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'target' => $subjectTarget,
|
|
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'target' => $talkTarget,
|
|
|
|
|
'summary' => 'Create the talk page',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcnamespace' => '0', 'rcprop' => 'title' ] );
|
|
|
|
|
$items = $this->getItemsFromRecentChangesResult( $result );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->assertCount( 1, $items );
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->assertEquals(
|
2017-12-25 02:41:49 +00:00
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'type' => 'new',
|
2017-12-27 12:23:17 +00:00
|
|
|
'ns' => 0,
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'title' => 'Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
2017-12-27 12:23:17 +00:00
|
|
|
$items[0]
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testShowAnonParams() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doAnonPageEdit( $target, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$resultAnon = $this->doListRecentChangesRequest( [
|
|
|
|
|
'rcprop' => 'user',
|
|
|
|
|
'rcshow' => WatchedItemQueryService::FILTER_ANON
|
|
|
|
|
] );
|
|
|
|
|
$resultNotAnon = $this->doListRecentChangesRequest( [
|
|
|
|
|
'rcprop' => 'user',
|
|
|
|
|
'rcshow' => WatchedItemQueryService::FILTER_NOT_ANON
|
|
|
|
|
] );
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$items = $this->getItemsFromRecentChangesResult( $resultAnon );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->assertCount( 1, $items );
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->assertSame( true, $items[0]['anon'], 'anon' );
|
|
|
|
|
$this->assertSame( [], $this->getItemsFromRecentChangesResult( $resultNotAnon ) );
|
2017-12-25 02:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testNewAndEditTypeParameters() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$subjectTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$talkTarget = new TitleValue( 1, 'Foo' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'target' => $subjectTarget,
|
|
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'target' => $subjectTarget,
|
|
|
|
|
'summary' => 'Change the content',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'target' => $talkTarget,
|
|
|
|
|
'summary' => 'Create Talk page',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$resultNew = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'new' ] );
|
|
|
|
|
$resultEdit = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'edit' ] );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultNew )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'edit',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultEdit )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLogTypeParameters() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$subjectTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$talkTarget = new TitleValue( 1, 'Foo' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$this->createPageAndDeleteIt( $subjectTarget );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $talkTarget, 'Create Talk page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'log' ] );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'log',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function getExternalRC( LinkTarget $target ) {
|
|
|
|
|
$title = Title::newFromLinkTarget( $target );
|
|
|
|
|
|
|
|
|
|
$rc = new RecentChange;
|
|
|
|
|
$rc->mAttribs = [
|
|
|
|
|
'rc_timestamp' => wfTimestamp( TS_MW ),
|
|
|
|
|
'rc_namespace' => $title->getNamespace(),
|
|
|
|
|
'rc_title' => $title->getDBkey(),
|
|
|
|
|
'rc_type' => RC_EXTERNAL,
|
|
|
|
|
'rc_source' => 'foo',
|
|
|
|
|
'rc_minor' => 0,
|
|
|
|
|
'rc_cur_id' => $title->getArticleID(),
|
|
|
|
|
'rc_user' => 0,
|
2017-09-12 17:12:29 +00:00
|
|
|
'rc_user_text' => 'm>External User',
|
2017-12-25 02:41:49 +00:00
|
|
|
'rc_comment' => '',
|
|
|
|
|
'rc_comment_text' => '',
|
|
|
|
|
'rc_comment_data' => null,
|
|
|
|
|
'rc_this_oldid' => $title->getLatestRevID(),
|
|
|
|
|
'rc_last_oldid' => $title->getLatestRevID(),
|
|
|
|
|
'rc_bot' => 0,
|
|
|
|
|
'rc_ip' => '',
|
|
|
|
|
'rc_patrolled' => 0,
|
|
|
|
|
'rc_new' => 0,
|
|
|
|
|
'rc_old_len' => $title->getLength(),
|
|
|
|
|
'rc_new_len' => $title->getLength(),
|
|
|
|
|
'rc_deleted' => 0,
|
|
|
|
|
'rc_logid' => 0,
|
|
|
|
|
'rc_log_type' => null,
|
|
|
|
|
'rc_log_action' => '',
|
|
|
|
|
'rc_params' => '',
|
|
|
|
|
];
|
|
|
|
|
$rc->mExtra = [
|
|
|
|
|
'prefixedDBkey' => $title->getPrefixedDBkey(),
|
|
|
|
|
'lastTimestamp' => 0,
|
|
|
|
|
'oldSize' => $title->getLength(),
|
|
|
|
|
'newSize' => $title->getLength(),
|
|
|
|
|
'pageStatus' => 'changed'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return $rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testExternalTypeParameters() {
|
|
|
|
|
$user = $this->getLoggedInTestUser();
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$subjectTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$talkTarget = new TitleValue( 1, 'Foo' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $user, $subjectTarget, 'Create the page' );
|
|
|
|
|
$this->doPageEdit( $user, $talkTarget, 'Create Talk page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$rc = $this->getExternalRC( $subjectTarget );
|
|
|
|
|
$rc->save();
|
|
|
|
|
|
|
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'external' ] );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'external',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testCategorizeTypeParameter() {
|
|
|
|
|
$user = $this->getLoggedInTestUser();
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$subjectTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$categoryTarget = new TitleValue( NS_CATEGORY, 'Bar' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$this->doPageEdits(
|
|
|
|
|
$user,
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'target' => $categoryTarget,
|
|
|
|
|
'summary' => 'Create the category',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'target' => $subjectTarget,
|
|
|
|
|
'summary' => 'Create the page and add it to the category',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
$title = Title::newFromLinkTarget( $subjectTarget );
|
2020-04-15 21:50:29 +00:00
|
|
|
$revision = MediaWikiServices::getInstance()
|
|
|
|
|
->getRevisionLookup()
|
|
|
|
|
->getRevisionByTitle( $title );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
2020-04-15 21:50:29 +00:00
|
|
|
$comment = $revision->getComment();
|
2017-12-25 02:41:49 +00:00
|
|
|
$rc = RecentChange::newForCategorization(
|
|
|
|
|
$revision->getTimestamp(),
|
|
|
|
|
Title::newFromLinkTarget( $categoryTarget ),
|
|
|
|
|
$user,
|
2020-04-15 21:50:29 +00:00
|
|
|
$comment ? $comment->text : '',
|
2017-12-25 02:41:49 +00:00
|
|
|
$title,
|
|
|
|
|
0,
|
|
|
|
|
$revision->getId(),
|
|
|
|
|
null,
|
|
|
|
|
false
|
|
|
|
|
);
|
|
|
|
|
$rc->save();
|
|
|
|
|
|
|
|
|
|
$result = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rctype' => 'categorize' ] );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'categorize',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => NS_CATEGORY,
|
|
|
|
|
'title' => 'Category:Bar',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLimitParam() {
|
|
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Foo' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 1, 'Foo' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'summary' => 'Create Talk page',
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Bar' ),
|
|
|
|
|
'summary' => 'Create another page',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$resultWithoutLimit = $this->doListRecentChangesRequest( [ 'rcprop' => 'title' ] );
|
|
|
|
|
$resultWithLimit = $this->doListRecentChangesRequest( [ 'rclimit' => 2, 'rcprop' => 'title' ] );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Bar'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Foo'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultWithoutLimit )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Bar'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Foo'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultWithLimit )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
$this->assertArrayHasKey( 'rccontinue', $resultWithLimit[0]['continue'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testAllRevParam() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'target' => $target,
|
|
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'target' => $target,
|
|
|
|
|
'summary' => 'Change the content',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$resultAllRev = $this->doListRecentChangesRequest( [ 'rcprop' => 'title', 'rcallrev' => '' ] );
|
2017-12-25 02:41:49 +00:00
|
|
|
$resultNoAllRev = $this->doListRecentChangesRequest( [ 'rcprop' => 'title' ] );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'edit',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Thing',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Thing',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultNoAllRev )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'edit',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Thing',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Thing',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultAllRev )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testDirParams() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$subjectTarget = new TitleValue( 0, 'Foo' );
|
|
|
|
|
$talkTarget = new TitleValue( 1, 'Foo' );
|
2017-12-25 02:41:49 +00:00
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'target' => $subjectTarget,
|
|
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'target' => $talkTarget,
|
|
|
|
|
'summary' => 'Create Talk page',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$resultDirOlder = $this->doListRecentChangesRequest(
|
|
|
|
|
[ 'rcdir' => 'older', 'rcprop' => 'title' ]
|
|
|
|
|
);
|
|
|
|
|
$resultDirNewer = $this->doListRecentChangesRequest(
|
|
|
|
|
[ 'rcdir' => 'newer', 'rcprop' => 'title' ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Foo'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultDirOlder )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Foo'
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultDirNewer )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-15 17:03:24 +00:00
|
|
|
public function testTitleParams() {
|
|
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Foo' ),
|
2018-03-15 17:03:24 +00:00
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 1, 'Bar' ),
|
2018-03-15 17:03:24 +00:00
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Quux' ),
|
2018-03-15 17:03:24 +00:00
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$result1 = $this->doListRecentChangesRequest(
|
2018-03-15 17:03:24 +00:00
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'rctitle' => 'Foo',
|
2018-03-15 17:03:24 +00:00
|
|
|
'rcprop' => 'title'
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
$result2 = $this->doListRecentChangesRequest(
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'rctitle' => 'Talk:Bar',
|
2018-03-15 17:03:24 +00:00
|
|
|
'rcprop' => 'title'
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo'
|
2018-03-15 17:03:24 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result1 )
|
2018-03-15 17:03:24 +00:00
|
|
|
);
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Bar'
|
2018-03-15 17:03:24 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $result2 )
|
2018-03-15 17:03:24 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-25 02:41:49 +00:00
|
|
|
public function testStartEndParams() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$resultStart = $this->doListRecentChangesRequest( [
|
|
|
|
|
'rcstart' => '20010115000000',
|
|
|
|
|
'rcdir' => 'newer',
|
|
|
|
|
'rcprop' => 'title',
|
|
|
|
|
] );
|
|
|
|
|
$resultEnd = $this->doListRecentChangesRequest( [
|
|
|
|
|
'rcend' => '20010115000000',
|
|
|
|
|
'rcdir' => 'newer',
|
|
|
|
|
'rcprop' => 'title',
|
|
|
|
|
] );
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Thing',
|
2017-12-25 02:41:49 +00:00
|
|
|
]
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $resultStart )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->assertSame( [], $this->getItemsFromRecentChangesResult( $resultEnd ) );
|
2017-12-25 02:41:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContinueParam() {
|
|
|
|
|
$this->doPageEdits(
|
|
|
|
|
$this->getLoggedInTestUser(),
|
|
|
|
|
[
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Foo' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 1, 'Foo' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'summary' => 'Create Talk page',
|
|
|
|
|
],
|
|
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'target' => new TitleValue( 0, 'Bar' ),
|
2017-12-25 02:41:49 +00:00
|
|
|
'summary' => 'Create the page',
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$firstResult = $this->doListRecentChangesRequest( [ 'rclimit' => 2, 'rcprop' => 'title' ] );
|
|
|
|
|
|
|
|
|
|
$continuationParam = $firstResult[0]['continue']['rccontinue'];
|
|
|
|
|
|
|
|
|
|
$continuedResult = $this->doListRecentChangesRequest(
|
|
|
|
|
[ 'rccontinue' => $continuationParam, 'rcprop' => 'title' ]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Bar',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 1,
|
|
|
|
|
'title' => 'Talk:Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $firstResult )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
$this->assertEquals(
|
|
|
|
|
[
|
|
|
|
|
[
|
|
|
|
|
'type' => 'new',
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Foo',
|
2017-12-25 02:41:49 +00:00
|
|
|
]
|
|
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$this->getItemsFromRecentChangesResult( $continuedResult )
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testGeneratorRecentChangesPropInfo_returnsRCPages() {
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$target = new TitleValue( 0, 'Thing' );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->doPageEdit( $this->getLoggedInTestUser(), $target, 'Create the page' );
|
2017-12-25 02:41:49 +00:00
|
|
|
|
|
|
|
|
$result = $this->doGeneratorRecentChangesRequest( [ 'prop' => 'info' ] );
|
|
|
|
|
|
|
|
|
|
// $result[0]['query']['pages'] uses page ids as keys. Page ids don't matter here, so drop them
|
|
|
|
|
$pages = array_values( $result[0]['query']['pages'] );
|
2017-12-27 12:23:17 +00:00
|
|
|
$this->assertCount( 1, $pages );
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
|
|
|
|
|
$page = $pages[0];
|
|
|
|
|
foreach ( [
|
|
|
|
|
'pageid',
|
|
|
|
|
'touched',
|
|
|
|
|
'lastrevid',
|
|
|
|
|
'length',
|
|
|
|
|
] as $key ) {
|
|
|
|
|
// Assert key but ignore value
|
|
|
|
|
$this->assertArrayHasKey( $key, $page );
|
|
|
|
|
unset( $page[ $key ] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(
|
2017-12-25 02:41:49 +00:00
|
|
|
[
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'ns' => 0,
|
|
|
|
|
'title' => 'Thing',
|
2017-12-27 12:23:17 +00:00
|
|
|
'new' => true,
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
'contentmodel' => 'wikitext',
|
|
|
|
|
'pagelanguage' => 'en',
|
|
|
|
|
'pagelanguagehtmlcode' => 'en',
|
|
|
|
|
'pagelanguagedir' => 'ltr',
|
2017-12-25 02:41:49 +00:00
|
|
|
],
|
watchlist: Misc cleanup for ApiQueryRecentChangesIntegrationTest
* Avoid partial assertions using array subsets.
Instead, explicitly ignore the keys we want to ignore,
and then assert the array in full.
This way, newly added properties are explicitly detected
by the test, and it also automatically means that no bad
properties can be added. For example, properties like 'new',
'minor' and 'bot' express their meaning by sheer existence
and must never be tolerated to exist.
This was motivated by the many assertArraySubset() deprecation
warnings that were making the CI build output very noisy,
and thus it was difficult to quickly find real problems.
- For testNamespaceParam() I added rcprop=title, as it was
only asserting those keys. The alternative was to repeat
all the assertions for the overall output, which other tests
already did.
* Avoid using User::getName() or Title::getPrefixedText()
in the asserted expected value. Be explicit. This also
makes the test run considerably faster.
* Use 'tablesUsed' the way we normally do in MediaWiki unit
tests, by declaring the class member. (We never use
TestCase constructors.)
* Remove use of harcoded DB truncation for 'recentchanges'.
MediaWikiIntegrationTestCase does this already, which is what
`@group Database` and `tablesUsed` are for.
* Remove use of mutable TestUser, the user is never mutated.
This allows the internal registry to re-use the same instance.
* Remove use of assertArrayHasKey() where it only checked
something the test would immediately assert on the next line.
We already have PHPUnit configured in general to assert and
fail directly upon any undefined key access.
* Use sample names like Foo, Bar and Quux which are easier
to remember and distinguish than overly long and similar
titles with some word or number added at the end of them.
Change-Id: I8133e1199e3b1d053be7053795172891ad2bf48b
2020-03-08 17:18:55 +00:00
|
|
|
$page
|
2017-12-25 02:41:49 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|