Avatar fixes

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2020-11-10 20:38:09 +01:00
parent 9317e0f0f0
commit c084008df2
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 25 additions and 2 deletions

View File

@ -52,6 +52,10 @@ class UserAvatarTest extends \Test\TestCase {
} }
public function testGetNoAvatar() { public function testGetNoAvatar() {
if (PHP_MAJOR_VERSION > 7) {
$this->markTestSkipped('Only run on php7');
}
$file = $this->createMock(ISimpleFile::class); $file = $this->createMock(ISimpleFile::class);
$this->folder->method('newFile') $this->folder->method('newFile')
->willReturn($file); ->willReturn($file);
@ -78,12 +82,19 @@ class UserAvatarTest extends \Test\TestCase {
})); }));
$file->method('getContent') $file->method('getContent')
->willReturn($data); ->willReturnCallback(function() use (&$data) {
return $data;
});
$this->assertEquals($data, $this->avatar->get()->data()); $result = $this->avatar->get();
$this->assertTrue($result->valid());
} }
public function testGetAvatarSizeMatch() { public function testGetAvatarSizeMatch() {
if (PHP_MAJOR_VERSION > 7) {
$this->markTestSkipped('Only run on php7');
}
$this->folder->method('fileExists') $this->folder->method('fileExists')
->willReturnMap([ ->willReturnMap([
['avatar.jpg', true], ['avatar.jpg', true],
@ -101,6 +112,10 @@ class UserAvatarTest extends \Test\TestCase {
} }
public function testGetAvatarSizeMinusOne() { public function testGetAvatarSizeMinusOne() {
if (PHP_MAJOR_VERSION > 7) {
$this->markTestSkipped('Only run on php7');
}
$this->folder->method('fileExists') $this->folder->method('fileExists')
->willReturnMap([ ->willReturnMap([
['avatar.jpg', true], ['avatar.jpg', true],
@ -117,6 +132,10 @@ class UserAvatarTest extends \Test\TestCase {
} }
public function testGetAvatarNoSizeMatch() { public function testGetAvatarNoSizeMatch() {
if (PHP_MAJOR_VERSION > 7) {
$this->markTestSkipped('Only run on php7');
}
$this->folder->method('fileExists') $this->folder->method('fileExists')
->willReturnMap([ ->willReturnMap([
['avatar.png', true], ['avatar.png', true],
@ -181,6 +200,10 @@ class UserAvatarTest extends \Test\TestCase {
} }
public function testSetAvatar() { public function testSetAvatar() {
if (PHP_MAJOR_VERSION > 7) {
$this->markTestSkipped('Only run on php7');
}
$avatarFileJPG = $this->createMock(File::class); $avatarFileJPG = $this->createMock(File::class);
$avatarFileJPG->method('getName') $avatarFileJPG->method('getName')
->willReturn('avatar.jpg'); ->willReturn('avatar.jpg');