function smarty_function_gravatarUrl(array $params) { $email = $params['email']; $size = isset($params['size']) ? $params['size'] : null; $default = isset($params['default']) ? $params['default'] : null; $gravatar = new CMService_Gravatar(); return $gravatar->getUrl($email, $size, $default); }
public function testGetUrl() { $gravatar = new CMService_Gravatar(); $this->assertSame('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0', $gravatar->getUrl('*****@*****.**')); $this->assertSame('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=140', $gravatar->getUrl('*****@*****.**', 140)); $this->assertSame('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=http%3A%2F%2Fexample.com%2Fdefault.jpg', $gravatar->getUrl('*****@*****.**', null, 'http://example.com/default.jpg')); $this->assertSame('https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=140&d=http%3A%2F%2Fexample.com%2Fdefault.jpg', $gravatar->getUrl('*****@*****.**', 140, 'http://example.com/default.jpg')); $this->assertSame('https://secure.gravatar.com/avatar', $gravatar->getUrl(null)); $this->assertSame('https://secure.gravatar.com/avatar?s=140', $gravatar->getUrl(null, 140)); $this->assertSame('http://example.com/default.jpg', $gravatar->getUrl(null, null, 'http://example.com/default.jpg')); $this->assertSame('http://example.com/default.jpg', $gravatar->getUrl(null, 140, 'http://example.com/default.jpg')); }