summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/Translate/tests/phpunit/Synchronization/GroupSynchronizationCacheTest.php')
-rw-r--r--MLEB/Translate/tests/phpunit/Synchronization/GroupSynchronizationCacheTest.php67
1 files changed, 66 insertions, 1 deletions
diff --git a/MLEB/Translate/tests/phpunit/Synchronization/GroupSynchronizationCacheTest.php b/MLEB/Translate/tests/phpunit/Synchronization/GroupSynchronizationCacheTest.php
index c9ccc0a5..74083af1 100644
--- a/MLEB/Translate/tests/phpunit/Synchronization/GroupSynchronizationCacheTest.php
+++ b/MLEB/Translate/tests/phpunit/Synchronization/GroupSynchronizationCacheTest.php
@@ -212,7 +212,7 @@ class GroupSynchronizationCacheTest extends MediaWikiIntegrationTestCase {
$fixedGroupSyncResponse = $this->groupSyncCache->syncGroupErrors( $groupId );
$fixedErrorMessages = $fixedGroupSyncResponse->getRemainingMessages();
- $this->assertEquals( count( $errorMessages ) - 1, count( $fixedErrorMessages ) );
+ $this->assertCount( count( $errorMessages ) - 1, $fixedErrorMessages );
}
public function testAddGroupErrorsEmpty() {
@@ -224,6 +224,59 @@ class GroupSynchronizationCacheTest extends MediaWikiIntegrationTestCase {
$this->groupSyncCache->addGroupErrors( $groupSyncResponse );
}
+ public function testGroupHasErrors() {
+ $groupId = 'test-group';
+ $this->addTestGroupError( $groupId );
+ $this->assertTrue( $this->groupSyncCache->groupHasErrors( $groupId ) );
+
+ $this->groupSyncCache->markGroupAsResolved( $groupId );
+ $this->assertFalse( $this->groupSyncCache->groupHasErrors( $groupId ) );
+ }
+
+ public function testGroupInReview() {
+ $groupId = 'test-group';
+ $this->groupSyncCache->markGroupAsInReview( $groupId );
+ $this->assertTrue( $this->groupSyncCache->isGroupInReview( $groupId ) );
+
+ $this->groupSyncCache->markGroupAsInReview( $groupId );
+ $this->assertTrue( $this->groupSyncCache->isGroupInReview( $groupId ) );
+ }
+
+ /** @dataProvider provideExtendGroupExpiryTime */
+ public function testExtendGroupExpiryTime( int $initialExpiryTime, string $expectedCondition ) {
+ $groupId = 'test-group-id';
+ $this->groupSyncCache = $this->getGroupSynchronizationCache( $initialExpiryTime );
+
+ $this->startGroupSync( $groupId, 'hello' );
+
+ $initialExpiryTime = $this->groupSyncCache->getGroupExpiryTime( $groupId );
+
+ $this->groupSyncCache->extendGroupExpiryTime( $groupId );
+
+ $extendedExpiryTime = $this->groupSyncCache->getGroupExpiryTime( $groupId );
+
+ $this->$expectedCondition( $initialExpiryTime, $extendedExpiryTime );
+ }
+
+ public function testExtendInvalidGroupExpiryTime() {
+ $this->expectException( LogicException::class );
+ $this->expectExceptionMessageMatches( '/group that is not being processed/i' );
+
+ $this->groupSyncCache->extendGroupExpiryTime( 'testGroupId' );
+ }
+
+ public function testExtendTimedOutGroupExpiryTime() {
+ $groupSyncCache = $this->getGroupSynchronizationCache( -1 );
+ $this->groupSyncCache = $groupSyncCache;
+
+ $this->expectException( LogicException::class );
+ $this->expectExceptionMessageMatches( '/group that has already expired/i' );
+
+ $groupId = 'test-group-id';
+ $this->startGroupSync( $groupId, 'hello' );
+ $this->groupSyncCache->extendGroupExpiryTime( $groupId );
+ }
+
public function provideGetSynchronizationStatus() {
$groupId = 'hello';
@@ -260,6 +313,18 @@ class GroupSynchronizationCacheTest extends MediaWikiIntegrationTestCase {
];
}
+ public function provideExtendGroupExpiryTime() {
+ yield 'group expiry time is extended when it is about to expire' => [
+ 10,
+ 'assertGreaterThan'
+ ];
+
+ yield 'group expiry time is not extended when it is not going to expire' => [
+ 5000,
+ 'assertEquals'
+ ];
+ }
+
private function getMessageParam( string $groupId, string $title ): MessageUpdateParameter {
return new MessageUpdateParameter( [
'fuzzy' => true,