2015-12-01 21:08:42 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Roeland Jago Douma <rullzer@owncloud.com>
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2015, ownCloud, Inc.
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*
|
|
|
|
*/
|
2016-05-19 07:27:21 +00:00
|
|
|
|
|
|
|
namespace Test;
|
|
|
|
|
2015-12-01 21:08:42 +00:00
|
|
|
use OC\AvatarManager;
|
2016-02-15 19:49:07 +00:00
|
|
|
use Test\Traits\UserTrait;
|
|
|
|
use Test\Traits\MountProviderTrait;
|
2015-12-01 21:08:42 +00:00
|
|
|
|
2016-02-15 19:49:07 +00:00
|
|
|
/**
|
|
|
|
* Class AvatarManagerTest
|
|
|
|
* @group DB
|
|
|
|
*/
|
2015-12-01 21:08:42 +00:00
|
|
|
class AvatarManagerTest extends \Test\TestCase {
|
2016-02-15 19:49:07 +00:00
|
|
|
use UserTrait;
|
|
|
|
use MountProviderTrait;
|
2015-12-01 21:08:42 +00:00
|
|
|
|
2016-02-15 19:49:07 +00:00
|
|
|
/** @var AvatarManager */
|
2015-12-01 21:08:42 +00:00
|
|
|
private $avatarManager;
|
|
|
|
|
2016-02-15 19:49:07 +00:00
|
|
|
/** @var \OC\Files\Storage\Temporary */
|
|
|
|
private $storage;
|
2015-12-01 21:08:42 +00:00
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
2016-02-15 19:49:07 +00:00
|
|
|
$this->createUser('valid-user', 'valid-user');
|
|
|
|
|
|
|
|
$this->storage = new \OC\Files\Storage\Temporary();
|
|
|
|
$this->registerMount('valid-user', $this->storage, '/valid-user/');
|
|
|
|
|
|
|
|
$this->avatarManager = \OC::$server->getAvatarManager();
|
2015-12-01 21:08:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-05-19 07:27:21 +00:00
|
|
|
* @expectedException \Exception
|
2015-12-01 21:08:42 +00:00
|
|
|
* @expectedExceptionMessage user does not exist
|
|
|
|
*/
|
|
|
|
public function testGetAvatarInvalidUser() {
|
|
|
|
$this->avatarManager->getAvatar('invalidUser');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetAvatarValidUser() {
|
2016-02-15 19:49:07 +00:00
|
|
|
$avatar = $this->avatarManager->getAvatar('valid-user');
|
2015-12-01 21:08:42 +00:00
|
|
|
|
2016-02-15 19:49:07 +00:00
|
|
|
$this->assertInstanceOf('\OCP\IAvatar', $avatar);
|
|
|
|
$this->assertFalse($this->storage->file_exists('files'));
|
2015-12-01 21:08:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|