public function testDefaultPhoto() { $user = new User(); $profile = new Profile(); $this->assertNull($user->getPhoto(), 'new user have no photo'); $profile->email = '*****@*****.**'; $user->fromProfile($profile); $this->assertSame('https://secure.gravatar.com/avatar/06e36fe8745612d55318be4103414b3e?d=identicon', $user->getPhoto(), 'adding email, create gravatar'); $profile->email = '*****@*****.**'; $user->fromProfile($profile); $this->assertSame('https://secure.gravatar.com/avatar/f8439b029e8a4120be09207e350b8134?d=identicon', $user->getPhoto(), 'changing email, modify gravatar'); $url = 'http://example.com/profile.jpg'; $user->setPhoto($url); $profile->email = '*****@*****.**'; $user->fromProfile($profile); $this->assertSame($url, $user->getPhoto(), 'if photo was manually set, never change it'); $user->setPhoto(null); $this->assertNull($user->getPhoto()); $profile->email = '*****@*****.**'; $user->fromProfile($profile); $this->assertSame('https://secure.gravatar.com/avatar/06e36fe8745612d55318be4103414b3e?d=identicon', $user->getPhoto(), 'can re-set gravatar'); }