Debian Codegraph @

extensions/SecureLinkFixer/tests/phpunit/HooksTest.php

raw symbols SCIP
1 <?php
2 /**
3 * Copyright (C) 2018 Kunal Mehta <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19 namespace MediaWiki\SecureLinkFixer\Test;
20
21 use MediaWiki\SecureLinkFixer\Hooks;
22 use MediaWikiIntegrationTestCase;
23
24 /**
25 * @covers \MediaWiki\SecureLinkFixer\Hooks
26 */
27 class HooksTest extends MediaWikiIntegrationTestCase {
28
29 /**
30 * @dataProvider provideOnLinkerMakeExternalLink
31 */
32 public function testOnLinkerMakeExternalLink( $input, $expected ) {
33 $services = $this->getServiceContainer();
34 $hooks = new Hooks( $services->getService( 'HSTSPreloadLookup' ), $services->getUrlUtils() );
35 $dummy = '';
36 $dummy2 = [];
37 $hooks->onLinkerMakeExternalLink( $input, $dummy, $dummy, $dummy2, $dummy );
38 $this->assertSame( $expected, $input );
39 }
40
41 public static function provideOnLinkerMakeExternalLink() {
42 return [
43 [ 'http://test.localhost/', 'http://test.localhost/' ],
44 [ 'http://en.wikipedia.org/wiki/Main_Page', 'https://en.wikipedia.org/wiki/Main_Page' ],
45 [ '//en.wikipedia.org/wiki/Main_Page', 'https://en.wikipedia.org/wiki/Main_Page' ],
46 [ 'http://foo.dev/foo/', 'https://foo.dev/foo/' ],
47 [ 'ftp://en.wikipedia.org/', 'ftp://en.wikipedia.org/' ],
48 [ 'https://whatever.localhost/', 'https://whatever.localhost/' ],
49 [ 'definitely invalid', 'definitely invalid' ],
50 ];
51 }
52 }