2011-07-13 01:54:40 +00:00
|
|
|
<?php
|
2022-07-27 17:07:00 +00:00
|
|
|
|
|
|
|
|
use MediaWiki\MainConfigNames;
|
2022-10-28 10:04:25 +00:00
|
|
|
use MediaWiki\Request\FauxRequest;
|
2022-04-04 19:41:23 +00:00
|
|
|
use MediaWiki\Utils\UrlUtils;
|
|
|
|
|
|
2011-10-11 18:30:50 +00:00
|
|
|
/**
|
2014-07-18 19:35:43 +00:00
|
|
|
* @group GlobalFunctions
|
2013-10-24 09:53:24 +00:00
|
|
|
* @covers ::wfExpandUrl
|
2011-07-13 01:54:40 +00:00
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class WfExpandUrlTest extends MediaWikiIntegrationTestCase {
|
2013-10-24 09:53:24 +00:00
|
|
|
/**
|
2022-05-16 02:14:33 +00:00
|
|
|
* Same tests as the UrlUtils method to ensure they don't fall out of sync
|
|
|
|
|
* @dataProvider UrlUtilsProviders::provideExpand
|
2013-10-24 09:53:24 +00:00
|
|
|
*/
|
2022-05-16 02:14:33 +00:00
|
|
|
public function testWfExpandUrl( string $input, array $options,
|
|
|
|
|
$defaultProto, string $expected
|
2014-04-24 09:47:06 +00:00
|
|
|
) {
|
2022-05-16 02:14:33 +00:00
|
|
|
$conf = [
|
2022-07-27 17:07:00 +00:00
|
|
|
MainConfigNames::Server => $options[UrlUtils::SERVER] ?? null,
|
|
|
|
|
MainConfigNames::CanonicalServer => $options[UrlUtils::CANONICAL_SERVER] ?? null,
|
|
|
|
|
MainConfigNames::InternalServer => $options[UrlUtils::INTERNAL_SERVER] ?? null,
|
|
|
|
|
MainConfigNames::HttpsPort => $options[UrlUtils::HTTPS_PORT] ?? 443,
|
2022-05-16 02:14:33 +00:00
|
|
|
];
|
|
|
|
|
$currentProto = $options[UrlUtils::FALLBACK_PROTOCOL];
|
|
|
|
|
|
2022-07-27 17:07:00 +00:00
|
|
|
$this->overrideConfigValues( $conf );
|
2021-09-21 20:19:50 +00:00
|
|
|
$this->setRequest( new FauxRequest( [], false, null, $currentProto ) );
|
|
|
|
|
$this->assertEquals( $expected, wfExpandUrl( $input, $defaultProto ) );
|
2011-07-13 01:54:40 +00:00
|
|
|
}
|
|
|
|
|
}
|