3 namespace MediaWiki\Tests\SpecialPage
;
5 use MediaWiki\Config\HashConfig
;
6 use MediaWiki\MainConfigNames
;
7 use MediaWiki\SpecialPage\ContributionsRangeTrait
;
8 use MediaWikiIntegrationTestCase
;
9 use Wikimedia\TestingAccessWrapper
;
12 * @covers \MediaWiki\SpecialPage\ContributionsRangeTrait
14 class ContributionsRangeTraitTest
extends MediaWikiIntegrationTestCase
{
16 private function getConfig() {
17 return new HashConfig( [
18 MainConfigNames
::RangeContributionsCIDRLimit
=> [
25 private function getWrappedTrait() {
26 return TestingAccessWrapper
::newFromObject(
27 $this->getMockForTrait( ContributionsRangeTrait
::class )
32 * @dataProvider provideQueryableRanges
34 public function testIsQueryableRange( $ipRange ) {
36 $this->getWrappedTrait()->isQueryableRange( $ipRange, $this->getConfig() ),
40 public static function provideQueryableRanges() {
42 [ '116.17.184.5/32' ],
50 * @dataProvider provideUnqueryableRanges
52 public function testUnqueryableRanges( $ipRange ) {
54 $this->getWrappedTrait()->isQueryableRange( $ipRange, $this->getConfig() ),
58 public static function provideUnqueryableRanges() {
60 [ '116.17.184.5/33' ],
63 [ '2001:db8::/9999' ],
71 * @dataProvider provideValidIPOrQueryableRanges
73 public function testIsValidIPOrQueryableRange( $ip ) {
75 $this->getWrappedTrait()->isValidIPOrQueryableRange( $ip, $this->getConfig() ),
79 public static function provideValidIPOrQueryableRanges() {
89 * @dataProvider provideInvalidIPOrUnqueryableRanges
91 public function testInvalidIPOrUnqueryableRanges( $ip ) {
93 $this->getWrappedTrait()->isValidIPOrQueryableRange( $ip, $this->getConfig() ),
97 public static function provideInvalidIPOrUnqueryableRanges() {
105 public function testGetQueryableRangeLimit() {
111 $config = new HashConfig( [
112 MainConfigNames
::RangeContributionsCIDRLimit
=> $limit
115 $this->assertSame( $limit, $this->getWrappedTrait()->getQueryableRangeLimit( $config ) );