2013-07-30 18:09:54 +04:00
|
|
|
<?php
|
2014-01-02 19:08:08 +04:00
|
|
|
|
2013-07-30 18:09:54 +04: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.
|
|
|
|
*/
|
2015-03-03 14:52:27 +03:00
|
|
|
|
|
|
|
use OC\Avatar;
|
|
|
|
|
2014-11-11 00:59:50 +03:00
|
|
|
class Test_Avatar extends \Test\TestCase {
|
2015-04-07 13:46:07 +03:00
|
|
|
private static $trashBinStatus;
|
2013-07-30 18:09:54 +04:00
|
|
|
|
2015-04-07 13:46:07 +03:00
|
|
|
/** @var @var string */
|
2014-01-02 19:08:08 +04:00
|
|
|
private $user;
|
|
|
|
|
2014-11-11 00:59:50 +03:00
|
|
|
protected function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->user = $this->getUniqueID();
|
2014-01-02 19:08:08 +04:00
|
|
|
$storage = new \OC\Files\Storage\Temporary(array());
|
|
|
|
\OC\Files\Filesystem::mount($storage, array(), '/' . $this->user . '/');
|
|
|
|
}
|
|
|
|
|
2015-04-07 13:46:07 +03:00
|
|
|
public static function setUpBeforeClass() {
|
|
|
|
self::$trashBinStatus = \OC_App::isEnabled('files_trashbin');
|
|
|
|
\OC_App::disable('files_trashbin');
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function tearDownAfterClass() {
|
|
|
|
if (self::$trashBinStatus) {
|
|
|
|
\OC_App::enable('files_trashbin');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-19 14:15:48 +04:00
|
|
|
public function testAvatar() {
|
2013-08-30 11:00:37 +04:00
|
|
|
|
2015-03-03 14:52:27 +03:00
|
|
|
$avatar = new Avatar($this->user);
|
2013-08-28 18:39:00 +04:00
|
|
|
|
2013-09-09 18:57:46 +04:00
|
|
|
$this->assertEquals(false, $avatar->get());
|
2013-07-30 18:09:54 +04:00
|
|
|
|
2014-01-02 19:08:08 +04:00
|
|
|
$expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
|
2013-08-08 19:03:19 +04:00
|
|
|
$expected->resize(64);
|
2013-10-15 19:23:47 +04:00
|
|
|
$avatar->set($expected->data());
|
2013-09-09 18:57:46 +04:00
|
|
|
$this->assertEquals($expected->data(), $avatar->get()->data());
|
2013-07-30 18:09:54 +04:00
|
|
|
|
2013-09-09 18:57:46 +04:00
|
|
|
$avatar->remove();
|
|
|
|
$this->assertEquals(false, $avatar->get());
|
2013-07-30 18:09:54 +04:00
|
|
|
}
|
2013-11-22 02:40:25 +04:00
|
|
|
|
|
|
|
public function testAvatarApi() {
|
|
|
|
$avatarManager = \OC::$server->getAvatarManager();
|
2014-01-02 19:08:08 +04:00
|
|
|
$avatar = $avatarManager->getAvatar($this->user);
|
2013-11-22 02:40:25 +04:00
|
|
|
|
|
|
|
$this->assertEquals(false, $avatar->get());
|
|
|
|
|
2014-01-02 19:08:08 +04:00
|
|
|
$expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
|
2013-11-22 02:40:25 +04: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 18:09:54 +04:00
|
|
|
}
|