/** * {@inheritdoc} */ public function calculateSortPriority(User $perspective) { $points = 0; if ($this->isShortlyWritten()) { $points += self::SIMPLE_SORT_CRITERION; } $points += $perspective->follows($this->author->getCredentials()->getUsername()) ? self::HIGH_SORT_CRITERION : self::NORMAL_SORT_CRITERION; if ($this->isCurrent()) { $points += self::NORMAL_SORT_CRITERION; } $id = $perspective->getId(); if ($this->isMarked($id)) { $points += self::HIGH_SORT_CRITERION; } if ($this->isMarkedInComments($id)) { $points += self::NORMAL_SORT_CRITERION; } return $points; }
public function testFollowNewUser() { $target = User::fromDTO(new CreateUserDTO('foo', 'bar', '*****@*****.**')); $user = new User(new Credentials('Ma27', 'test-pwd'), new UserDetails('*****@*****.**', new \DateTime(), new \DateTime())); $user->follow($target); $this->assertTrue($user->follows('foo')); $this->assertCount(1, $user->getFollowing()); }