MediaWiki  1.30.0
ContribsPagerTest.php
Go to the documentation of this file.
1 <?php
2 
8  private $pager;
9 
10  function setUp() {
11  $context = new RequestContext();
12  $this->pager = new ContribsPager( $context, [
13  'start' => '2017-01-01',
14  'end' => '2017-02-02',
15  ] );
16 
17  parent::setUp();
18  }
19 
25  public function testDateFilterOptionProcessing( $inputOpts, $expectedOpts ) {
26  $this->assertArraySubset( $expectedOpts, ContribsPager::processDateFilter( $inputOpts ) );
27  }
28 
29  public static function dateFilterOptionProcessingProvider() {
30  return [
31  [ [ 'start' => '2016-05-01',
32  'end' => '2016-06-01',
33  'year' => null,
34  'month' => null ],
35  [ 'start' => '2016-05-01',
36  'end' => '2016-06-01' ] ],
37  [ [ 'start' => '2016-05-01',
38  'end' => '2016-06-01',
39  'year' => '',
40  'month' => '' ],
41  [ 'start' => '2016-05-01',
42  'end' => '2016-06-01' ] ],
43  [ [ 'start' => '2016-05-01',
44  'end' => '2016-06-01',
45  'year' => '2012',
46  'month' => '5' ],
47  [ 'start' => '',
48  'end' => '2012-05-31' ] ],
49  [ [ 'start' => '',
50  'end' => '',
51  'year' => '2012',
52  'month' => '5' ],
53  [ 'start' => '',
54  'end' => '2012-05-31' ] ],
55  [ [ 'start' => '',
56  'end' => '',
57  'year' => '2012',
58  'month' => '' ],
59  [ 'start' => '',
60  'end' => '2012-12-31' ] ],
61  ];
62  }
63 
68  public function testQueryableRanges( $ipRange ) {
69  $this->setMwGlobals( [
70  'wgRangeContributionsCIDRLimit' => [
71  'IPv4' => 16,
72  'IPv6' => 32,
73  ],
74  ] );
75 
76  $this->assertTrue(
77  $this->pager->isQueryableRange( $ipRange ),
78  "$ipRange is a queryable IP range"
79  );
80  }
81 
82  public function provideQueryableRanges() {
83  return [
84  [ '116.17.184.5/32' ],
85  [ '0.17.184.5/16' ],
86  [ '2000::/32' ],
87  [ '2001:db8::/128' ],
88  ];
89  }
90 
95  public function testUnqueryableRanges( $ipRange ) {
96  $this->setMwGlobals( [
97  'wgRangeContributionsCIDRLimit' => [
98  'IPv4' => 16,
99  'IPv6' => 32,
100  ],
101  ] );
102 
103  $this->assertFalse(
104  $this->pager->isQueryableRange( $ipRange ),
105  "$ipRange is not a queryable IP range"
106  );
107  }
108 
109  public function provideUnqueryableRanges() {
110  return [
111  [ '116.17.184.5/33' ],
112  [ '0.17.184.5/15' ],
113  [ '2000::/31' ],
114  [ '2001:db8::/9999' ],
115  ];
116  }
117 }
ContribsPagerTest
Database.
Definition: ContribsPagerTest.php:6
ContribsPagerTest\testDateFilterOptionProcessing
testDateFilterOptionProcessing( $inputOpts, $expectedOpts)
dateFilterOptionProcessingProvider
Definition: ContribsPagerTest.php:25
$context
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:2581
ContribsPagerTest\testQueryableRanges
testQueryableRanges( $ipRange)
ContribsPager::isQueryableRange provideQueryableRanges.
Definition: ContribsPagerTest.php:68
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:672
MediaWikiTestCase
Definition: MediaWikiTestCase.php:15
ContribsPagerTest\testUnqueryableRanges
testUnqueryableRanges( $ipRange)
ContribsPager::isQueryableRange provideUnqueryableRanges.
Definition: ContribsPagerTest.php:95
ContribsPagerTest\$pager
ContribsPager $pager
Definition: ContribsPagerTest.php:8
ContribsPagerTest\provideQueryableRanges
provideQueryableRanges()
Definition: ContribsPagerTest.php:82
ContribsPagerTest\dateFilterOptionProcessingProvider
static dateFilterOptionProcessingProvider()
Definition: ContribsPagerTest.php:29
RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition: RequestContext.php:33
ContribsPagerTest\provideUnqueryableRanges
provideUnqueryableRanges()
Definition: ContribsPagerTest.php:109
ContribsPager
Definition: ContribsPager.php:31
ContribsPager\processDateFilter
static processDateFilter( $opts)
Set up date filter options, given request data.
Definition: ContribsPager.php:661
ContribsPagerTest\setUp
setUp()
Definition: ContribsPagerTest.php:10