| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
namespace MediaWiki\SecureLinkFixer\Test; |
| 20 |
|
| 21 |
use MediaWiki\SecureLinkFixer\Hooks; |
| 22 |
use MediaWikiIntegrationTestCase; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
class HooksTest extends MediaWikiIntegrationTestCase { |
| 28 |
|
| 29 |
|
| 30 |
|
| 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 |
} |