MediaWiki REL1_33
NameTableStoreFactoryTest.php
Go to the documentation of this file.
1<?php
2
4
12
21 private function getMockLoadBalancer( $localDomain ) {
22 $mock = $this->getMockBuilder( ILoadBalancer::class )
23 ->disableOriginalConstructor()->getMock();
24
25 $mock->expects( $this->any() )
26 ->method( 'getLocalDomainID' )
27 ->willReturn( $localDomain );
28
29 return $mock;
30 }
31
35 private function getMockLoadBalancerFactory( $expectedWiki ) {
36 $mock = $this->getMockBuilder( ILBFactory::class )
37 ->disableOriginalConstructor()->getMock();
38
39 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
40 $localDomain = $lbFactory->getLocalDomainID();
41
42 $mock->expects( $this->any() )->method( 'getLocalDomainID' )->willReturn( $localDomain );
43
44 $mock->expects( $this->once() )
45 ->method( 'getMainLB' )
46 ->with( $this->equalTo( $expectedWiki ) )
47 ->willReturnCallback( function ( $domain ) use ( $localDomain ) {
48 return $this->getMockLoadBalancer( $localDomain );
49 } );
50
51 return $mock;
52 }
53
54 public static function provideTestGet() {
55 return [
56 [
57 'change_tag_def',
58 false,
59 false,
60 ],
61 [
62 'content_models',
63 false,
64 false,
65 ],
66 [
67 'slot_roles',
68 false,
69 false,
70 ],
71 [
72 'change_tag_def',
73 'test7245',
74 'test7245',
75 ],
76 ];
77 }
78
80 public function testGet( $tableName, $wiki, $expectedWiki ) {
82 $wiki2 = ( $wiki === false )
83 ? $services->getDBLoadBalancerFactory()->getLocalDomainID()
84 : $wiki;
85 $names = new NameTableStoreFactory(
86 $this->getMockLoadBalancerFactory( $expectedWiki ),
87 $services->getMainWANObjectCache(),
88 LoggerFactory::getInstance( 'NameTableStoreFactory' )
89 );
90
91 $table = $names->get( $tableName, $wiki );
92 $table2 = $names->get( $tableName, $wiki2 );
93 $this->assertSame( $table, $table2 );
94 $this->assertInstanceOf( NameTableStore::class, $table );
95 }
96
97 /*
98 * The next three integration tests verify that the schema information is correct by loading
99 * the relevant information from the database.
100 */
101
104 $factory = $services->getNameTableStoreFactory();
105 $store = $factory->getChangeTagDef();
106 $this->assertType( 'array', $store->getMap() );
107 }
108
111 $factory = $services->getNameTableStoreFactory();
112 $store = $factory->getContentModels();
113 $this->assertType( 'array', $store->getMap() );
114 }
115
116 public function testIntegratedGetSlotRoles() {
118 $factory = $services->getNameTableStoreFactory();
119 $store = $factory->getSlotRoles();
120 $this->assertType( 'array', $store->getMap() );
121 }
122}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
Definition COPYING.txt:326
assertType( $type, $actual, $message='')
Asserts the type of the provided value.
PSR-3 logger instance factory.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getInstance()
Returns the global default instance of the top level service locator.
MediaWiki\Storage\NameTableStoreFactory Database.
testGet( $tableName, $wiki, $expectedWiki)
provideTestGet
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition hooks.txt:2290
processing should stop and the error should be shown to the user * false
Definition hooks.txt:187
An interface for generating database load balancers.
Database cluster connection, tracking, load balancing, and transaction manager interface.