MediaWiki REL1_31
ContribsPagerTest.php
Go to the documentation of this file.
1<?php
2
8 private $pager;
9
10 function setUp() {
12 $this->pager = new ContribsPager( $context, [
13 'start' => '2017-01-01',
14 'end' => '2017-02-02',
15 ] );
16
17 parent::setUp();
18 }
19
26 public function testDateFilterOptionProcessing( $inputOpts, $expectedOpts ) {
27 $this->assertArraySubset( $expectedOpts, ContribsPager::processDateFilter( $inputOpts ) );
28 }
29
30 public static function dateFilterOptionProcessingProvider() {
31 return [
32 [ [ 'start' => '2016-05-01',
33 'end' => '2016-06-01',
34 'year' => null,
35 'month' => null ],
36 [ 'start' => '2016-05-01',
37 'end' => '2016-06-01' ] ],
38 [ [ 'start' => '2016-05-01',
39 'end' => '2016-06-01',
40 'year' => '',
41 'month' => '' ],
42 [ 'start' => '2016-05-01',
43 'end' => '2016-06-01' ] ],
44 [ [ 'start' => '2016-05-01',
45 'end' => '2016-06-01',
46 'year' => '2012',
47 'month' => '5' ],
48 [ 'start' => '',
49 'end' => '2012-05-31' ] ],
50 [ [ 'start' => '',
51 'end' => '',
52 'year' => '2012',
53 'month' => '5' ],
54 [ 'start' => '',
55 'end' => '2012-05-31' ] ],
56 [ [ 'start' => '',
57 'end' => '',
58 'year' => '2012',
59 'month' => '' ],
60 [ 'start' => '',
61 'end' => '2012-12-31' ] ],
62 ];
63 }
64
69 public function testQueryableRanges( $ipRange ) {
70 $this->setMwGlobals( [
71 'wgRangeContributionsCIDRLimit' => [
72 'IPv4' => 16,
73 'IPv6' => 32,
74 ],
75 ] );
76
77 $this->assertTrue(
78 $this->pager->isQueryableRange( $ipRange ),
79 "$ipRange is a queryable IP range"
80 );
81 }
82
83 public function provideQueryableRanges() {
84 return [
85 [ '116.17.184.5/32' ],
86 [ '0.17.184.5/16' ],
87 [ '2000::/32' ],
88 [ '2001:db8::/128' ],
89 ];
90 }
91
96 public function testUnqueryableRanges( $ipRange ) {
97 $this->setMwGlobals( [
98 'wgRangeContributionsCIDRLimit' => [
99 'IPv4' => 16,
100 'IPv6' => 32,
101 ],
102 ] );
103
104 $this->assertFalse(
105 $this->pager->isQueryableRange( $ipRange ),
106 "$ipRange is not a queryable IP range"
107 );
108 }
109
110 public function provideUnqueryableRanges() {
111 return [
112 [ '116.17.184.5/33' ],
113 [ '0.17.184.5/15' ],
114 [ '2000::/31' ],
115 [ '2001:db8::/9999' ],
116 ];
117 }
118}
static dateFilterOptionProcessingProvider()
testQueryableRanges( $ipRange)
ContribsPager::isQueryableRange provideQueryableRanges.
testDateFilterOptionProcessing( $inputOpts, $expectedOpts)
ContribsPager::processDateFilter dateFilterOptionProcessingProvider.
testUnqueryableRanges( $ipRange)
ContribsPager::isQueryableRange provideUnqueryableRanges.
static processDateFilter(array $opts)
Set up date filter options, given request data.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Group all the pieces relevant to the context of a request into one instance.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition hooks.txt:2811