public function testImportDataObject()
 {
     $array = MediaWikiContributor::importDataObject($this->user_json_string);
     $this->assertTrue(is_array($array), 'Valid JSON string with expected keys should return an array');
 }
 /**
  * set Author data object.
  *
  * @param Author $author               The Author of the change
  * @param bool   $validate_contributor Whether or not we should make sure the MediaWiki contributor node data match our JSON user cache
  */
 public function setContributor(MediaWikiContributor $author, $validate_contributor = true)
 {
     $this->validate_contributor = $validate_contributor;
     $u1 = $this->getContributorId();
     $u2 = $author->getId();
     if ($u2 !== $u1 && $this->validate_contributor === true) {
         throw new RuntimeException(sprintf('Contributor %s is not the same as %s', $u1, $u2));
     }
     $this->author = $author;
     $this->contributor_id = $this->author->getId();
     $this->contributor_name = $this->author->getName();
     if ($this->author->getName() === 'Anonymous' && !empty($this->contributor_name)) {
         $this->author->setName($this->contributor_name);
     }
     if ($this->author->getRealName() === 'Anonymous Author' && !empty($this->contributor_name)) {
         $this->author->setRealName($this->contributor_name);
     }
     return $this;
 }