mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/SecureLinkFixer
synced 2024-11-14 19:24:46 +00:00
da8ba82393
Initally used a new sniff with autofix (T333745) Bug: T332865 Change-Id: I7cc7ccda4db61bc20f6b3ee225c9a5b7d484dd88
52 lines
1.8 KiB
PHP
52 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (C) 2018 Kunal Mehta <legoktm@debian.org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
namespace MediaWiki\SecureLinkFixer\Test;
|
|
|
|
use MediaWiki\SecureLinkFixer\Hooks;
|
|
use MediaWikiIntegrationTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\SecureLinkFixer\Hooks
|
|
*/
|
|
class HooksTest extends MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideOnLinkerMakeExternalLink
|
|
*/
|
|
public function testOnLinkerMakeExternalLink( $input, $expected ) {
|
|
$hooks = new Hooks( $this->getServiceContainer()->getService( 'HSTSPreloadLookup' ) );
|
|
$dummy = '';
|
|
$dummy2 = [];
|
|
$hooks->onLinkerMakeExternalLink( $input, $dummy, $dummy, $dummy2, $dummy );
|
|
$this->assertSame( $expected, $input );
|
|
}
|
|
|
|
public static function provideOnLinkerMakeExternalLink() {
|
|
return [
|
|
[ 'http://test.localhost/', 'http://test.localhost/' ],
|
|
[ 'http://en.wikipedia.org/wiki/Main_Page', 'https://en.wikipedia.org/wiki/Main_Page' ],
|
|
[ '//en.wikipedia.org/wiki/Main_Page', 'https://en.wikipedia.org/wiki/Main_Page' ],
|
|
[ 'http://foo.dev/foo/', 'https://foo.dev/foo/' ],
|
|
[ 'ftp://en.wikipedia.org/', 'ftp://en.wikipedia.org/' ],
|
|
[ 'https://whatever.localhost/', 'https://whatever.localhost/' ],
|
|
[ 'definitely invalid', 'definitely invalid' ],
|
|
];
|
|
}
|
|
}
|