public function testIterator() { $this->sut->addFan($this->fan); $this->assertEquals(1, $this->sut->getFanCount()); $this->assertTrue($this->sut->hasFan($this->fan)); $it = $this->sut->getFanIterator(); $first = $it->key(); $this->assertEquals($this->fan->getNickname(), $first); }
/** * Update the author's avatar with a given GD image resource * Persists the image file and update the property of Author * !! No persistence on Author, only edge effect !! * * @param AuthorInterface $author the author to update * @param resource $imageResource a GD image resource * * @throws \InvalidArgumentException * @throws \RuntimeException */ public function updateAvatar(AuthorInterface $author, $imageResource) { if (!is_resource($imageResource)) { throw new \InvalidArgumentException('The image is not a valid resource'); } try { // always the same name $avatarName = sha1('avatar' . $author->getNickname()) . '.jpeg'; $this->storage->upsertResource($avatarName, $imageResource); } catch (\Exception $e) { throw new \RuntimeException('Unable to save avatar'); } $author->setAvatar($avatarName); }
public function isLastCommenter(AuthorInterface $author) { if (count($this->commentary)) { return $author->isEqual($this->commentary[0]->getAuthor()); } return false; }