public function testGetSetState()
 {
     $group = new WikiMessageGroup('testgroup', 'wewgweg');
     $ok = ApiGroupReview::changeState($group, 'fi', 'newstate', FuzzyBot::getUser());
     $this->assertTrue($ok, 'state was changed');
     $state = ApiGroupReview::getState($group, 'fi');
     $this->assertEquals('newstate', $state, 'state was changed to expected value');
     $ok = ApiGroupReview::changeState($group, 'fi', 'newstate', FuzzyBot::getUser());
     $this->assertFalse($ok, 'state was not changed again');
 }
 /**
  * @group Broken
  * This tests fails regularly on WMF CI but haven't been able to reproduce locally.
  */
 public function testHooks()
 {
     $user = new MockSuperUser();
     $group = MessageGroups::getGroup('group-trans');
     // In the beginning...
     $currentState = ApiGroupReview::getState($group, 'fi');
     $this->assertEquals(false, $currentState, 'groups start from unset state');
     // First translation
     $title = Title::newFromText('MediaWiki:key1/fi');
     $page = WikiPage::factory($title);
     $content = ContentHandler::makeContent('trans1', $title);
     $status = $page->doEditContent($content, __METHOD__, 0, false, $user);
     self::runJobs();
     $currentState = ApiGroupReview::getState($group, 'fi');
     $this->assertEquals('inprogress', $currentState, 'in progress after first translation');
     // First review
     ApiTranslationReview::doReview($user, self::getRevision($status), __METHOD__);
     self::runJobs();
     $currentState = ApiGroupReview::getState($group, 'fi');
     $this->assertEquals('inprogress', $currentState, 'in progress while untranslated messages');
     // Second translation
     $title = Title::newFromText('MediaWiki:key2/fi');
     $page = WikiPage::factory($title);
     $content = ContentHandler::makeContent('trans2', $title);
     $status = $page->doEditContent($content, __METHOD__, 0, false, $user);
     self::runJobs();
     $currentState = ApiGroupReview::getState($group, 'fi');
     $this->assertEquals('proofreading', $currentState, 'proofreading after second translation');
     // Second review
     ApiTranslationReview::doReview($user, self::getRevision($status), __METHOD__);
     self::runJobs();
     $currentState = ApiGroupReview::getState($group, 'fi');
     $this->assertEquals('ready', $currentState, 'ready when all proofread');
     // Change to translation
     $title = Title::newFromText('MediaWiki:key1/fi');
     $page = WikiPage::factory($title);
     $content = ContentHandler::makeContent('trans1 updated', $title);
     $page->doEditContent($content, __METHOD__, 0, false, $user);
     self::runJobs();
     $currentState = ApiGroupReview::getState($group, 'fi');
     $this->assertEquals('proofreading', $currentState, 'back to proofreading after translation changed');
 }