4 * Test class for RangeChronologicalPagerTest logic.
8 * @author Geoffrey Mon <geofbot@gmail.com>
10 class RangeChronologicalPagerTest
extends MediaWikiLangTestCase
{
13 * @covers RangeChronologicalPager::getDateCond
14 * @dataProvider getDateCondProvider
16 public function testGetDateCond( $inputYear, $inputMonth, $inputDay, $expected ) {
17 $pager = $this->getMockForAbstractClass( 'RangeChronologicalPager' );
18 $this->assertEquals( $expected, $pager->getDateCond( $inputYear, $inputMonth, $inputDay ) );
22 * Data provider in [ input year, input month, input day, expected timestamp output ] format
24 public function getDateCondProvider() {
26 [ 2016, 12, 5, '20161205235959' ],
27 [ 2016, 12, 31, '20161231235959' ],
28 [ 2016, 12, 1337, '20161231235959' ],
29 [ 2016, 1337, 1337, '20161231235959' ],
30 [ 2016, 1337, -1, '20161231235959' ],
31 [ 2016, 12, 32, '20161231235959' ],
32 [ 2016, 12, -1, '20161231235959' ],
33 [ 2016, -1, -1, '20161231235959' ],
38 * @covers RangeChronologicalPager::getDateRangeCond
39 * @dataProvider getDateRangeCondProvider
41 public function testGetDateRangeCond( $start, $end, $expected ) {
42 $pager = $this->getMockForAbstractClass( 'RangeChronologicalPager' );
43 $this->assertArrayEquals( $expected, $pager->getDateRangeCond( $start, $end ) );
47 * Data provider in [ start, end, [ expected output has start condition, has end cond ] ] format
49 public function getDateRangeCondProvider() {
50 $db = wfGetDB( DB_MASTER
);
57 '>=' . $db->addQuotes( $db->timestamp( '20161201000000' ) ),
58 '<=' . $db->addQuotes( $db->timestamp( '20161203000000' ) ),
65 '<=' . $db->addQuotes( $db->timestamp( '20161203000000' ) ),
72 '>=' . $db->addQuotes( $db->timestamp( '20161201000000' ) ),
80 * @covers RangeChronologicalPager::getDateRangeCond
81 * @dataProvider getDateRangeCondInvalidProvider
83 public function testGetDateRangeCondInvalid( $start, $end ) {
84 $pager = $this->getMockForAbstractClass( 'RangeChronologicalPager' );
85 $this->assertEquals( null, $pager->getDateRangeCond( $start, $end ) );
88 public function getDateRangeCondInvalidProvider() {
90 [ '-2016-12-01', '2017-12-01', ],
91 [ '2016-12-01', '-2017-12-01', ],
92 [ 'abcdefghij', 'klmnopqrstu', ],