diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-25 22:21:27 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-25 22:21:27 +0100 |
commit | 2ee65f177e4f7e09ad2287f14d564e7068d322fb (patch) | |
tree | 39075e87ea7927e20e8956824cb7c49bf626b178 /tests/lib/Avatar | |
parent | 3cf321fdfc4235a87015a9af2f59c63220016c65 (diff) | |
download | nextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.tar.gz nextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.zip |
Use the shorter phpunit syntax for mocked return values
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Avatar')
-rw-r--r-- | tests/lib/Avatar/UserAvatarTest.php | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php index 43e325b0941..11bb33a9741 100644 --- a/tests/lib/Avatar/UserAvatarTest.php +++ b/tests/lib/Avatar/UserAvatarTest.php @@ -57,18 +57,18 @@ class UserAvatarTest extends \Test\TestCase { ->willReturn($file); $this->folder->method('getFile') - ->will($this->returnCallback(function($path) { + ->willReturnCallback(function($path) { if ($path === 'avatar.64.png') { throw new NotFoundException(); } - })); + }); $this->folder->method('fileExists') - ->will($this->returnCallback(function($path) { + ->willReturnCallback(function($path) { if ($path === 'generated') { return true; } return false; - })); + }); $data = NULL; $file->method('putContent') @@ -85,10 +85,10 @@ class UserAvatarTest extends \Test\TestCase { public function testGetAvatarSizeMatch() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', true], ['avatar.128.jpg', true], - ])); + ]); $expected = new \OC_Image(); $expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png'); @@ -102,9 +102,9 @@ class UserAvatarTest extends \Test\TestCase { public function testGetAvatarSizeMinusOne() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', true], - ])); + ]); $expected = new \OC_Image(); $expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png'); @@ -118,10 +118,10 @@ class UserAvatarTest extends \Test\TestCase { public function testGetAvatarNoSizeMatch() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.png', true], ['avatar.32.png', false], - ])); + ]); $expected = new \OC_Image(); $expected->loadFromFile(\OC::$SERVERROOT . '/tests/data/testavatar.png'); @@ -133,7 +133,7 @@ class UserAvatarTest extends \Test\TestCase { $file->method('getContent')->willReturn($expected->data()); $this->folder->method('getFile') - ->will($this->returnCallback( + ->willReturnCallback( function($path) use ($file) { if ($path === 'avatar.png') { return $file; @@ -141,7 +141,7 @@ class UserAvatarTest extends \Test\TestCase { throw new \OCP\Files\NotFoundException; } } - )); + ); $newFile = $this->createMock(File::class); $newFile->expects($this->once()) @@ -164,19 +164,19 @@ class UserAvatarTest extends \Test\TestCase { public function testExiststJPG() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', true], ['avatar.png', false], - ])); + ]); $this->assertTrue($this->avatar->exists()); } public function testExistsPNG() { $this->folder->method('fileExists') - ->will($this->returnValueMap([ + ->willReturnMap([ ['avatar.jpg', false], ['avatar.png', true], - ])); + ]); $this->assertTrue($this->avatar->exists()); } @@ -282,7 +282,7 @@ class UserAvatarTest extends \Test\TestCase { { /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */ $l = $this->createMock(IL10N::class); - $l->method('t')->will($this->returnArgument(0)); + $l->method('t')->willReturnArgument(0); return new \OC\Avatar\UserAvatar( $this->folder, |