| 1 |
<?php |
| 2 |
|
| 3 |
use MediaWiki\PoolCounter\PoolCounterConnectionManager; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
class PoolCounterConnectionManagerTest extends MediaWikiIntegrationTestCase { |
| 10 |
|
| 11 |
public static function provideServersConfig() { |
| 12 |
|
| 13 |
return [ |
| 14 |
'Correct IPv4' => [ |
| 15 |
'127.0.0.1', '127.0.0.1', 7531 |
| 16 |
], |
| 17 |
'Bracketless IPv6' => [ |
| 18 |
'::1', '[::1]', 7531 |
| 19 |
], |
| 20 |
'Bracketed IPv6' => [ |
| 21 |
'[::1]', '[::1]', 7531 |
| 22 |
], |
| 23 |
'IPv4 with port' => [ |
| 24 |
'127.0.0.1:123', '127.0.0.1', 123 |
| 25 |
], |
| 26 |
'IPv6 with port' => [ |
| 27 |
'[::1]:123', '[::1]', 123, |
| 28 |
], |
| 29 |
]; |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public function testGetServersConfig( $suppliedHostname, $expectedHost, $expectedPort ) { |
| 39 |
$pcm = new PoolCounterConnectionManager( [ 'servers' => [ $suppliedHostname ] ] ); |
| 40 |
$pcm->get( 'test' ); |
| 41 |
|
| 42 |
$this->assertEquals( $expectedHost, $pcm->host ); |
| 43 |
$this->assertSame( $expectedPort, $pcm->port ); |
| 44 |
} |
| 45 |
|
| 46 |
} |