aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
diff options
context:
space:
mode:
authorBartosz Dziewoński <matma.rex@gmail.com>2021-11-05 20:33:21 +0100
committerBartosz Dziewoński <matma.rex@gmail.com>2021-11-05 21:56:01 +0100
commitb1b1ec343f8d526bc9013d7f828f8bb6e83cbe42 (patch)
treedb4915759d93037b863a21042b2344c046330eb5 /tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
parent0496e036b5310c2a23e42e3104ca84e8c3944022 (diff)
downloadmediawikicore-b1b1ec343f8d526bc9013d7f828f8bb6e83cbe42.tar.gz
mediawikicore-b1b1ec343f8d526bc9013d7f828f8bb6e83cbe42.zip
ApiQuerySiteinfo: Fix "rightsinfo"/"url" when $wgRightsPage is set
Bug: T295191 Change-Id: I181b29dbdc8374837789c1d900577e49f62bd8d3
Diffstat (limited to 'tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php')
-rw-r--r--tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php b/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
index 16b1ab908dcf..869172b64aa3 100644
--- a/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
+++ b/tests/phpunit/includes/api/query/ApiQuerySiteinfoTest.php
@@ -477,15 +477,27 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
'wgRightsUrl' => $url,
'wgRightsText' => $text,
] );
-
$this->assertSame(
[ 'url' => $expectedUrl, 'text' => $expectedText ],
$this->doQuery( 'rightsinfo' )
);
+
+ // The installer sets these options to empty string if not specified otherwise,
+ // test that this behaves the same as null.
+ $this->setMwGlobals( [
+ 'wgRightsPage' => $page ?? '',
+ 'wgRightsUrl' => $url ?? '',
+ 'wgRightsText' => $text ?? '',
+ ] );
+ $this->assertSame(
+ [ 'url' => $expectedUrl, 'text' => $expectedText ],
+ $this->doQuery( 'rightsinfo' ),
+ 'empty string behaves the same as null'
+ );
}
public function rightsInfoProvider() {
- $textUrl = wfExpandUrl( Title::newFromText( 'License' ), PROTO_CURRENT );
+ $textUrl = wfExpandUrl( Title::newFromText( 'License' )->getLinkURL(), PROTO_CURRENT );
$url = 'http://license.example/';
return [
@@ -499,7 +511,7 @@ class ApiQuerySiteinfoTest extends ApiTestCase {
'Page and text' => [ 'License', null, '!!!', $textUrl, '!!!' ],
'Page and URL and text' => [ 'License', $url, '!!!', $textUrl, '!!!' ],
'Pagename "0"' => [ '0', null, null,
- wfExpandUrl( Title::newFromText( '0' ), PROTO_CURRENT ), '0' ],
+ wfExpandUrl( Title::newFromText( '0' )->getLinkURL(), PROTO_CURRENT ), '0' ],
'URL "0"' => [ null, '0', null, '0', '' ],
'Text "0"' => [ null, null, '0', '', '0' ],
];