public function testReturnTypes() { $this->assertSame($this->instance->getId(), 42, 'Should return integer value'); $this->assertSame($this->instance->isAuthenticated(), true, 'Should return boolean value'); $this->assertSame($this->instance->getEmail(), '*****@*****.**'); $this->assertSame($this->instance->getRealName(), 'John Doe'); $this->assertSame((string) $this->instance, 'John Doe <*****@*****.**>', 'toString() should return both values as a string.'); }
/** * 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; }