Skip to content

Commit 655fe61

Browse files
committed
tests: fix deprecation warnings for PHP 8.5 in tests
1 parent 8e01673 commit 655fe61

6 files changed

Lines changed: 57 additions & 19 deletions

File tree

tests/Unit/Api/AbstractApi/DeleteTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public function testDeleteWithHttpClient(): void
3333
$api = new class ($client) extends AbstractApi {};
3434

3535
$method = new ReflectionMethod($api, 'delete');
36-
$method->setAccessible(true);
36+
if (PHP_VERSION_ID < 80100) {
37+
$method->setAccessible(true);
38+
}
3739

3840
// Perform the tests
3941
$return = $method->invoke($api, 'path.xml');
@@ -54,7 +56,9 @@ public function testXmlDecodingFromDeleteMethod(string $response, string $expect
5456
$api = new class ($client) extends AbstractApi {};
5557

5658
$method = new ReflectionMethod($api, 'delete');
57-
$method->setAccessible(true);
59+
if (PHP_VERSION_ID < 80100) {
60+
$method->setAccessible(true);
61+
}
5862

5963
// Perform the tests
6064
$return = $method->invoke($api, 'path.xml');

tests/Unit/Api/AbstractApi/GetTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function testGetWithHttpClient(): void
3434
$api = new class ($client) extends AbstractApi {};
3535

3636
$method = new ReflectionMethod($api, 'get');
37-
$method->setAccessible(true);
37+
if (PHP_VERSION_ID < 80100) {
38+
$method->setAccessible(true);
39+
}
3840

3941
// Perform the tests
4042
$this->assertSame(
@@ -56,7 +58,9 @@ public function testJsonDecodingFromGetMethod(string $response, ?bool $decode, $
5658
$api = new class ($client) extends AbstractApi {};
5759

5860
$method = new ReflectionMethod($api, 'get');
59-
$method->setAccessible(true);
61+
if (PHP_VERSION_ID < 80100) {
62+
$method->setAccessible(true);
63+
}
6064

6165
// Perform the tests
6266
if (is_bool($decode)) {
@@ -91,7 +95,9 @@ public function testXmlDecodingFromGetMethod(string $response, ?bool $decode, st
9195
$api = new class ($client) extends AbstractApi {};
9296

9397
$method = new ReflectionMethod($api, 'get');
94-
$method->setAccessible(true);
98+
if (PHP_VERSION_ID < 80100) {
99+
$method->setAccessible(true);
100+
}
95101

96102
// Perform the tests
97103
$return = $method->invoke($api, 'path', $decode);

tests/Unit/Api/AbstractApi/PostTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function testPostWithHttpClient(): void
3434
$api = new class ($client) extends AbstractApi {};
3535

3636
$method = new ReflectionMethod($api, 'post');
37-
$method->setAccessible(true);
37+
if (PHP_VERSION_ID < 80100) {
38+
$method->setAccessible(true);
39+
}
3840

3941
// Perform the tests
4042
$return = $method->invoke($api, 'path.xml', '');
@@ -56,7 +58,9 @@ public function testXmlDecodingFromPostMethod(string $response, string $expected
5658
$api = new class ($client) extends AbstractApi {};
5759

5860
$method = new ReflectionMethod($api, 'post');
59-
$method->setAccessible(true);
61+
if (PHP_VERSION_ID < 80100) {
62+
$method->setAccessible(true);
63+
}
6064

6165
// Perform the tests
6266
$return = $method->invoke($api, 'path.xml', '');

tests/Unit/Api/AbstractApi/PutTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function testPutWithHttpClient(): void
3434
$api = new class ($client) extends AbstractApi {};
3535

3636
$method = new ReflectionMethod($api, 'put');
37-
$method->setAccessible(true);
37+
if (PHP_VERSION_ID < 80100) {
38+
$method->setAccessible(true);
39+
}
3840

3941
// Perform the tests
4042
$return = $method->invoke($api, 'path.xml', '');
@@ -56,7 +58,9 @@ public function testXmlDecodingFromPutMethod(string $response, string $expected)
5658
$api = new class ($client) extends AbstractApi {};
5759

5860
$method = new ReflectionMethod($api, 'put');
59-
$method->setAccessible(true);
61+
if (PHP_VERSION_ID < 80100) {
62+
$method->setAccessible(true);
63+
}
6064

6165
// Perform the tests
6266
$return = $method->invoke($api, 'path.xml', '');

tests/Unit/Api/AbstractApiTest.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public function testCreateWithHttpClientWorks(): void
2525
$api = new class ($client) extends AbstractApi {};
2626

2727
$method = new ReflectionMethod($api, 'getHttpClient');
28-
$method->setAccessible(true);
28+
if (PHP_VERSION_ID < 80100) {
29+
$method->setAccessible(true);
30+
}
2931

3032
$this->assertSame($client, $method->invoke($api));
3133
}
@@ -37,7 +39,9 @@ public function testCreateWitClientWorks(): void
3739
$api = new class ($client) extends AbstractApi {};
3840

3941
$method = new ReflectionMethod($api, 'getHttpClient');
40-
$method->setAccessible(true);
42+
if (PHP_VERSION_ID < 80100) {
43+
$method->setAccessible(true);
44+
}
4145

4246
$this->assertInstanceOf(HttpClient::class, $method->invoke($api));
4347
}
@@ -183,7 +187,9 @@ public function testIsNotNullReturnsCorrectBoolean(bool $expected, $value): void
183187
$api = new class ($client) extends AbstractApi {};
184188

185189
$method = new ReflectionMethod($api, 'isNotNull');
186-
$method->setAccessible(true);
190+
if (PHP_VERSION_ID < 80100) {
191+
$method->setAccessible(true);
192+
}
187193

188194
$this->assertSame($expected, $method->invoke($api, $value));
189195
}
@@ -375,7 +381,9 @@ public function testRetrieveData(string $path, string $contentType, string $resp
375381
$api = new class ($client) extends AbstractApi {};
376382

377383
$method = new ReflectionMethod($api, 'retrieveData');
378-
$method->setAccessible(true);
384+
if (PHP_VERSION_ID < 80100) {
385+
$method->setAccessible(true);
386+
}
379387

380388
$this->assertSame($expected, $method->invoke($api, $path));
381389
}
@@ -410,7 +418,9 @@ public function testRetrieveDataWith100ResultsMakes1Request(): void
410418
$api = new class ($client) extends AbstractApi {};
411419

412420
$method = new ReflectionMethod($api, 'retrieveData');
413-
$method->setAccessible(true);
421+
if (PHP_VERSION_ID < 80100) {
422+
$method->setAccessible(true);
423+
}
414424

415425
$method->invoke($api, '/data.json', ['limit' => 101]);
416426
}
@@ -435,7 +445,9 @@ public function testRetrieveDataWith250ResultsMakes3Requests(): void
435445
$api = new class ($client) extends AbstractApi {};
436446

437447
$method = new ReflectionMethod($api, 'retrieveData');
438-
$method->setAccessible(true);
448+
if (PHP_VERSION_ID < 80100) {
449+
$method->setAccessible(true);
450+
}
439451

440452
$method->invoke($api, '/data.json', ['limit' => 301]);
441453
}
@@ -454,7 +466,9 @@ public function testRetrieveDataThrowsException(string $response, string $conten
454466
$api = new class ($client) extends AbstractApi {};
455467

456468
$method = new ReflectionMethod($api, 'retrieveData');
457-
$method->setAccessible(true);
469+
if (PHP_VERSION_ID < 80100) {
470+
$method->setAccessible(true);
471+
}
458472

459473
$this->expectException($expectedException);
460474
$this->expectExceptionMessage($expectedMessage);
@@ -483,7 +497,9 @@ public function testDeprecatedRetrieveAll(string $content, string $contentType,
483497
$api = new class ($client) extends AbstractApi {};
484498

485499
$method = new ReflectionMethod($api, 'retrieveAll');
486-
$method->setAccessible(true);
500+
if (PHP_VERSION_ID < 80100) {
501+
$method->setAccessible(true);
502+
}
487503

488504
$this->assertSame($expected, $method->invoke($api, ''));
489505
}
@@ -504,7 +520,9 @@ public function testDeprecatedAttachCustomFieldXML(): void
504520
$api = new class ($client) extends AbstractApi {};
505521

506522
$method = new ReflectionMethod($api, 'attachCustomFieldXML');
507-
$method->setAccessible(true);
523+
if (PHP_VERSION_ID < 80100) {
524+
$method->setAccessible(true);
525+
}
508526

509527
$xml = new SimpleXMLElement('<?xml version="1.0"?><issue/>');
510528

tests/Unit/Api/ProjectTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,9 @@ public function testDeprecatedPrepareParamsXml(): void
316316
$api = new Project($client);
317317

318318
$method = new ReflectionMethod($api, 'prepareParamsXml');
319-
$method->setAccessible(true);
319+
if (PHP_VERSION_ID < 80100) {
320+
$method->setAccessible(true);
321+
}
320322

321323
$this->assertInstanceOf(SimpleXMLElement::class, $method->invoke($api, ['id' => 1]));
322324
}

0 commit comments

Comments
 (0)