3 use MediaWiki\Site\MediaWikiPageNameNormalizer
;
6 * @covers MediaWiki\Site\MediaWikiPageNameNormalizer
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
30 class MediaWikiPageNameNormalizerTest
extends PHPUnit_Framework_TestCase
{
32 protected function setUp() {
35 static $connectivity = null;
37 if ( $connectivity === null ) {
38 // Check whether we have (reasonable fast) connectivity
40 'https://www.wikidata.org/w/api.php?action=query&meta=siteinfo&format=json',
41 array( 'timeout' => 3 ),
45 if ( $res === false ||
strpos( $res, '"sitename":"Wikidata"' ) === false ) {
46 $connectivity = false;
52 if ( !$connectivity ) {
53 $this->markTestSkipped( 'MediaWikiPageNameNormalizerTest needs internet connectivity.' );
58 * @dataProvider normalizePageTitleProvider
60 public function testNormalizePageTitle( $expected, $pageName ) {
61 $normalizer = new MediaWikiPageNameNormalizer();
65 $normalizer->normalizePageName( $pageName, 'https://www.wikidata.org/w/api.php' )
69 public function normalizePageTitleProvider() {
70 // Note: This makes (very conservative) assumptions about pages on Wikidata
73 'universe (Q1)' => array(
76 'Q404 redirects to Q395' => array(
79 'there is no Q0' => array(