MediaWiki REL1_32
DatabaseMssqlTest.php
Go to the documentation of this file.
1<?php
2
4
5class DatabaseMssqlTest extends PHPUnit\Framework\TestCase {
6
7 use MediaWikiCoversValidator;
8 use PHPUnit4And6Compat;
9
13 private function getMockDb() {
14 return $this->getMockBuilder( DatabaseMssql::class )
15 ->disableOriginalConstructor()
16 ->setMethods( null )
17 ->getMock();
18 }
19
20 public function provideBuildSubstring() {
21 yield [ 'someField', 1, 2, 'SUBSTRING(someField,1,2)' ];
22 yield [ 'someField', 1, null, 'SUBSTRING(someField,1,2147483647)' ];
23 yield [ 'someField', 1, 3333333333, 'SUBSTRING(someField,1,3333333333)' ];
24 }
25
30 public function testBuildSubstring( $input, $start, $length, $expected ) {
31 $mockDb = $this->getMockDb();
32 $output = $mockDb->buildSubstring( $input, $start, $length );
33 $this->assertSame( $expected, $output );
34 }
35
37 yield [ -1, 1 ];
38 yield [ 1, -1 ];
39 yield [ 1, 'foo' ];
40 yield [ 'foo', 1 ];
41 yield [ null, 1 ];
42 yield [ 0, 1 ];
43 }
44
49 public function testBuildSubstring_invalidParams( $start, $length ) {
50 $mockDb = $this->getMockDb();
51 $this->setExpectedException( InvalidArgumentException::class );
52 $mockDb->buildSubstring( 'foo', $start, $length );
53 }
54
55}
testBuildSubstring( $input, $start, $length, $expected)
Wikimedia\Rdbms\DatabaseMssql::buildSubstring provideBuildSubstring.
testBuildSubstring_invalidParams( $start, $length)
Wikimedia\Rdbms\DatabaseMssql::buildSubstring provideBuildSubstring_invalidParams.
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 $output
Definition hooks.txt:2317
if(is_array($mode)) switch( $mode) $input