15 use PHPUnit4And6Compat;
21 $lb = $this->getMock( ILoadBalancer::class );
23 $lb->method(
'getConnection' )->willReturnCallback(
29 $lb->method(
'getConnectionRef' )->willReturnCallback(
30 function ()
use ( $lb ) {
42 $db = $this->getMockBuilder( Database::class )
43 ->disableOriginalConstructor()
47 $db->method(
'__toString' )->willReturn(
'MOCK_DB' );
64 $this->assertInstanceOf( ResultWrapper::class, $ref->select(
'whatever',
'*' ) );
68 $lb = $this->getMock( ILoadBalancer::class );
70 $lb->expects( $this->once() )
71 ->method(
'getConnection' )
72 ->with(
DB_MASTER, [
'test' ],
'dummy', ILoadBalancer::CONN_TRX_AUTOCOMMIT )
81 [
DB_MASTER, [
'test' ],
'dummy', ILoadBalancer::CONN_TRX_AUTOCOMMIT ]
84 $this->assertInstanceOf( ResultWrapper::class, $ref->select(
'whatever',
'*' ) );
90 $lb->expects( $this->once() )
91 ->method(
'reuseConnection' );
99 $this->assertInstanceOf( ResultWrapper::class, $ref->select(
'whatever',
'*' ) );
103 $this->setExpectedException( InvalidArgumentException::class,
'' );
110 $lb = $this->getMock( ILoadBalancer::class );
113 $lb->expects( $this->never() )
114 ->method(
'getConnection' );
118 $this->assertSame(
'dummy', $ref->getWikiID() );
122 $lb = $this->getMock( ILoadBalancer::class );
125 $lb->expects( $this->never() )
126 ->method(
'getConnection' );
130 $this->assertSame(
'dummy', $ref->getDomainID() );
136 $this->assertInstanceOf( ResultWrapper::class, $ref->select(
'whatever',
'*' ) );
141 $this->assertInternalType(
'string', $ref->__toString() );
145 $this->assertInternalType(
'string', $ref->__toString() );
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Wikimedia\Rdbms\DBConnRef.
getDBConnRef(ILoadBalancer $lb=null)
innerMethodForTestDestruct(ILoadBalancer $lb)