1
1
<?php
2
2
namespace phpbu \App \Backup \Sync ;
3
3
4
+ use Kunnu \Dropbox \Models \FileMetadata ;
5
+ use Kunnu \Dropbox \Models \MetadataCollection ;
6
+ use phpbu \App \Backup \Target ;
4
7
use phpbu \App \BaseMockery ;
8
+ use phpbu \App \Result ;
5
9
use PHPUnit \Framework \TestCase ;
6
10
7
11
/**
@@ -27,6 +31,8 @@ public function testSetUpOk()
27
31
$ dropbox = new Dropbox ();
28
32
$ dropbox ->setup ([
29
33
'token ' => 'this-is-no-token ' ,
34
+ 'appKey ' => 'this-is-no-key ' ,
35
+ 'appSecret ' => 'this-is-no-secret ' ,
30
36
'path ' => '/ '
31
37
]);
32
38
@@ -44,16 +50,18 @@ public function testSlasherizePath()
44
50
45
51
$ dropbox = new Dropbox ();
46
52
$ 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 '
49
57
]);
50
58
51
- $ resultStub = $ this ->createMock (\ phpbu \ App \ Result::class);
59
+ $ resultStub = $ this ->createMock (Result::class);
52
60
$ resultStub ->expects ($ this ->once ())
53
61
->method ('debug ' )
54
62
->with ($ this ->equalTo ($ msg ));
55
63
56
- $ targetStub = $ this ->createMock (\ phpbu \ App \ Backup \ Target::class);
64
+ $ targetStub = $ this ->createMock (Target::class);
57
65
58
66
$ dropbox ->simulate ($ targetStub , $ resultStub );
59
67
}
@@ -64,10 +72,10 @@ public function testSlasherizePath()
64
72
public function testSync ()
65
73
{
66
74
$ target = $ this ->createTargetMock ('foo.txt ' , 'foo.txt.gz ' );
67
- $ result = $ this ->createMock (\ phpbu \ App \ Result::class);
75
+ $ result = $ this ->createMock (Result::class);
68
76
$ result ->expects ($ this ->once ())->method ('debug ' );
69
77
70
- $ metaMock = $ this ->createMock (\ Kunnu \ Dropbox \ Models \ FileMetadata::class);
78
+ $ metaMock = $ this ->createMock (FileMetadata::class);
71
79
$ metaMock ->expects ($ this ->once ())->method ('getSize ' )->willReturn (12345678 );
72
80
73
81
$ clientMock = $ this ->createMock (\Kunnu \Dropbox \Dropbox::class);
@@ -77,8 +85,10 @@ public function testSync()
77
85
$ dropbox ->method ('createClient ' )->willReturn ($ clientMock );
78
86
79
87
$ 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 ' => '/ '
82
92
]);
83
93
84
94
$ dropbox ->sync ($ target , $ result );
@@ -90,13 +100,13 @@ public function testSync()
90
100
public function testSyncWithCleanup ()
91
101
{
92
102
$ target = $ this ->createTargetMock ('foo.txt ' , 'foo.txt.gz ' );
93
- $ result = $ this ->createMock (\ phpbu \ App \ Result::class);
103
+ $ result = $ this ->createMock (Result::class);
94
104
$ result ->expects ($ this ->exactly (2 ))->method ('debug ' );
95
105
96
- $ metaMock = $ this ->createMock (\ Kunnu \ Dropbox \ Models \ FileMetadata::class);
106
+ $ metaMock = $ this ->createMock (FileMetadata::class);
97
107
$ metaMock ->expects ($ this ->once ())->method ('getSize ' )->willReturn (12345678 );
98
108
99
- $ metaCollectionMock = $ this ->createMock (\ Kunnu \ Dropbox \ Models \ MetadataCollection::class);
109
+ $ metaCollectionMock = $ this ->createMock (MetadataCollection::class);
100
110
$ metaCollectionMock ->expects ($ this ->once ())->method ('getItems ' )->willReturn ([]);
101
111
102
112
$ clientMock = $ this ->createMock (\Kunnu \Dropbox \Dropbox::class);
@@ -108,6 +118,8 @@ public function testSyncWithCleanup()
108
118
109
119
$ dropbox ->setup ([
110
120
'token ' => 'this-is-no-token ' ,
121
+ 'appKey ' => 'this-is-no-key ' ,
122
+ 'appSecret ' => 'this-is-no-secret ' ,
111
123
'path ' => '/ ' ,
112
124
'cleanup.type ' => 'quantity ' ,
113
125
'cleanup.amount ' => 99
@@ -123,7 +135,7 @@ public function testSyncFail()
123
135
{
124
136
$ this ->expectException ('phpbu\App\Exception ' );
125
137
$ target = $ this ->createTargetMock ('foo.txt ' , 'foo.txt.gz ' );
126
- $ result = $ this ->createMock (\ phpbu \ App \ Result::class);
138
+ $ result = $ this ->createMock (Result::class);
127
139
128
140
$ clientMock = $ this ->createMock (\Kunnu \Dropbox \Dropbox::class);
129
141
$ clientMock ->expects ($ this ->once ())->method ('upload ' )->will ($ this ->throwException (new \Exception ));
@@ -132,8 +144,10 @@ public function testSyncFail()
132
144
$ dropbox ->method ('createClient ' )->willReturn ($ clientMock );
133
145
134
146
$ 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 ' => '/ '
137
151
]);
138
152
139
153
$ dropbox ->sync ($ target , $ result );
@@ -146,15 +160,17 @@ public function testSimulate()
146
160
{
147
161
$ dropbox = new Dropbox ();
148
162
$ 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 ' => '/ '
151
167
]);
152
168
153
- $ resultStub = $ this ->createMock (\ phpbu \ App \ Result::class);
169
+ $ resultStub = $ this ->createMock (Result::class);
154
170
$ resultStub ->expects ($ this ->once ())
155
171
->method ('debug ' );
156
172
157
- $ targetStub = $ this ->createMock (\ phpbu \ App \ Backup \ Target::class);
173
+ $ targetStub = $ this ->createMock (Target::class);
158
174
159
175
$ dropbox ->simulate ($ targetStub , $ resultStub );
160
176
}
@@ -176,6 +192,12 @@ public function testSetUpNoPath()
176
192
{
177
193
$ this ->expectException ('phpbu\App\Backup\Sync\Exception ' );
178
194
$ 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
+ );
180
202
}
181
203
}
0 commit comments