diff options
author | Brian Evans <grknight@gentoo.org> | 2021-07-19 15:20:22 -0400 |
---|---|---|
committer | Brian Evans <grknight@gentoo.org> | 2021-07-19 15:20:22 -0400 |
commit | 9f092345e6bbecfde8c19e6d1490a6031a35f61f (patch) | |
tree | 2abb2398cd0df686e8608e15097ddc58b8995615 /MLEB/Translate/tests/phpunit/api | |
parent | OAuth: Update for fixes and security (diff) | |
download | extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.tar.gz extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.tar.bz2 extensions-9f092345e6bbecfde8c19e6d1490a6031a35f61f.zip |
Update to MLEB 2021.06
Signed-off-by: Brian Evans <grknight@gentoo.org>
Diffstat (limited to 'MLEB/Translate/tests/phpunit/api')
6 files changed, 30 insertions, 65 deletions
diff --git a/MLEB/Translate/tests/phpunit/api/ApiGroupReviewTest.php b/MLEB/Translate/tests/phpunit/api/ApiGroupReviewTest.php index 3eb9c721..fec499fc 100644 --- a/MLEB/Translate/tests/phpunit/api/ApiGroupReviewTest.php +++ b/MLEB/Translate/tests/phpunit/api/ApiGroupReviewTest.php @@ -7,11 +7,9 @@ * @license GPL-2.0-or-later */ -use MediaWiki\Extensions\Translate\SystemUsers\FuzzyBot; +use MediaWiki\Extension\Translate\SystemUsers\FuzzyBot; -/** - * @group Database - */ +/** @group Database */ class ApiGroupReviewTest extends MediaWikiIntegrationTestCase { public function testGetSetState() { $group = new WikiMessageGroup( 'testgroup', 'wewgweg' ); diff --git a/MLEB/Translate/tests/phpunit/api/ApiManageMessageGroupsTest.php b/MLEB/Translate/tests/phpunit/api/ApiManageMessageGroupsTest.php index 9f3af08b..fcbf6414 100644 --- a/MLEB/Translate/tests/phpunit/api/ApiManageMessageGroupsTest.php +++ b/MLEB/Translate/tests/phpunit/api/ApiManageMessageGroupsTest.php @@ -4,22 +4,20 @@ * @license GPL-2.0-or-later */ -use MediaWiki\Extensions\Translate\MessageSync\MessageSourceChange; +use MediaWiki\Extension\Translate\MessageSync\MessageSourceChange; /** * @group medium * @covers ApiManageMessageGroups */ class ApiManageMessageGroupsTest extends ApiTestCase { - /** - * @var User - */ + /** @var User */ protected $user; protected function setUp(): void { parent::setUp(); $this->setMwGlobals( [ - 'wgTranslateCacheDirectory' => __DIR__ . '/../data', + 'wgTranslateCacheDirectory' => $this->getNewTempDirectory(), ] ); $this->setGroupPermissions( 'translate-admin', 'translate-manage', true ); @@ -127,7 +125,7 @@ class ApiManageMessageGroupsTest extends ApiTestCase { 'operation' => 'new', 'changesetName' => MessageChangeStorage::DEFAULT_NAME, 'changesetModified' => time() - ], null, $this->user, 'csrf' + ], null, $this->user, 'csrf' ); $sourceChanges = MessageChangeStorage::getGroupChanges( $filePath, 'testgroup-api' ); @@ -169,21 +167,10 @@ class ApiManageMessageGroupsTest extends ApiTestCase { 'operation' => 'new', 'changesetName' => MessageChangeStorage::DEFAULT_NAME, 'changesetModified' => $date->getTimestamp(), - ], null, $this->user, 'csrf' + ], null, $this->user, 'csrf' ); } - public static function tearDownAfterClass() : void { - parent::tearDownAfterClass(); - - global $wgTranslateCacheDirectory; - $tmp = $wgTranslateCacheDirectory; - $wgTranslateCacheDirectory = __DIR__ . '/../data'; - $filePath = self::getStoragePath(); - unlink( $filePath ); - $wgTranslateCacheDirectory = $tmp; - } - private static function getStoragePath() { return MessageChangeStorage::getCdbPath( MessageChangeStorage::DEFAULT_NAME ); } diff --git a/MLEB/Translate/tests/phpunit/api/ApiQueryManageMessageGroupsTest.php b/MLEB/Translate/tests/phpunit/api/ApiQueryManageMessageGroupsTest.php index bb4b440c..8b044d43 100644 --- a/MLEB/Translate/tests/phpunit/api/ApiQueryManageMessageGroupsTest.php +++ b/MLEB/Translate/tests/phpunit/api/ApiQueryManageMessageGroupsTest.php @@ -4,22 +4,20 @@ * @license GPL-2.0-or-later */ -use MediaWiki\Extensions\Translate\MessageSync\MessageSourceChange; +use MediaWiki\Extension\Translate\MessageSync\MessageSourceChange; /** * @group medium * @covers ApiQueryManageMessageGroups */ class ApiQueryManageMessageGroupsTest extends ApiTestCase { - /** - * @var User - */ + /** @var User */ protected $user; protected function setUp(): void { parent::setUp(); $this->setMwGlobals( [ - 'wgTranslateCacheDirectory' => __DIR__ . '/../data' + 'wgTranslateCacheDirectory' => $this->getNewTempDirectory() ] ); $this->setGroupPermissions( 'translate-admin', 'translate-manage', true ); @@ -49,7 +47,7 @@ class ApiQueryManageMessageGroupsTest extends ApiTestCase { 'mmggroupId' => 'testgroup-api', 'mmgmessageKey' => 'keyAdded1', 'mmgchangesetName' => MessageChangeStorage::DEFAULT_NAME, - ], null, false, $this->user + ], null, false, $this->user ); $apiRespose = $data[0]['query']['managemessagegroups'][0]; @@ -109,15 +107,4 @@ class ApiQueryManageMessageGroupsTest extends ApiTestCase { MessageChangeStorage::writeChanges( $changeData, self::getStoragePath() ); } - - public static function tearDownAfterClass() : void { - parent::tearDownAfterClass(); - - global $wgTranslateCacheDirectory; - $tmp = $wgTranslateCacheDirectory; - $wgTranslateCacheDirectory = __DIR__ . '/../data'; - $filePath = self::getStoragePath(); - unlink( $filePath ); - $wgTranslateCacheDirectory = $tmp; - } } diff --git a/MLEB/Translate/tests/phpunit/api/ApiQueryMessageCollectionTest.php b/MLEB/Translate/tests/phpunit/api/ApiQueryMessageCollectionTest.php index 354fbaea..4e7d3825 100644 --- a/MLEB/Translate/tests/phpunit/api/ApiQueryMessageCollectionTest.php +++ b/MLEB/Translate/tests/phpunit/api/ApiQueryMessageCollectionTest.php @@ -5,11 +5,9 @@ * @license GPL-2.0-or-later */ -/** - * @group medium - */ +/** @group medium */ class ApiQueryMessageCollectionTest extends ApiTestCase { - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->setTemporaryHook( diff --git a/MLEB/Translate/tests/phpunit/api/ApiQueryMessageGroupsTest.php b/MLEB/Translate/tests/phpunit/api/ApiQueryMessageGroupsTest.php index bc797a83..227072f0 100644 --- a/MLEB/Translate/tests/phpunit/api/ApiQueryMessageGroupsTest.php +++ b/MLEB/Translate/tests/phpunit/api/ApiQueryMessageGroupsTest.php @@ -6,12 +6,10 @@ * @license GPL-2.0-or-later */ -/** - * @group medium - */ +/** @group medium */ class ApiQueryMessageGroupsTest extends ApiTestCase { - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->setMwGlobals( [ @@ -72,14 +70,14 @@ class ApiQueryMessageGroupsTest extends ApiTestCase { $this->assertCount( 2, $items, 'Only the two groups specified are in the api' ); $this->assertStringEndsWith( 'id', $items[0]['id'] ); $this->assertStringEndsWith( 'id', $items[1]['id'] ); - $this->assertSame( $items[0]['label'], 'thelabel' ); - $this->assertSame( $items[1]['label'], 'thelabel' ); - $this->assertSame( $items[0]['exists'], true ); - $this->assertSame( $items[1]['exists'], true ); - $this->assertSame( $items[0]['namespace'], 5 ); - $this->assertSame( $items[1]['namespace'], 5 ); - $this->assertSame( $items[0]['class'], WikiMessageGroup::class ); - $this->assertSame( $items[1]['class'], WikiMessageGroup::class ); + $this->assertSame( 'thelabel', $items[0]['label'] ); + $this->assertSame( 'thelabel', $items[1]['label'] ); + $this->assertTrue( $items[0]['exists'] ); + $this->assertTrue( $items[1]['exists'] ); + $this->assertSame( 5, $items[0]['namespace'] ); + $this->assertSame( 5, $items[1]['namespace'] ); + $this->assertSame( WikiMessageGroup::class, $items[0]['class'] ); + $this->assertSame( WikiMessageGroup::class, $items[1]['class'] ); } public function testAPIFilterAccuracy() { @@ -119,12 +117,12 @@ class ApiQueryMessageGroupsTest extends ApiTestCase { $item = $data['query']['messagegroups'][0]; $this->assertCount( 5, $item ); - $this->assertSame( $item['id'], $id ); - $this->assertSame( $item['label'], 'thelabel' ); - $this->assertSame( $item['exists'], true ); + $this->assertSame( $id, $item['id'] ); + $this->assertSame( 'thelabel', $item['label'] ); + $this->assertTrue( $item['exists'] ); $this->assertStringEndsWith( 'id', $item['id'] ); // theid, anotherid - $this->assertSame( $item['namespace'], 5 ); - $this->assertSame( $item['class'], WikiMessageGroup::class ); + $this->assertSame( 5, $item['namespace'] ); + $this->assertSame( WikiMessageGroup::class, $item['class'] ); } } diff --git a/MLEB/Translate/tests/phpunit/api/ApiTranslationReviewTest.php b/MLEB/Translate/tests/phpunit/api/ApiTranslationReviewTest.php index 3e98e97e..b0ae1eff 100644 --- a/MLEB/Translate/tests/phpunit/api/ApiTranslationReviewTest.php +++ b/MLEB/Translate/tests/phpunit/api/ApiTranslationReviewTest.php @@ -1,6 +1,5 @@ <?php /** - * * @file * @author Niklas Laxström * @license GPL-2.0-or-later @@ -8,11 +7,9 @@ use MediaWiki\MediaWikiServices; -/** - * @group Database - */ +/** @group Database */ class ApiTranslationReviewTest extends MediaWikiIntegrationTestCase { - protected function setUp() : void { + protected function setUp(): void { parent::setUp(); $this->setMwGlobals( [ |