From 22da16ded433300cf38e81477584bf62b6ecb8ec Mon Sep 17 00:00:00 2001 From: Sebastian Feldmann Date: Fri, 15 Nov 2024 16:29:55 +0100 Subject: [PATCH] Fix Dropbox tests --- tests/phpbu/Backup/Sync/DropboxTest.php | 60 +++++++++++++++++-------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/tests/phpbu/Backup/Sync/DropboxTest.php b/tests/phpbu/Backup/Sync/DropboxTest.php index 54d3e443..f1f2b4e8 100644 --- a/tests/phpbu/Backup/Sync/DropboxTest.php +++ b/tests/phpbu/Backup/Sync/DropboxTest.php @@ -1,7 +1,11 @@ setup([ 'token' => 'this-is-no-token', + 'appKey' => 'this-is-no-key', + 'appSecret' => 'this-is-no-secret', 'path' => '/' ]); @@ -44,16 +50,18 @@ public function testSlasherizePath() $dropbox = new Dropbox(); $dropbox->setup([ - 'token' => 'this-is-no-token', - 'path' => 'foo' + 'token' => 'this-is-no-token', + 'appKey' => 'this-is-no-key', + 'appSecret' => 'this-is-no-secret', + 'path' => 'foo' ]); - $resultStub = $this->createMock(\phpbu\App\Result::class); + $resultStub = $this->createMock(Result::class); $resultStub->expects($this->once()) ->method('debug') ->with($this->equalTo($msg)); - $targetStub = $this->createMock(\phpbu\App\Backup\Target::class); + $targetStub = $this->createMock(Target::class); $dropbox->simulate($targetStub, $resultStub); } @@ -64,10 +72,10 @@ public function testSlasherizePath() public function testSync() { $target = $this->createTargetMock('foo.txt', 'foo.txt.gz'); - $result = $this->createMock(\phpbu\App\Result::class); + $result = $this->createMock(Result::class); $result->expects($this->once())->method('debug'); - $metaMock = $this->createMock(\Kunnu\Dropbox\Models\FileMetadata::class); + $metaMock = $this->createMock(FileMetadata::class); $metaMock->expects($this->once())->method('getSize')->willReturn(12345678); $clientMock = $this->createMock(\Kunnu\Dropbox\Dropbox::class); @@ -77,8 +85,10 @@ public function testSync() $dropbox->method('createClient')->willReturn($clientMock); $dropbox->setup([ - 'token' => 'this-is-no-token', - 'path' => '/' + 'token' => 'this-is-no-token', + 'appKey' => 'this-is-no-key', + 'appSecret' => 'this-is-no-secret', + 'path' => '/' ]); $dropbox->sync($target, $result); @@ -90,13 +100,13 @@ public function testSync() public function testSyncWithCleanup() { $target = $this->createTargetMock('foo.txt', 'foo.txt.gz'); - $result = $this->createMock(\phpbu\App\Result::class); + $result = $this->createMock(Result::class); $result->expects($this->exactly(2))->method('debug'); - $metaMock = $this->createMock(\Kunnu\Dropbox\Models\FileMetadata::class); + $metaMock = $this->createMock(FileMetadata::class); $metaMock->expects($this->once())->method('getSize')->willReturn(12345678); - $metaCollectionMock = $this->createMock(\Kunnu\Dropbox\Models\MetadataCollection::class); + $metaCollectionMock = $this->createMock(MetadataCollection::class); $metaCollectionMock->expects($this->once())->method('getItems')->willReturn([]); $clientMock = $this->createMock(\Kunnu\Dropbox\Dropbox::class); @@ -108,6 +118,8 @@ public function testSyncWithCleanup() $dropbox->setup([ 'token' => 'this-is-no-token', + 'appKey' => 'this-is-no-key', + 'appSecret' => 'this-is-no-secret', 'path' => '/', 'cleanup.type' => 'quantity', 'cleanup.amount' => 99 @@ -123,7 +135,7 @@ public function testSyncFail() { $this->expectException('phpbu\App\Exception'); $target = $this->createTargetMock('foo.txt', 'foo.txt.gz'); - $result = $this->createMock(\phpbu\App\Result::class); + $result = $this->createMock(Result::class); $clientMock = $this->createMock(\Kunnu\Dropbox\Dropbox::class); $clientMock->expects($this->once())->method('upload')->will($this->throwException(new \Exception)); @@ -132,8 +144,10 @@ public function testSyncFail() $dropbox->method('createClient')->willReturn($clientMock); $dropbox->setup([ - 'token' => 'this-is-no-token', - 'path' => '/' + 'token' => 'this-is-no-token', + 'appKey' => 'this-is-no-key', + 'appSecret' => 'this-is-no-secret', + 'path' => '/' ]); $dropbox->sync($target, $result); @@ -146,15 +160,17 @@ public function testSimulate() { $dropbox = new Dropbox(); $dropbox->setup([ - 'token' => 'this-is-no-token', - 'path' => '/' + 'token' => 'this-is-no-token', + 'appKey' => 'this-is-no-key', + 'appSecret' => 'this-is-no-secret', + 'path' => '/' ]); - $resultStub = $this->createMock(\phpbu\App\Result::class); + $resultStub = $this->createMock(Result::class); $resultStub->expects($this->once()) ->method('debug'); - $targetStub = $this->createMock(\phpbu\App\Backup\Target::class); + $targetStub = $this->createMock(Target::class); $dropbox->simulate($targetStub, $resultStub); } @@ -176,6 +192,12 @@ public function testSetUpNoPath() { $this->expectException('phpbu\App\Backup\Sync\Exception'); $dropbox = new Dropbox(); - $dropbox->setup(['token' => 'this-is-no-token']); + $dropbox->setup( + [ + 'token' => 'this-is-no-token', + 'appKey' => 'this-is-no-key', + 'appSecret' => 'this-is-no-secret' + ] + ); } }