Debian Codegraph @

tests/phpunit/integration/includes/poolcounter/PoolCounterConnectionManagerTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\PoolCounter\PoolCounterConnectionManager;
4
5 /**
6 * @covers \MediaWiki\PoolCounter\PoolCounterConnectionManager
7 * @group Database
8 */
9 class PoolCounterConnectionManagerTest extends MediaWikiIntegrationTestCase {
10
11 public static function provideServersConfig() {
12 // supplied hostname, expected host, expected port
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 * Tests whether the hostname supplied is correct. Tests ipv4 and ipv6.
34 *
35 * @covers \MediaWiki\PoolCounter\PoolCounterConnectionManager::get
36 * @dataProvider provideServersConfig
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 }