summaryrefslogtreecommitdiffstats
path: root/tests/lib/avatar.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@owncloud.com>2015-12-01 22:08:42 +0100
committerRoeland Jago Douma <rullzer@owncloud.com>2015-12-01 22:15:43 +0100
commitb00db2c9334874c6062a143de2a6b76b44dca35d (patch)
treedb13d5d23114468e978786cc52031dc31c312584 /tests/lib/avatar.php
parent8931ba4a0d574a05cf4415f2556bdd3ee0388ba9 (diff)
downloadnextcloud-server-b00db2c9334874c6062a143de2a6b76b44dca35d.tar.gz
nextcloud-server-b00db2c9334874c6062a143de2a6b76b44dca35d.zip
DI in avatar code
* DI in avatar code * Use the node API * More unit tests * Unit tests no longer require DB
Diffstat (limited to 'tests/lib/avatar.php')
-rw-r--r--tests/lib/avatar.php94
1 files changed, 0 insertions, 94 deletions
diff --git a/tests/lib/avatar.php b/tests/lib/avatar.php
deleted file mode 100644
index 3fa7dc64547..00000000000
--- a/tests/lib/avatar.php
+++ /dev/null
@@ -1,94 +0,0 @@
-<?php
-
-/**
- * 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.
- */
-
-use OC\Avatar;
-
-/**
- * Class Test_Avatar
- *
- * @group DB
- */
-class Test_Avatar extends \Test\TestCase {
- private static $trashBinStatus;
-
- /** @var @var string */
- private $user;
-
- protected function setUp() {
- parent::setUp();
-
- $this->user = $this->getUniqueID();
- $storage = new \OC\Files\Storage\Temporary(array());
- \OC\Files\Filesystem::mount($storage, array(), '/' . $this->user . '/');
- }
-
- 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');
- }
- }
-
- /**
- * @return array
- */
- public function traversalProvider() {
- return [
- ['Pot\..\entiallyDangerousUsername'],
- ['Pot/..\entiallyDangerousUsername'],
- ['PotentiallyDangerousUsername/..'],
- ['PotentiallyDangerousUsername\../'],
- ['/../PotentiallyDangerousUsername'],
- ];
- }
-
- /**
- * @dataProvider traversalProvider
- * @expectedException \Exception
- * @expectedExceptionMessage Username may not contain slashes
- * @param string $dangerousUsername
- */
- public function testAvatarTraversal($dangerousUsername) {
- new Avatar($dangerousUsername);
- }
-
- public function testAvatar() {
-
- $avatar = new Avatar($this->user);
-
- $this->assertEquals(false, $avatar->get());
-
- $expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $expected->resize(64);
- $avatar->set($expected->data());
- $this->assertEquals($expected->data(), $avatar->get()->data());
-
- $avatar->remove();
- $this->assertEquals(false, $avatar->get());
- }
-
- public function testAvatarApi() {
- $avatarManager = \OC::$server->getAvatarManager();
- $avatar = $avatarManager->getAvatar($this->user);
-
- $this->assertEquals(false, $avatar->get());
-
- $expected = new OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $expected->resize(64);
- $avatar->set($expected->data());
- $this->assertEquals($expected->data(), $avatar->get()->data());
-
- $avatar->remove();
- $this->assertEquals(false, $avatar->get());
- }
-}