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
path: root/tests
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-07-11 12:56:39 +0300
committerGitHub <noreply@github.com>2022-07-11 12:56:39 +0300
commit16b5e6bc7f78f796eb7d8a4e1bd70cdc838dc119 (patch)
tree8163de44309f3bb370236ebb731a1e5b39ad09bc /tests
parent22cc36ec60ea0329efafbb7aafca1595194e59c9 (diff)
parentec5cbdeb7ffb87c0169c39e6f44846e819b41f14 (diff)
Merge pull request #32973 from nextcloud/cleanup/avatar-code
Cleanup avatar related code
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Avatar/AvatarManagerTest.php7
-rw-r--r--tests/lib/Avatar/UserAvatarTest.php24
2 files changed, 16 insertions, 15 deletions
diff --git a/tests/lib/Avatar/AvatarManagerTest.php b/tests/lib/Avatar/AvatarManagerTest.php
index ae9c0e1671f..06ff4086f72 100644
--- a/tests/lib/Avatar/AvatarManagerTest.php
+++ b/tests/lib/Avatar/AvatarManagerTest.php
@@ -37,6 +37,7 @@ use OCP\Files\SimpleFS\ISimpleFolder;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUser;
+use OC\User\User;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
@@ -101,7 +102,7 @@ class AvatarManagerTest extends \Test\TestCase {
}
public function testGetAvatarForSelf() {
- $user = $this->createMock(IUser::class);
+ $user = $this->createMock(User::class);
$user
->expects($this->any())
->method('getUID')
@@ -151,7 +152,7 @@ class AvatarManagerTest extends \Test\TestCase {
}
public function testGetAvatarValidUserDifferentCasing() {
- $user = $this->createMock(IUser::class);
+ $user = $this->createMock(User::class);
$this->userManager->expects($this->once())
->method('get')
->with('vaLid-USER')
@@ -225,7 +226,7 @@ class AvatarManagerTest extends \Test\TestCase {
->method('getUser')
->willReturn($requestingUser);
- $user = $this->createMock(IUser::class);
+ $user = $this->createMock(User::class);
$user
->expects($this->once())
->method('getUID')
diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php
index dd5f25163f2..b2b4ebba343 100644
--- a/tests/lib/Avatar/UserAvatarTest.php
+++ b/tests/lib/Avatar/UserAvatarTest.php
@@ -57,7 +57,7 @@ class UserAvatarTest extends \Test\TestCase {
->willReturn($file);
$this->folder->method('getFile')
- ->willReturnCallback(function ($path) {
+ ->willReturnCallback(function (string $path) {
if ($path === 'avatar.64.png') {
throw new NotFoundException();
}
@@ -96,7 +96,7 @@ class UserAvatarTest extends \Test\TestCase {
$expected = new \OC_Image();
$expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $file = $this->createMock(File::class);
+ $file = $this->createMock(ISimpleFile::class);
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('getFile')->with('avatar.128.jpg')->willReturn($file);
@@ -112,7 +112,7 @@ class UserAvatarTest extends \Test\TestCase {
$expected = new \OC_Image();
$expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png');
- $file = $this->createMock(File::class);
+ $file = $this->createMock(ISimpleFile::class);
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('getFile')->with('avatar.jpg')->willReturn($file);
@@ -132,7 +132,7 @@ class UserAvatarTest extends \Test\TestCase {
$expected2->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png');
$expected2->resize(32);
- $file = $this->createMock(File::class);
+ $file = $this->createMock(ISimpleFile::class);
$file->method('getContent')->willReturn($expected->data());
$this->folder->method('getFile')
@@ -146,7 +146,7 @@ class UserAvatarTest extends \Test\TestCase {
}
);
- $newFile = $this->createMock(File::class);
+ $newFile = $this->createMock(ISimpleFile::class);
$newFile->expects($this->once())
->method('putContent')
->with($expected2->data());
@@ -258,17 +258,17 @@ class UserAvatarTest extends \Test\TestCase {
}
public function testMixPalette() {
- $colorFrom = new \OC\Color(0, 0, 0);
- $colorTo = new \OC\Color(6, 12, 18);
+ $colorFrom = new \OCP\Color(0, 0, 0);
+ $colorTo = new \OCP\Color(6, 12, 18);
$steps = 6;
- $palette = $this->invokePrivate($this->avatar, 'mixPalette', [$steps, $colorFrom, $colorTo]);
+ $palette = \OCP\Color::mixPalette($steps, $colorFrom, $colorTo);
foreach ($palette as $j => $color) {
// calc increment
- $incR = $colorTo->r / $steps * $j;
- $incG = $colorTo->g / $steps * $j;
- $incB = $colorTo->b / $steps * $j;
+ $incR = $colorTo->red() / $steps * $j;
+ $incG = $colorTo->green() / $steps * $j;
+ $incB = $colorTo->blue() / $steps * $j;
// ensure everything is equal
- $this->assertEquals($color, new \OC\Color($incR, $incG, $incB));
+ $this->assertEquals($color, new \OCP\Color($incR, $incG, $incB));
}
$hashToInt = $this->invokePrivate($this->avatar, 'hashToInt', ['abcdef', 18]);
$this->assertTrue(gettype($hashToInt) === 'integer');