summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2016-08-29 15:17:59 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2016-08-30 09:00:22 +0200
commit6a85882f610ed34c971a1510f5876f0564fd7612 (patch)
treea0d114b0e450f7b35d9eeb423171d4e7fe3d6767 /tests/lib
parent14136295b7568c6e34504c101eba0ee10f5c74fd (diff)
downloadnextcloud-server-6a85882f610ed34c971a1510f5876f0564fd7612.tar.gz
nextcloud-server-6a85882f610ed34c971a1510f5876f0564fd7612.zip
Fix tests
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/AvatarTest.php42
1 files changed, 29 insertions, 13 deletions
diff --git a/tests/lib/AvatarTest.php b/tests/lib/AvatarTest.php
index 0a00f5d5614..f515f0d013f 100644
--- a/tests/lib/AvatarTest.php
+++ b/tests/lib/AvatarTest.php
@@ -20,15 +20,26 @@ class AvatarTest extends \Test\TestCase {
/** @var \OC\User\User | \PHPUnit_Framework_MockObject_MockObject $user */
private $user;
+ /** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ private $config;
+
public function setUp() {
parent::setUp();
- $this->folder = $this->getMock('\OCP\Files\Folder');
+ $this->folder = $this->getMockBuilder('OCP\Files\Folder')->getMock();
/** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */
- $l = $this->getMock('\OCP\IL10N');
+ $l = $this->getMockBuilder('OCP\IL10N')->getMock();
$l->method('t')->will($this->returnArgument(0));
- $this->user = $this->getMockBuilder('\OC\User\User')->disableOriginalConstructor()->getMock();
- $this->avatar = new \OC\Avatar($this->folder, $l, $this->user, $this->getMock('\OCP\ILogger'));
+ $this->user = $this->getMockBuilder('OC\User\User')->disableOriginalConstructor()->getMock();
+ $this->config = $this->getMockBuilder('OCP\IConfig')->getMock();
+
+ $this->avatar = new \OC\Avatar(
+ $this->folder,
+ $l,
+ $this->user,
+ $this->getMockBuilder('\OCP\ILogger')->getMock(),
+ $this->config
+ );
}
public function testGetNoAvatar() {
@@ -44,7 +55,7 @@ class AvatarTest extends \Test\TestCase {
$expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('get')->with('avatar.128.jpg')->willReturn($file);
@@ -59,7 +70,7 @@ class AvatarTest extends \Test\TestCase {
$expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('get')->with('avatar.jpg')->willReturn($file);
@@ -77,7 +88,7 @@ class AvatarTest extends \Test\TestCase {
$expected2 = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected2->resize(32);
- $file = $this->getMock('\OCP\Files\File');
+ $file = $this->getMockBuilder('OCP\Files\File')->getMock();
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('get')
@@ -91,7 +102,7 @@ class AvatarTest extends \Test\TestCase {
}
));
- $newFile = $this->getMock('\OCP\Files\File');
+ $newFile = $this->getMockBuilder('OCP\Files\File')->getMock();
$newFile->expects($this->once())
->method('putContent')
->with($expected2->data());
@@ -129,22 +140,22 @@ class AvatarTest extends \Test\TestCase {
}
public function testSetAvatar() {
- $avatarFileJPG = $this->getMock('\OCP\Files\File');
+ $avatarFileJPG = $this->getMockBuilder('OCP\Files\File')->getMock();
$avatarFileJPG->method('getName')
->willReturn('avatar.jpg');
$avatarFileJPG->expects($this->once())->method('delete');
- $avatarFilePNG = $this->getMock('\OCP\Files\File');
+ $avatarFilePNG = $this->getMockBuilder('OCP\Files\File')->getMock();
$avatarFilePNG->method('getName')
->willReturn('avatar.png');
$avatarFilePNG->expects($this->once())->method('delete');
- $resizedAvatarFile = $this->getMock('\OCP\Files\File');
+ $resizedAvatarFile = $this->getMockBuilder('OCP\Files\File')->getMock();
$resizedAvatarFile->method('getName')
->willReturn('avatar.32.jpg');
$resizedAvatarFile->expects($this->once())->method('delete');
- $nonAvatarFile = $this->getMock('\OCP\Files\File');
+ $nonAvatarFile = $this->getMockBuilder('OCP\Files\File')->getMock();
$nonAvatarFile->method('getName')
->willReturn('avatarX');
$nonAvatarFile->expects($this->never())->method('delete');
@@ -152,7 +163,7 @@ class AvatarTest extends \Test\TestCase {
$this->folder->method('getDirectoryListing')
->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile, $nonAvatarFile]);
- $newFile = $this->getMock('\OCP\Files\File');
+ $newFile = $this->getMockBuilder('OCP\Files\File')->getMock();
$this->folder->expects($this->once())
->method('newFile')
->with('avatar.png')
@@ -163,6 +174,11 @@ class AvatarTest extends \Test\TestCase {
->method('putContent')
->with($image->data());
+ $this->config->expects($this->once())
+ ->method('setUserValue');
+ $this->config->expects($this->once())
+ ->method('getUserValue');
+
// One on remove and once on setting the new avatar
$this->user->expects($this->exactly(2))->method('triggerChange');