Aleksey Bekh-Ivanov (WMDE) has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/334333 )
Change subject: WIP Refactoring SpecialItemByTitleTest
......................................................................
WIP Refactoring SpecialItemByTitleTest
Before we can get rid of assertTag we should understand
what is actually tested.
Bug: T69122
Change-Id: I5315e5a48cb4e4bfc6680e101c3cb587b64e9df6
---
M repo/tests/phpunit/includes/Specials/SpecialItemByTitleTest.php
1 file changed, 70 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/33/334333/1
diff --git a/repo/tests/phpunit/includes/Specials/SpecialItemByTitleTest.php
b/repo/tests/phpunit/includes/Specials/SpecialItemByTitleTest.php
index 9d39bf4..cbdaf6b 100644
--- a/repo/tests/phpunit/includes/Specials/SpecialItemByTitleTest.php
+++ b/repo/tests/phpunit/includes/Specials/SpecialItemByTitleTest.php
@@ -180,4 +180,74 @@
}
}
+ public function testAllNeededFieldsArePresent_WhenRendered() {
+
+ list( $output ) = $this->executeSpecialPage();
+
+ $matchers = [];
+
+ $matchers['site'] = [
+ 'tag' => 'input',
+ 'attributes' => [
+ 'name' => 'site',
+ ],
+ ];
+ $matchers['page'] = [
+ 'tag' => 'input',
+ 'attributes' => [
+ 'name' => 'page',
+ ],
+ ];
+ $matchers['submit'] = [
+ 'tag' => 'button',
+ 'attributes' => [
+ 'type' => 'submit',
+ 'name' => '',
+ ],
+ ];
+
+ foreach ( $matchers as $key => $matcher ) {
+ $this->assertTag( $matcher, $output, "Failed to match
html output with tag '{$key}''" );
+ }
+ }
+
+ public function
testSiteAndPageFieldsAreFilledIn_WhenRenderedWithSubpageReferingToNonexistentTitle()
{
+
+ list( $output ) = $this->executeSpecialPage( 'enwiki/NotFound'
);
+
+ $matchers = [];
+
+ $matchers['site'] = [
+ 'tag' => 'input',
+ 'attributes' => [
+ 'name' => 'site',
+ 'value' => 'enwiki'
+ ],
+ ];
+ $matchers['page'] = [
+ 'tag' => 'input',
+ 'attributes' => [
+ 'name' => 'page',
+ 'value' => 'NotFound'
+ ],
+ ];
+
+ foreach ( $matchers as $key => $matcher ) {
+ $this->assertTag( $matcher, $output, "Failed to match
html output with tag '{$key}''" );
+ }
+ }
+
+ public function
testRedirectsToItem_WhenGivenSubpageReferencesExistingTitle() {
+ $target = 'Q123';
+ $sub = 'dewiki/Gefunden';
+
+
+ /* @var WebResponse $response */
+ list( $output, $response ) = $this->executeSpecialPage( $sub );
+
+ $target = Title::newFromText( $target )->getFullURL();
+ $expected = wfExpandUrl( $target, PROTO_CURRENT );
+ $this->assertEquals( $expected, $response->getHeader(
'Location' ), 'Redirect' );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/334333
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5315e5a48cb4e4bfc6680e101c3cb587b64e9df6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aleksey Bekh-Ivanov (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits