2015-12-02 00:08:42 +03: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/>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
use OC\AvatarManager;
|
2016-02-15 22:49:07 +03:00
|
|
|
use Test\Traits\UserTrait;
|
|
|
|
use Test\Traits\MountProviderTrait;
|
2015-12-02 00:08:42 +03:00
|
|
|
|
2016-02-15 22:49:07 +03:00
|
|
|
/**
|
|
|
|
* Class AvatarManagerTest
|
|
|
|
* @group DB
|
|
|
|
*/
|
2015-12-02 00:08:42 +03:00
|
|
|
class AvatarManagerTest extends \Test\TestCase {
|
2016-02-15 22:49:07 +03:00
|
|
|
use UserTrait;
|
|
|
|
use MountProviderTrait;
|
2015-12-02 00:08:42 +03:00
|
|
|
|
2016-02-15 22:49:07 +03:00
|
|
|
/** @var AvatarManager */
|
2015-12-02 00:08:42 +03:00
|
|
|
private $avatarManager;
|
|
|
|
|
2016-02-15 22:49:07 +03:00
|
|
|
/** @var \OC\Files\Storage\Temporary */
|
|
|
|
private $storage;
|
2015-12-02 00:08:42 +03:00
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
2016-02-15 22:49:07 +03: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-02 00:08:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @expectedException Exception
|
|
|
|
* @expectedExceptionMessage user does not exist
|
|
|
|
*/
|
|
|
|
public function testGetAvatarInvalidUser() {
|
|
|
|
$this->avatarManager->getAvatar('invalidUser');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetAvatarValidUser() {
|
2016-02-15 22:49:07 +03:00
|
|
|
$avatar = $this->avatarManager->getAvatar('valid-user');
|
2015-12-02 00:08:42 +03:00
|
|
|
|
2016-02-15 22:49:07 +03:00
|
|
|
$this->assertInstanceOf('\OCP\IAvatar', $avatar);
|
|
|
|
$this->assertFalse($this->storage->file_exists('files'));
|
2015-12-02 00:08:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|