Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 4cff3e0

Browse files
author
sathielemann
committed
Added compatibility for PHP 8.0 but dropped compatibility for all PHP Versions < 7.3. This is necessary to get compatibility of PHPUnit and PHP 8.0.
1 parent 3ec0f3a commit 4cff3e0

File tree

4 files changed

+63
-61
lines changed

4 files changed

+63
-61
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
}
2020
],
2121
"require": {
22-
"php": ">=5.3 <8.0",
22+
"php": ">=7.3 <8.1",
2323
"ext-json": "*",
2424
"ext-curl": "*"
2525
},
2626
"require-dev": {
27-
"phpmd/phpmd": "2.4.*",
28-
"phpunit/phpunit": "^4.8",
29-
"squizlabs/php_codesniffer": "^2.9"
27+
"phpmd/phpmd": "^2.10",
28+
"phpunit/phpunit": "^9",
29+
"squizlabs/php_codesniffer": "^3"
3030
},
3131
"autoload": {
3232
"psr-4": {

src/DeepL.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace BabyMarkt\DeepL;
44

5+
use InvalidArgumentException;
6+
57
/**
68
* DeepL API client library
79
*
@@ -133,7 +135,7 @@ public function translate(
133135
array $splittingTags = null
134136
) {
135137
if (is_array($tagHandling)) {
136-
throw new \InvalidArgumentException('$tagHandling must be of type String in V2 of DeepLLibrary');
138+
throw new InvalidArgumentException('$tagHandling must be of type String in V2 of DeepLLibrary');
137139
}
138140
$paramsArray = array(
139141
'text' => $text,

tests/integration/DeepLApiTest.php

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace BabyMarkt\DeepL\integration;
44

55
use BabyMarkt\DeepL\DeepL;
6-
use PHPUnit_Framework_TestCase;
6+
use PHPUnit\Framework\TestCase;
77
use ReflectionClass;
88

99
/**
@@ -12,7 +12,7 @@
1212
* @package BabyMarkt\DeepL
1313
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
1414
*/
15-
class DeepLApiTest extends PHPUnit_Framework_TestCase
15+
class DeepLApiTest extends TestCase
1616
{
1717
/**
1818
* DeepL Auth Key.
@@ -24,7 +24,7 @@ class DeepLApiTest extends PHPUnit_Framework_TestCase
2424
/**
2525
* Setup DeepL Auth Key.
2626
*/
27-
public static function setUpBeforeClass()
27+
public static function setUpBeforeClass(): void
2828
{
2929
parent::setUpBeforeClass();
3030

@@ -62,7 +62,7 @@ protected static function getMethod($className, $methodName)
6262
public function testTranslateSuccess()
6363
{
6464
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.');
6666
}
6767

6868
$deepl = new DeepL(self::$authKey);
@@ -72,7 +72,7 @@ public function testTranslateSuccess()
7272

7373
$translatedText = $deepl->translate($germanText);
7474

75-
$this->assertEquals($expectedText, $translatedText[0]['text']);
75+
self::assertEquals($expectedText, $translatedText[0]['text']);
7676
}
7777

7878
/**
@@ -81,7 +81,7 @@ public function testTranslateSuccess()
8181
public function testTranslateV1Success()
8282
{
8383
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.');
8585
}
8686

8787
$deepl = new DeepL(self::$authKey, 1);
@@ -91,7 +91,7 @@ public function testTranslateV1Success()
9191

9292
$translatedText = $deepl->translate($germanText);
9393

94-
$this->assertEquals($expectedText, $translatedText[0]['text']);
94+
self::assertEquals($expectedText, $translatedText[0]['text']);
9595
}
9696

9797
/**
@@ -100,12 +100,12 @@ public function testTranslateV1Success()
100100
public function testTranslateWrongVersion()
101101
{
102102
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.');
104104
}
105105
$germanText = 'Hallo Welt';
106106
$deepl = new DeepL(self::$authKey, 3);
107107

108-
$this->setExpectedException('\BabyMarkt\DeepL\DeepLException');
108+
$this->expectException('\BabyMarkt\DeepL\DeepLException');
109109

110110
$deepl->translate($germanText);
111111
}
@@ -116,7 +116,7 @@ public function testTranslateWrongVersion()
116116
public function testTranslateTagHandlingSuccess()
117117
{
118118
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.');
120120
}
121121

122122
$deepl = new DeepL(self::$authKey);
@@ -131,7 +131,7 @@ public function testTranslateTagHandlingSuccess()
131131
'xml'
132132
);
133133

134-
$this->assertEquals($expectedText, $translatedText[0]['text']);
134+
self::assertEquals($expectedText, $translatedText[0]['text']);
135135
}
136136

137137
/**
@@ -140,7 +140,7 @@ public function testTranslateTagHandlingSuccess()
140140
public function testTranslateIgnoreTagsSuccess()
141141
{
142142
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.');
144144
}
145145

146146
$deepl = new DeepL(self::$authKey);
@@ -156,7 +156,7 @@ public function testTranslateIgnoreTagsSuccess()
156156
array('strong')
157157
);
158158

159-
$this->assertEquals($expectedText, $translatedText[0]['text']);
159+
self::assertEquals($expectedText, $translatedText[0]['text']);
160160
}
161161

162162
/**
@@ -165,14 +165,14 @@ public function testTranslateIgnoreTagsSuccess()
165165
public function testUsage()
166166
{
167167
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.');
169169
}
170170

171171
$deepl = new DeepL(self::$authKey);
172172
$response = $deepl->usage();
173173

174-
$this->assertArrayHasKey('character_count', $response);
175-
$this->assertArrayHasKey('character_limit', $response);
174+
self::assertArrayHasKey('character_count', $response);
175+
self::assertArrayHasKey('character_limit', $response);
176176
}
177177

178178
/**
@@ -181,15 +181,15 @@ public function testUsage()
181181
public function testLanguages()
182182
{
183183
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.');
185185
}
186186

187187
$deepl = new DeepL(self::$authKey);
188188
$response = $deepl->languages();
189189

190190
foreach ($response as $language) {
191-
$this->assertArrayHasKey('language', $language);
192-
$this->assertArrayHasKey('name', $language);
191+
self::assertArrayHasKey('language', $language);
192+
self::assertArrayHasKey('name', $language);
193193
}
194194
}
195195

@@ -199,15 +199,15 @@ public function testLanguages()
199199
public function testLanguagesSource()
200200
{
201201
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.');
203203
}
204204

205205
$deepl = new DeepL(self::$authKey);
206206
$response = $deepl->languages('source');
207207

208208
foreach ($response as $language) {
209-
$this->assertArrayHasKey('language', $language);
210-
$this->assertArrayHasKey('name', $language);
209+
self::assertArrayHasKey('language', $language);
210+
self::assertArrayHasKey('name', $language);
211211
}
212212
}
213213

@@ -217,15 +217,15 @@ public function testLanguagesSource()
217217
public function testLanguagesTarget()
218218
{
219219
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.');
221221
}
222222

223223
$deepl = new DeepL(self::$authKey);
224224
$response = $deepl->languages('target');
225225

226226
foreach ($response as $language) {
227-
$this->assertArrayHasKey('language', $language);
228-
$this->assertArrayHasKey('name', $language);
227+
self::assertArrayHasKey('language', $language);
228+
self::assertArrayHasKey('name', $language);
229229
}
230230
}
231231

@@ -235,12 +235,12 @@ public function testLanguagesTarget()
235235
public function testLanguagesFail()
236236
{
237237
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.');
239239
}
240240

241241
$deepl = new DeepL(self::$authKey);
242242

243-
$this->setExpectedException('\BabyMarkt\DeepL\DeepLException');
243+
$this->expectException('\BabyMarkt\DeepL\DeepLException');
244244

245245
$deepl->languages('fail');
246246
}
@@ -251,7 +251,7 @@ public function testLanguagesFail()
251251
public function testTranslateWithAllParams()
252252
{
253253
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.');
255255
}
256256

257257
$deepl = new DeepL(self::$authKey);
@@ -273,7 +273,7 @@ public function testTranslateWithAllParams()
273273
array('p','br') //$splittingTags
274274
);
275275

276-
$this->assertEquals($expectedText, $translatedText[0]['text']);
276+
self::assertEquals($expectedText, $translatedText[0]['text']);
277277
}
278278

279279
/**
@@ -282,7 +282,7 @@ public function testTranslateWithAllParams()
282282
public function testTranslateFormality()
283283
{
284284
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.');
286286
}
287287

288288
$deepl = new DeepL(self::$authKey);
@@ -298,7 +298,7 @@ public function testTranslateFormality()
298298
'less' //$formality
299299
);
300300

301-
$this->assertEquals($expectedText, $translatedText[0]['text']);
301+
self::assertEquals($expectedText, $translatedText[0]['text']);
302302
}
303303

304304
/**
@@ -307,13 +307,13 @@ public function testTranslateFormality()
307307
public function testTranslateFormalityFail()
308308
{
309309
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.');
311311
}
312312

313313
$deepl = new DeepL(self::$authKey);
314314
$englishText = '<strong>text to do not translate</strong><p>please translate this text</p>';
315315

316-
$this->setExpectedException('\BabyMarkt\DeepL\DeepLException');
316+
self::setExpectedException('\BabyMarkt\DeepL\DeepLException');
317317

318318
$deepl->translate(
319319
$englishText,
@@ -332,7 +332,7 @@ public function testTranslateFormalityFail()
332332
public function testTranslateWithHTML()
333333
{
334334
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.');
336336
}
337337

338338
$deepl = new DeepL(self::$authKey);
@@ -367,7 +367,7 @@ public function testTranslateWithHTML()
367367
array('p')
368368
);
369369

370-
$this->assertEquals($expectedArray, $translatedText);
370+
self::assertEquals($expectedArray, $translatedText);
371371
}
372372

373373
/**
@@ -376,12 +376,12 @@ public function testTranslateWithHTML()
376376
public function testTranslateWithNotSupportedSourceLanguage()
377377
{
378378
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.');
380380
}
381381

382382
$deepl = new DeepL(self::$authKey);
383383

384-
$this->setExpectedException('\BabyMarkt\DeepL\DeepLException');
384+
$this->expectException('\BabyMarkt\DeepL\DeepLException');
385385
$deepl->translate('some txt', 'dk', 'de');
386386
}
387387

@@ -391,12 +391,12 @@ public function testTranslateWithNotSupportedSourceLanguage()
391391
public function testTranslateWithNotSupportedDestinationLanguage()
392392
{
393393
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.');
395395
}
396396

397397
$deepl = new DeepL(self::$authKey);
398398

399-
$this->setExpectedException('\BabyMarkt\DeepL\DeepLException');
399+
$this->expectException('\BabyMarkt\DeepL\DeepLException');
400400
$deepl->translate('some txt', 'en', 'dk');
401401
}
402402
}

0 commit comments

Comments
 (0)