2013-07-30 14:09:54 +00:00
|
|
|
<?php
|
2014-01-02 15:08:08 +00:00
|
|
|
|
2013-07-30 14:09:54 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
class Test_Avatar extends PHPUnit_Framework_TestCase {
|
|
|
|
|
2014-01-02 15:08:08 +00:00
|
|
|
private $user;
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
$this->user = uniqid();
|
|
|
|
$storage = new \OC\Files\Storage\Temporary(array());
|
|
|
|
\OC\Files\Filesystem::mount($storage, array(), '/' . $this->user . '/');
|
|
|
|
}
|
|
|
|
|
2013-08-19 10:15:48 +00:00
|
|
|
public function testAvatar() {
|
2013-08-30 07:00:37 +00:00
|
|
|
|
2014-01-02 15:08:08 +00:00
|
|
|
$avatar = new \OC_Avatar($this->user);
|
2013-08-28 14:39:00 +00:00
|
|
|
|
2013-09-09 14:57:46 +00:00
|
|
|
$this->assertEquals(false, $avatar->get());
|
2013-07-30 14:09:54 +00:00
|
|
|
|
2014-01-02 15:08:08 +00:00
|
|
|
$expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
|
2013-08-08 15:03:19 +00:00
|
|
|
$expected->resize(64);
|
2013-10-15 15:23:47 +00:00
|
|
|
$avatar->set($expected->data());
|
2013-09-09 14:57:46 +00:00
|
|
|
$this->assertEquals($expected->data(), $avatar->get()->data());
|
2013-07-30 14:09:54 +00:00
|
|
|
|
2013-09-09 14:57:46 +00:00
|
|
|
$avatar->remove();
|
|
|
|
$this->assertEquals(false, $avatar->get());
|
2013-07-30 14:09:54 +00:00
|
|
|
}
|
2013-11-21 22:40:25 +00:00
|
|
|
|
|
|
|
public function testAvatarApi() {
|
|
|
|
$avatarManager = \OC::$server->getAvatarManager();
|
2014-01-02 15:08:08 +00:00
|
|
|
$avatar = $avatarManager->getAvatar($this->user);
|
2013-11-21 22:40:25 +00:00
|
|
|
|
|
|
|
$this->assertEquals(false, $avatar->get());
|
|
|
|
|
2014-01-02 15:08:08 +00:00
|
|
|
$expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
|
2013-11-21 22:40:25 +00:00
|
|
|
$expected->resize(64);
|
|
|
|
$avatar->set($expected->data());
|
|
|
|
$this->assertEquals($expected->data(), $avatar->get()->data());
|
|
|
|
|
|
|
|
$avatar->remove();
|
|
|
|
$this->assertEquals(false, $avatar->get());
|
|
|
|
}
|
2013-07-30 14:09:54 +00:00
|
|
|
}
|