11<?php
22namespace phpbu \App \Backup \Sync ;
33
4+ use Kunnu \Dropbox \Models \FileMetadata ;
5+ use Kunnu \Dropbox \Models \MetadataCollection ;
6+ use phpbu \App \Backup \Target ;
47use phpbu \App \BaseMockery ;
8+ use phpbu \App \Result ;
59use PHPUnit \Framework \TestCase ;
610
711/**
@@ -27,6 +31,8 @@ public function testSetUpOk()
2731 $ dropbox = new Dropbox ();
2832 $ dropbox ->setup ([
2933 'token ' => 'this-is-no-token ' ,
34+ 'appKey ' => 'this-is-no-key ' ,
35+ 'appSecret ' => 'this-is-no-secret ' ,
3036 'path ' => '/ '
3137 ]);
3238
@@ -44,16 +50,18 @@ public function testSlasherizePath()
4450
4551 $ dropbox = new Dropbox ();
4652 $ dropbox ->setup ([
47- 'token ' => 'this-is-no-token ' ,
48- 'path ' => 'foo '
53+ 'token ' => 'this-is-no-token ' ,
54+ 'appKey ' => 'this-is-no-key ' ,
55+ 'appSecret ' => 'this-is-no-secret ' ,
56+ 'path ' => 'foo '
4957 ]);
5058
51- $ resultStub = $ this ->createMock (\ phpbu \ App \ Result::class);
59+ $ resultStub = $ this ->createMock (Result::class);
5260 $ resultStub ->expects ($ this ->once ())
5361 ->method ('debug ' )
5462 ->with ($ this ->equalTo ($ msg ));
5563
56- $ targetStub = $ this ->createMock (\ phpbu \ App \ Backup \ Target::class);
64+ $ targetStub = $ this ->createMock (Target::class);
5765
5866 $ dropbox ->simulate ($ targetStub , $ resultStub );
5967 }
@@ -64,10 +72,10 @@ public function testSlasherizePath()
6472 public function testSync ()
6573 {
6674 $ target = $ this ->createTargetMock ('foo.txt ' , 'foo.txt.gz ' );
67- $ result = $ this ->createMock (\ phpbu \ App \ Result::class);
75+ $ result = $ this ->createMock (Result::class);
6876 $ result ->expects ($ this ->once ())->method ('debug ' );
6977
70- $ metaMock = $ this ->createMock (\ Kunnu \ Dropbox \ Models \ FileMetadata::class);
78+ $ metaMock = $ this ->createMock (FileMetadata::class);
7179 $ metaMock ->expects ($ this ->once ())->method ('getSize ' )->willReturn (12345678 );
7280
7381 $ clientMock = $ this ->createMock (\Kunnu \Dropbox \Dropbox::class);
@@ -77,8 +85,10 @@ public function testSync()
7785 $ dropbox ->method ('createClient ' )->willReturn ($ clientMock );
7886
7987 $ dropbox ->setup ([
80- 'token ' => 'this-is-no-token ' ,
81- 'path ' => '/ '
88+ 'token ' => 'this-is-no-token ' ,
89+ 'appKey ' => 'this-is-no-key ' ,
90+ 'appSecret ' => 'this-is-no-secret ' ,
91+ 'path ' => '/ '
8292 ]);
8393
8494 $ dropbox ->sync ($ target , $ result );
@@ -90,13 +100,13 @@ public function testSync()
90100 public function testSyncWithCleanup ()
91101 {
92102 $ target = $ this ->createTargetMock ('foo.txt ' , 'foo.txt.gz ' );
93- $ result = $ this ->createMock (\ phpbu \ App \ Result::class);
103+ $ result = $ this ->createMock (Result::class);
94104 $ result ->expects ($ this ->exactly (2 ))->method ('debug ' );
95105
96- $ metaMock = $ this ->createMock (\ Kunnu \ Dropbox \ Models \ FileMetadata::class);
106+ $ metaMock = $ this ->createMock (FileMetadata::class);
97107 $ metaMock ->expects ($ this ->once ())->method ('getSize ' )->willReturn (12345678 );
98108
99- $ metaCollectionMock = $ this ->createMock (\ Kunnu \ Dropbox \ Models \ MetadataCollection::class);
109+ $ metaCollectionMock = $ this ->createMock (MetadataCollection::class);
100110 $ metaCollectionMock ->expects ($ this ->once ())->method ('getItems ' )->willReturn ([]);
101111
102112 $ clientMock = $ this ->createMock (\Kunnu \Dropbox \Dropbox::class);
@@ -108,6 +118,8 @@ public function testSyncWithCleanup()
108118
109119 $ dropbox ->setup ([
110120 'token ' => 'this-is-no-token ' ,
121+ 'appKey ' => 'this-is-no-key ' ,
122+ 'appSecret ' => 'this-is-no-secret ' ,
111123 'path ' => '/ ' ,
112124 'cleanup.type ' => 'quantity ' ,
113125 'cleanup.amount ' => 99
@@ -123,7 +135,7 @@ public function testSyncFail()
123135 {
124136 $ this ->expectException ('phpbu\App\Exception ' );
125137 $ target = $ this ->createTargetMock ('foo.txt ' , 'foo.txt.gz ' );
126- $ result = $ this ->createMock (\ phpbu \ App \ Result::class);
138+ $ result = $ this ->createMock (Result::class);
127139
128140 $ clientMock = $ this ->createMock (\Kunnu \Dropbox \Dropbox::class);
129141 $ clientMock ->expects ($ this ->once ())->method ('upload ' )->will ($ this ->throwException (new \Exception ));
@@ -132,8 +144,10 @@ public function testSyncFail()
132144 $ dropbox ->method ('createClient ' )->willReturn ($ clientMock );
133145
134146 $ dropbox ->setup ([
135- 'token ' => 'this-is-no-token ' ,
136- 'path ' => '/ '
147+ 'token ' => 'this-is-no-token ' ,
148+ 'appKey ' => 'this-is-no-key ' ,
149+ 'appSecret ' => 'this-is-no-secret ' ,
150+ 'path ' => '/ '
137151 ]);
138152
139153 $ dropbox ->sync ($ target , $ result );
@@ -146,15 +160,17 @@ public function testSimulate()
146160 {
147161 $ dropbox = new Dropbox ();
148162 $ dropbox ->setup ([
149- 'token ' => 'this-is-no-token ' ,
150- 'path ' => '/ '
163+ 'token ' => 'this-is-no-token ' ,
164+ 'appKey ' => 'this-is-no-key ' ,
165+ 'appSecret ' => 'this-is-no-secret ' ,
166+ 'path ' => '/ '
151167 ]);
152168
153- $ resultStub = $ this ->createMock (\ phpbu \ App \ Result::class);
169+ $ resultStub = $ this ->createMock (Result::class);
154170 $ resultStub ->expects ($ this ->once ())
155171 ->method ('debug ' );
156172
157- $ targetStub = $ this ->createMock (\ phpbu \ App \ Backup \ Target::class);
173+ $ targetStub = $ this ->createMock (Target::class);
158174
159175 $ dropbox ->simulate ($ targetStub , $ resultStub );
160176 }
@@ -176,6 +192,12 @@ public function testSetUpNoPath()
176192 {
177193 $ this ->expectException ('phpbu\App\Backup\Sync\Exception ' );
178194 $ dropbox = new Dropbox ();
179- $ dropbox ->setup (['token ' => 'this-is-no-token ' ]);
195+ $ dropbox ->setup (
196+ [
197+ 'token ' => 'this-is-no-token ' ,
198+ 'appKey ' => 'this-is-no-key ' ,
199+ 'appSecret ' => 'this-is-no-secret '
200+ ]
201+ );
180202 }
181203}
0 commit comments