MediaWiki REL1_32
RangeChronologicalPagerTest.php
Go to the documentation of this file.
1<?php
2
11
16 public function testGetDateCond( $inputYear, $inputMonth, $inputDay, $expected ) {
17 $pager = $this->getMockForAbstractClass( RangeChronologicalPager::class );
18 $this->assertEquals(
19 $expected,
20 wfTimestamp( TS_MW, $pager->getDateCond( $inputYear, $inputMonth, $inputDay ) )
21 );
22 }
23
27 public function getDateCondProvider() {
28 return [
29 [ 2016, 12, 5, '20161205235959' ],
30 [ 2016, 12, 31, '20161231235959' ],
31 [ 2016, 12, 1337, '20161231235959' ],
32 [ 2016, 1337, 1337, '20161231235959' ],
33 [ 2016, 1337, -1, '20161231235959' ],
34 [ 2016, 12, 32, '20161231235959' ],
35 [ 2016, 12, -1, '20161231235959' ],
36 [ 2016, -1, -1, '20161231235959' ],
37 ];
38 }
39
44 public function testGetDateRangeCond( $start, $end, $expected ) {
45 $pager = $this->getMockForAbstractClass( RangeChronologicalPager::class );
46 $this->assertArrayEquals( $expected, $pager->getDateRangeCond( $start, $end ) );
47 }
48
52 public function getDateRangeCondProvider() {
54
55 return [
56 [
57 '20161201000000',
58 '20161203000000',
59 [
60 '>=' . $db->addQuotes( $db->timestamp( '20161201000000' ) ),
61 '<=' . $db->addQuotes( $db->timestamp( '20161203000000' ) ),
62 ],
63 ],
64 [
65 '',
66 '20161203000000',
67 [
68 '<=' . $db->addQuotes( $db->timestamp( '20161203000000' ) ),
69 ],
70 ],
71 [
72 '20161201000000',
73 '',
74 [
75 '>=' . $db->addQuotes( $db->timestamp( '20161201000000' ) ),
76 ],
77 ],
78 [ '', '', [] ],
79 ];
80 }
81
86 public function testGetDateRangeCondInvalid( $start, $end ) {
87 $pager = $this->getMockForAbstractClass( RangeChronologicalPager::class );
88 $this->assertEquals( null, $pager->getDateRangeCond( $start, $end ) );
89 }
90
92 return [
93 [ '-2016-12-01', '2017-12-01', ],
94 [ '2016-12-01', '-2017-12-01', ],
95 [ 'abcdefghij', 'klmnopqrstu', ],
96 ];
97 }
98
99}
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Base class that store and restore the Language objects.
Database $db
Primary database.
assertArrayEquals(array $expected, array $actual, $ordered=false, $named=false)
Assert that two arrays are equal.
Test class for RangeChronologicalPagerTest logic.
testGetDateCond( $inputYear, $inputMonth, $inputDay, $expected)
getDateRangeCondProvider()
Data provider in [ start, end, [ expected output has start condition, has end cond ] ] format.
getDateCondProvider()
Data provider in [ input year, input month, input day, expected timestamp output ] format.
testGetDateRangeCond( $start, $end, $expected)
addQuotes( $s)
Adds quotes and backslashes.
timestamp( $ts=0)
Convert a timestamp in one of the formats accepted by wfTimestamp() to the format used for inserting ...
const DB_MASTER
Definition defines.php:26