3
3
namespace BabyMarkt \DeepL \integration ;
4
4
5
5
use BabyMarkt \DeepL \DeepL ;
6
- use PHPUnit_Framework_TestCase ;
6
+ use PHPUnit \ Framework \ TestCase ;
7
7
use ReflectionClass ;
8
8
9
9
/**
12
12
* @package BabyMarkt\DeepL
13
13
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
14
14
*/
15
- class DeepLApiTest extends PHPUnit_Framework_TestCase
15
+ class DeepLApiTest extends TestCase
16
16
{
17
17
/**
18
18
* DeepL Auth Key.
@@ -24,7 +24,7 @@ class DeepLApiTest extends PHPUnit_Framework_TestCase
24
24
/**
25
25
* Setup DeepL Auth Key.
26
26
*/
27
- public static function setUpBeforeClass ()
27
+ public static function setUpBeforeClass (): void
28
28
{
29
29
parent ::setUpBeforeClass ();
30
30
@@ -62,7 +62,7 @@ protected static function getMethod($className, $methodName)
62
62
public function testTranslateSuccess ()
63
63
{
64
64
if (self ::$ authKey === false ) {
65
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
65
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
66
66
}
67
67
68
68
$ deepl = new DeepL (self ::$ authKey );
@@ -72,7 +72,7 @@ public function testTranslateSuccess()
72
72
73
73
$ translatedText = $ deepl ->translate ($ germanText );
74
74
75
- $ this -> assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
75
+ self :: assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
76
76
}
77
77
78
78
/**
@@ -81,7 +81,7 @@ public function testTranslateSuccess()
81
81
public function testTranslateV1Success ()
82
82
{
83
83
if (self ::$ authKey === false ) {
84
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
84
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
85
85
}
86
86
87
87
$ deepl = new DeepL (self ::$ authKey , 1 );
@@ -91,7 +91,7 @@ public function testTranslateV1Success()
91
91
92
92
$ translatedText = $ deepl ->translate ($ germanText );
93
93
94
- $ this -> assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
94
+ self :: assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
95
95
}
96
96
97
97
/**
@@ -100,12 +100,12 @@ public function testTranslateV1Success()
100
100
public function testTranslateWrongVersion ()
101
101
{
102
102
if (self ::$ authKey === false ) {
103
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
103
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
104
104
}
105
105
$ germanText = 'Hallo Welt ' ;
106
106
$ deepl = new DeepL (self ::$ authKey , 3 );
107
107
108
- $ this ->setExpectedException ('\BabyMarkt\DeepL\DeepLException ' );
108
+ $ this ->expectException ('\BabyMarkt\DeepL\DeepLException ' );
109
109
110
110
$ deepl ->translate ($ germanText );
111
111
}
@@ -116,7 +116,7 @@ public function testTranslateWrongVersion()
116
116
public function testTranslateTagHandlingSuccess ()
117
117
{
118
118
if (self ::$ authKey === false ) {
119
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
119
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
120
120
}
121
121
122
122
$ deepl = new DeepL (self ::$ authKey );
@@ -131,7 +131,7 @@ public function testTranslateTagHandlingSuccess()
131
131
'xml '
132
132
);
133
133
134
- $ this -> assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
134
+ self :: assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
135
135
}
136
136
137
137
/**
@@ -140,7 +140,7 @@ public function testTranslateTagHandlingSuccess()
140
140
public function testTranslateIgnoreTagsSuccess ()
141
141
{
142
142
if (self ::$ authKey === false ) {
143
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
143
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
144
144
}
145
145
146
146
$ deepl = new DeepL (self ::$ authKey );
@@ -156,7 +156,7 @@ public function testTranslateIgnoreTagsSuccess()
156
156
array ('strong ' )
157
157
);
158
158
159
- $ this -> assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
159
+ self :: assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
160
160
}
161
161
162
162
/**
@@ -165,14 +165,14 @@ public function testTranslateIgnoreTagsSuccess()
165
165
public function testUsage ()
166
166
{
167
167
if (self ::$ authKey === false ) {
168
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
168
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
169
169
}
170
170
171
171
$ deepl = new DeepL (self ::$ authKey );
172
172
$ response = $ deepl ->usage ();
173
173
174
- $ this -> assertArrayHasKey ('character_count ' , $ response );
175
- $ this -> assertArrayHasKey ('character_limit ' , $ response );
174
+ self :: assertArrayHasKey ('character_count ' , $ response );
175
+ self :: assertArrayHasKey ('character_limit ' , $ response );
176
176
}
177
177
178
178
/**
@@ -181,15 +181,15 @@ public function testUsage()
181
181
public function testLanguages ()
182
182
{
183
183
if (self ::$ authKey === false ) {
184
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
184
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
185
185
}
186
186
187
187
$ deepl = new DeepL (self ::$ authKey );
188
188
$ response = $ deepl ->languages ();
189
189
190
190
foreach ($ response as $ language ) {
191
- $ this -> assertArrayHasKey ('language ' , $ language );
192
- $ this -> assertArrayHasKey ('name ' , $ language );
191
+ self :: assertArrayHasKey ('language ' , $ language );
192
+ self :: assertArrayHasKey ('name ' , $ language );
193
193
}
194
194
}
195
195
@@ -199,15 +199,15 @@ public function testLanguages()
199
199
public function testLanguagesSource ()
200
200
{
201
201
if (self ::$ authKey === false ) {
202
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
202
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
203
203
}
204
204
205
205
$ deepl = new DeepL (self ::$ authKey );
206
206
$ response = $ deepl ->languages ('source ' );
207
207
208
208
foreach ($ response as $ language ) {
209
- $ this -> assertArrayHasKey ('language ' , $ language );
210
- $ this -> assertArrayHasKey ('name ' , $ language );
209
+ self :: assertArrayHasKey ('language ' , $ language );
210
+ self :: assertArrayHasKey ('name ' , $ language );
211
211
}
212
212
}
213
213
@@ -217,15 +217,15 @@ public function testLanguagesSource()
217
217
public function testLanguagesTarget ()
218
218
{
219
219
if (self ::$ authKey === false ) {
220
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
220
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
221
221
}
222
222
223
223
$ deepl = new DeepL (self ::$ authKey );
224
224
$ response = $ deepl ->languages ('target ' );
225
225
226
226
foreach ($ response as $ language ) {
227
- $ this -> assertArrayHasKey ('language ' , $ language );
228
- $ this -> assertArrayHasKey ('name ' , $ language );
227
+ self :: assertArrayHasKey ('language ' , $ language );
228
+ self :: assertArrayHasKey ('name ' , $ language );
229
229
}
230
230
}
231
231
@@ -235,12 +235,12 @@ public function testLanguagesTarget()
235
235
public function testLanguagesFail ()
236
236
{
237
237
if (self ::$ authKey === false ) {
238
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
238
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
239
239
}
240
240
241
241
$ deepl = new DeepL (self ::$ authKey );
242
242
243
- $ this ->setExpectedException ('\BabyMarkt\DeepL\DeepLException ' );
243
+ $ this ->expectException ('\BabyMarkt\DeepL\DeepLException ' );
244
244
245
245
$ deepl ->languages ('fail ' );
246
246
}
@@ -251,7 +251,7 @@ public function testLanguagesFail()
251
251
public function testTranslateWithAllParams ()
252
252
{
253
253
if (self ::$ authKey === false ) {
254
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
254
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
255
255
}
256
256
257
257
$ deepl = new DeepL (self ::$ authKey );
@@ -273,7 +273,7 @@ public function testTranslateWithAllParams()
273
273
array ('p ' ,'br ' ) //$splittingTags
274
274
);
275
275
276
- $ this -> assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
276
+ self :: assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
277
277
}
278
278
279
279
/**
@@ -282,7 +282,7 @@ public function testTranslateWithAllParams()
282
282
public function testTranslateFormality ()
283
283
{
284
284
if (self ::$ authKey === false ) {
285
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
285
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
286
286
}
287
287
288
288
$ deepl = new DeepL (self ::$ authKey );
@@ -298,7 +298,7 @@ public function testTranslateFormality()
298
298
'less ' //$formality
299
299
);
300
300
301
- $ this -> assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
301
+ self :: assertEquals ($ expectedText , $ translatedText [0 ]['text ' ]);
302
302
}
303
303
304
304
/**
@@ -307,13 +307,13 @@ public function testTranslateFormality()
307
307
public function testTranslateFormalityFail ()
308
308
{
309
309
if (self ::$ authKey === false ) {
310
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
310
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
311
311
}
312
312
313
313
$ deepl = new DeepL (self ::$ authKey );
314
314
$ englishText = '<strong>text to do not translate</strong><p>please translate this text</p> ' ;
315
315
316
- $ this -> setExpectedException ('\BabyMarkt\DeepL\DeepLException ' );
316
+ self :: setExpectedException ('\BabyMarkt\DeepL\DeepLException ' );
317
317
318
318
$ deepl ->translate (
319
319
$ englishText ,
@@ -332,7 +332,7 @@ public function testTranslateFormalityFail()
332
332
public function testTranslateWithHTML ()
333
333
{
334
334
if (self ::$ authKey === false ) {
335
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
335
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
336
336
}
337
337
338
338
$ deepl = new DeepL (self ::$ authKey );
@@ -367,7 +367,7 @@ public function testTranslateWithHTML()
367
367
array ('p ' )
368
368
);
369
369
370
- $ this -> assertEquals ($ expectedArray , $ translatedText );
370
+ self :: assertEquals ($ expectedArray , $ translatedText );
371
371
}
372
372
373
373
/**
@@ -376,12 +376,12 @@ public function testTranslateWithHTML()
376
376
public function testTranslateWithNotSupportedSourceLanguage ()
377
377
{
378
378
if (self ::$ authKey === false ) {
379
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
379
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
380
380
}
381
381
382
382
$ deepl = new DeepL (self ::$ authKey );
383
383
384
- $ this ->setExpectedException ('\BabyMarkt\DeepL\DeepLException ' );
384
+ $ this ->expectException ('\BabyMarkt\DeepL\DeepLException ' );
385
385
$ deepl ->translate ('some txt ' , 'dk ' , 'de ' );
386
386
}
387
387
@@ -391,12 +391,12 @@ public function testTranslateWithNotSupportedSourceLanguage()
391
391
public function testTranslateWithNotSupportedDestinationLanguage ()
392
392
{
393
393
if (self ::$ authKey === false ) {
394
- $ this -> markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
394
+ self :: markTestSkipped ('DeepL Auth Key (DEEPL_AUTH_KEY) is not configured. ' );
395
395
}
396
396
397
397
$ deepl = new DeepL (self ::$ authKey );
398
398
399
- $ this ->setExpectedException ('\BabyMarkt\DeepL\DeepLException ' );
399
+ $ this ->expectException ('\BabyMarkt\DeepL\DeepLException ' );
400
400
$ deepl ->translate ('some txt ' , 'en ' , 'dk ' );
401
401
}
402
402
}
0 commit comments