diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-09-02 11:09:42 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2016-09-06 09:33:48 +0200 |
commit | 1a052015433f194591dd9c0d9c5f725d1d52c921 (patch) | |
tree | 88dfc1376dcae5a773de56c7d2607bb19d8937d5 /tests | |
parent | 4d3b92e68782ce7ab3ef58b6be715a76df2a6955 (diff) | |
download | nextcloud-server-1a052015433f194591dd9c0d9c5f725d1d52c921.tar.gz nextcloud-server-1a052015433f194591dd9c0d9c5f725d1d52c921.zip |
Fix getMock Avatar
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/AvatarTest.php | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/tests/lib/AvatarTest.php b/tests/lib/AvatarTest.php index f515f0d013f..7f012c895fd 100644 --- a/tests/lib/AvatarTest.php +++ b/tests/lib/AvatarTest.php @@ -8,7 +8,11 @@ namespace Test; +use OCP\Files\File; use OCP\Files\Folder; +use OCP\IConfig; +use OCP\IL10N; +use OCP\ILogger; class AvatarTest extends \Test\TestCase { /** @var Folder | \PHPUnit_Framework_MockObject_MockObject */ @@ -26,18 +30,18 @@ class AvatarTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->folder = $this->getMockBuilder('OCP\Files\Folder')->getMock(); + $this->folder = $this->createMock(Folder::class); /** @var \OCP\IL10N | \PHPUnit_Framework_MockObject_MockObject $l */ - $l = $this->getMockBuilder('OCP\IL10N')->getMock(); + $l = $this->createMock(IL10N::class); $l->method('t')->will($this->returnArgument(0)); $this->user = $this->getMockBuilder('OC\User\User')->disableOriginalConstructor()->getMock(); - $this->config = $this->getMockBuilder('OCP\IConfig')->getMock(); + $this->config = $this->createMock(IConfig::class); $this->avatar = new \OC\Avatar( $this->folder, $l, $this->user, - $this->getMockBuilder('\OCP\ILogger')->getMock(), + $this->createMock(ILogger::class), $this->config ); } @@ -55,7 +59,7 @@ class AvatarTest extends \Test\TestCase { $expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png'); - $file = $this->getMockBuilder('OCP\Files\File')->getMock(); + $file = $this->createMock(File::class); $file->method('getContent')->willReturn($expected->data()); $this->folder->method('get')->with('avatar.128.jpg')->willReturn($file); @@ -70,7 +74,7 @@ class AvatarTest extends \Test\TestCase { $expected = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png'); - $file = $this->getMockBuilder('OCP\Files\File')->getMock(); + $file = $this->createMock(File::class); $file->method('getContent')->willReturn($expected->data()); $this->folder->method('get')->with('avatar.jpg')->willReturn($file); @@ -88,7 +92,7 @@ class AvatarTest extends \Test\TestCase { $expected2 = new \OC_Image(\OC::$SERVERROOT . '/tests/data/testavatar.png'); $expected2->resize(32); - $file = $this->getMockBuilder('OCP\Files\File')->getMock(); + $file = $this->createMock(File::class); $file->method('getContent')->willReturn($expected->data()); $this->folder->method('get') @@ -102,7 +106,7 @@ class AvatarTest extends \Test\TestCase { } )); - $newFile = $this->getMockBuilder('OCP\Files\File')->getMock(); + $newFile = $this->createMock(File::class); $newFile->expects($this->once()) ->method('putContent') ->with($expected2->data()); @@ -140,22 +144,22 @@ class AvatarTest extends \Test\TestCase { } public function testSetAvatar() { - $avatarFileJPG = $this->getMockBuilder('OCP\Files\File')->getMock(); + $avatarFileJPG = $this->createMock(File::class); $avatarFileJPG->method('getName') ->willReturn('avatar.jpg'); $avatarFileJPG->expects($this->once())->method('delete'); - $avatarFilePNG = $this->getMockBuilder('OCP\Files\File')->getMock(); + $avatarFilePNG = $this->createMock(File::class); $avatarFilePNG->method('getName') ->willReturn('avatar.png'); $avatarFilePNG->expects($this->once())->method('delete'); - $resizedAvatarFile = $this->getMockBuilder('OCP\Files\File')->getMock(); + $resizedAvatarFile = $this->createMock(File::class); $resizedAvatarFile->method('getName') ->willReturn('avatar.32.jpg'); $resizedAvatarFile->expects($this->once())->method('delete'); - $nonAvatarFile = $this->getMockBuilder('OCP\Files\File')->getMock(); + $nonAvatarFile = $this->createMock(File::class); $nonAvatarFile->method('getName') ->willReturn('avatarX'); $nonAvatarFile->expects($this->never())->method('delete'); @@ -163,7 +167,7 @@ class AvatarTest extends \Test\TestCase { $this->folder->method('getDirectoryListing') ->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile, $nonAvatarFile]); - $newFile = $this->getMockBuilder('OCP\Files\File')->getMock(); + $newFile = $this->createMock(File::class); $this->folder->expects($this->once()) ->method('newFile') ->with('avatar.png') |