MediaWiki
REL1_31
DatabaseMssqlTest.php
Go to the documentation of this file.
1
<?php
2
3
use
Wikimedia\Rdbms\DatabaseMssql
;
4
5
class
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
36
public
function
provideBuildSubstring_invalidParams
() {
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
}
DatabaseMssqlTest
Definition
DatabaseMssqlTest.php:5
DatabaseMssqlTest\testBuildSubstring
testBuildSubstring( $input, $start, $length, $expected)
Wikimedia\Rdbms\DatabaseMssql::buildSubstring provideBuildSubstring.
Definition
DatabaseMssqlTest.php:30
DatabaseMssqlTest\getMockDb
getMockDb()
Definition
DatabaseMssqlTest.php:13
DatabaseMssqlTest\testBuildSubstring_invalidParams
testBuildSubstring_invalidParams( $start, $length)
Wikimedia\Rdbms\DatabaseMssql::buildSubstring provideBuildSubstring_invalidParams.
Definition
DatabaseMssqlTest.php:49
DatabaseMssqlTest\provideBuildSubstring_invalidParams
provideBuildSubstring_invalidParams()
Definition
DatabaseMssqlTest.php:36
DatabaseMssqlTest\provideBuildSubstring
provideBuildSubstring()
Definition
DatabaseMssqlTest.php:20
Wikimedia\Rdbms\DatabaseMssql
Definition
DatabaseMssql.php:37
$output
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition
hooks.txt:2255
$input
if(is_array($mode)) switch( $mode) $input
Definition
postprocess-phan.php:145
tests
phpunit
includes
libs
rdbms
database
DatabaseMssqlTest.php
Generated on Mon Nov 25 2024 15:36:26 for MediaWiki by
1.10.0