diff --git a/includes/ApiQueryPageImages.php b/includes/ApiQueryPageImages.php index 3c20367..e863342 100644 --- a/includes/ApiQueryPageImages.php +++ b/includes/ApiQueryPageImages.php @@ -7,6 +7,7 @@ use ApiQuery; use ApiQueryBase; use MediaWiki\MediaWikiServices; use Title; +use Wikimedia\ParamValidator\ParamValidator; use Wikimedia\ParamValidator\TypeDef\IntegerDef; /** @@ -225,33 +226,33 @@ class ApiQueryPageImages extends ApiQueryBase { public function getAllowedParams() { return [ 'prop' => [ - ApiBase::PARAM_TYPE => [ 'thumbnail', 'name', 'original' ], - ApiBase::PARAM_ISMULTI => true, - ApiBase::PARAM_DFLT => 'thumbnail|name', + ParamValidator::PARAM_TYPE => [ 'thumbnail', 'name', 'original' ], + ParamValidator::PARAM_ISMULTI => true, + ParamValidator::PARAM_DEFAULT => 'thumbnail|name', ], 'thumbsize' => [ - ApiBase::PARAM_TYPE => 'integer', - ApiBase::PARAM_DFLT => 50, + ParamValidator::PARAM_TYPE => 'integer', + ParamValidator::PARAM_DEFAULT => 50, ], 'limit' => [ - ApiBase::PARAM_DFLT => 50, - ApiBase::PARAM_TYPE => 'limit', + ParamValidator::PARAM_DEFAULT => 50, + ParamValidator::PARAM_TYPE => 'limit', IntegerDef::PARAM_MIN => 1, IntegerDef::PARAM_MAX => 50, IntegerDef::PARAM_MAX2 => 100, ], 'license' => [ - ApiBase::PARAM_TYPE => [ PageImages::LICENSE_FREE, PageImages::LICENSE_ANY ], - ApiBase::PARAM_ISMULTI => false, - ApiBase::PARAM_DFLT => $this->getConfig()->get( 'PageImagesAPIDefaultLicense' ), + ParamValidator::PARAM_TYPE => [ PageImages::LICENSE_FREE, PageImages::LICENSE_ANY ], + ParamValidator::PARAM_ISMULTI => false, + ParamValidator::PARAM_DEFAULT => $this->getConfig()->get( 'PageImagesAPIDefaultLicense' ), ], 'continue' => [ - ApiBase::PARAM_TYPE => 'integer', + ParamValidator::PARAM_TYPE => 'integer', ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', ], 'langcode' => [ - ApiBase::PARAM_TYPE => 'string', - ApiBase::PARAM_DFLT => null + ParamValidator::PARAM_TYPE => 'string', + ParamValidator::PARAM_DEFAULT => null ] ]; } diff --git a/tests/phpunit/ApiQueryPageImagesTest.php b/tests/phpunit/ApiQueryPageImagesTest.php index ed1aecd..023c91d 100644 --- a/tests/phpunit/ApiQueryPageImagesTest.php +++ b/tests/phpunit/ApiQueryPageImagesTest.php @@ -2,11 +2,11 @@ namespace PageImages\Tests; -use ApiBase; use PageImages\ApiQueryPageImages; use PageImages\PageImages; use PHPUnit\Framework\TestCase; use Title; +use Wikimedia\ParamValidator\ParamValidator; use Wikimedia\ParamValidator\TypeDef\IntegerDef; use Wikimedia\Rdbms\FakeResultWrapper; use Wikimedia\TestingAccessWrapper; @@ -67,15 +67,15 @@ class ApiQueryPageImagesTest extends TestCase { $this->assertNotEmpty( $params ); $this->assertContainsOnly( 'array', $params ); $this->assertArrayHasKey( 'limit', $params ); - $this->assertSame( 50, $params['limit'][ApiBase::PARAM_DFLT] ); - $this->assertSame( 'limit', $params['limit'][ApiBase::PARAM_TYPE] ); + $this->assertSame( 50, $params['limit'][ParamValidator::PARAM_DEFAULT] ); + $this->assertSame( 'limit', $params['limit'][ParamValidator::PARAM_TYPE] ); $this->assertSame( 1, $params['limit'][IntegerDef::PARAM_MIN] ); $this->assertSame( 50, $params['limit'][IntegerDef::PARAM_MAX] ); $this->assertSame( 100, $params['limit'][IntegerDef::PARAM_MAX2] ); $this->assertArrayHasKey( 'license', $params ); - $this->assertSame( [ 'free', 'any' ], $params['license'][ApiBase::PARAM_TYPE] ); - $this->assertSame( 'free', $params['license'][ApiBase::PARAM_DFLT] ); - $this->assertFalse( $params['license'][ApiBase::PARAM_ISMULTI] ); + $this->assertSame( [ 'free', 'any' ], $params['license'][ParamValidator::PARAM_TYPE] ); + $this->assertSame( 'free', $params['license'][ParamValidator::PARAM_DEFAULT] ); + $this->assertFalse( $params['license'][ParamValidator::PARAM_ISMULTI] ); } /**