Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2015-03-12 13:13:12 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2015-08-18 15:48:19 +0300
commit65cf4028cc418eba6ddd2aee124de8626148cb57 (patch)
tree1b1416ef3ffde655a50858ac44390e3d3a0721ae /tests/core
parentffff156965beaf52a22a024e240bf56a9f8d2b44 (diff)
Move avatarcontroller towards Node Api
Diffstat (limited to 'tests/core')
-rw-r--r--tests/core/avatar/avatarcontrollertest.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/core/avatar/avatarcontrollertest.php b/tests/core/avatar/avatarcontrollertest.php
index 952e013bb8f..e8fb977fae1 100644
--- a/tests/core/avatar/avatarcontrollertest.php
+++ b/tests/core/avatar/avatarcontrollertest.php
@@ -26,6 +26,8 @@ use OCP\AppFramework\IAppContainer;
use OC\Files\Filesystem;
use OCP\AppFramework\Http;
use OCP\Image;
+use OCP\Files\Folder;
+use OCP\Files\File;
/**
* Overwrite is_uploaded_file in this namespace to allow proper unit testing of
@@ -72,6 +74,8 @@ class AvatarControllerTest extends \Test\TestCase {
->disableOriginalConstructor()->getMock();
$this->container['Request'] = $this->getMockBuilder('OCP\IRequest')
->disableOriginalConstructor()->getMock();
+ $this->container['UserFolder'] = $this->getMockBuilder('OCP\Files\Folder')
+ ->disableOriginalConstructor()->getMock();
$this->avatarMock = $this->getMockBuilder('OCP\IAvatar')
->disableOriginalConstructor()->getMock();
@@ -89,10 +93,6 @@ class AvatarControllerTest extends \Test\TestCase {
OC::$server->getUserManager()->createUser($this->user, $this->user);
$this->loginAsUser($this->user);
- // Create Cache dir
- $view = new \OC\Files\View('/'.$this->user);
- $view->mkdir('cache');
-
// Configure userMock
$this->userMock->method('getDisplayName')->willReturn($this->user);
$this->userMock->method('getUID')->willReturn($this->user);
@@ -259,8 +259,7 @@ class AvatarControllerTest extends \Test\TestCase {
$this->assertTrue($copyRes);
//Create file in cache
- $view = new \OC\Files\View('/'.$this->user.'/cache');
- $view->file_put_contents('avatar_upload', file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
//Create request return
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => [filesize(OC::$SERVERROOT.'/tests/data/testimage.jpg')]];
@@ -298,8 +297,7 @@ class AvatarControllerTest extends \Test\TestCase {
$this->assertTrue($copyRes);
//Create file in cache
- $view = new \OC\Files\View('/'.$this->user.'/cache');
- $view->file_put_contents('avatar_upload', file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'));
+ $this->container['Cache']->method('get')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.gif'));
//Create request return
$reqRet = ['error' => [0], 'tmp_name' => [$fileName], 'size' => filesize(OC::$SERVERROOT.'/tests/data/testimage.gif')];
@@ -317,9 +315,11 @@ class AvatarControllerTest extends \Test\TestCase {
* Test posting avatar from existing file
*/
public function testPostAvatarFromFile() {
- //Create file in cache
- $view = new \OC\Files\View('/'.$this->user.'/files');
- $view->file_put_contents('avatar.jpg', file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ //Mock node API call
+ $file = $this->getMockBuilder('OCP\Files\File')
+ ->disableOriginalConstructor()->getMock();
+ $file->method('getContent')->willReturn(file_get_contents(OC::$SERVERROOT.'/tests/data/testimage.jpg'));
+ $this->container['UserFolder']->method('get')->willReturn($file);
//Create request return
$response = $this->avatarController->postAvatar('avatar.jpg');