Skip to content

Commit 74bf442

Browse files
authored
Php8 Support (#255)
* Add Attachment DELETE functionality * Add Wiki Attachments/File Uploads support * Add Attachment DELETE functionality * Add Wiki Attachments/File Uploads support * Fix Fatal error: Uncaught Exception: HTTP/2 stream 0 was not closed cleanly * #sync fork changes with original master * #253 Uncaught Exception: HTTP/2 stream 0 was not closed cleanly * Add support for PHP 8.0; Upgrade PHPUnit, fix code inspections in unit-tests * Update travis config
2 parents a3a7a58 + 4b22082 commit 74bf442

32 files changed

+321
-268
lines changed

.travis.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- 7.1
7-
# - 7.2
8-
# - 7.3
4+
- 7.3
5+
- 7.4
6+
- 8.0
97

108
before_script:
119
- composer install --ignore-platform-reqs

composer.json

+13-8
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,27 @@
33
"type": "library",
44
"description": "Redmine API client",
55
"homepage": "https://github.com/kbsali/php-redmine-api",
6-
"keywords": ["redmine", "api"],
6+
"keywords": [
7+
"redmine",
8+
"api"
9+
],
710
"license": "MIT",
8-
"authors": [{
9-
"name": "Kevin Saliou",
10-
"email": "kevin@saliou.name",
11-
"homepage": "http://kevin.saliou.name"
12-
}],
11+
"authors": [
12+
{
13+
"name": "Kevin Saliou",
14+
"email": "kevin@saliou.name",
15+
"homepage": "http://kevin.saliou.name"
16+
}
17+
],
1318
"require": {
14-
"php": "^5.4 || ^7.2",
19+
"php": "^7.3 || ^8.0",
1520
"ext-curl": "*",
1621
"ext-simplexml": "*",
1722
"ext-json": "*"
1823
},
1924
"require-dev": {
2025
"friendsofphp/php-cs-fixer": "^2.0",
21-
"phpunit/phpunit": "^4.8.36 || ^5.4.8 || ^6.0"
26+
"phpunit/phpunit": "^9.5"
2227
},
2328
"autoload": {
2429
"psr-4": {

phpunit.xml.dist

+20-34
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
12-
bootstrap="src/autoload.php"
13-
>
14-
<testsuites>
15-
<testsuite name="all">
16-
<directory suffix="Test.php">tests/Unit/</directory>
17-
</testsuite>
18-
</testsuites>
19-
20-
<groups>
21-
<exclude>
22-
<group>functional</group>
23-
</exclude>
24-
</groups>
25-
26-
<filter>
27-
<whitelist>
28-
<directory suffix=".php">src/Redmine/</directory>
29-
</whitelist>
30-
</filter>
31-
32-
<logging>
33-
<log type="coverage-clover" target="coverage.clover"/>
34-
</logging>
35-
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" bootstrap="src/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage>
4+
<include>
5+
<directory suffix=".php">src/Redmine/</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="coverage.clover"/>
9+
</report>
10+
</coverage>
11+
<testsuites>
12+
<testsuite name="all">
13+
<directory suffix="Test.php">tests/Unit/</directory>
14+
</testsuite>
15+
</testsuites>
16+
<groups>
17+
<exclude>
18+
<group>functional</group>
19+
</exclude>
20+
</groups>
21+
<logging/>
3622
</phpunit>

tests/Fixtures/MockClient.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Redmine\Tests\Fixtures;
44

5+
use Exception;
56
use Redmine\Client;
67

78
/**
@@ -48,7 +49,7 @@ public function get($path, $decode = true)
4849
* @param string $method
4950
* @param string $data
5051
*
51-
* @throws \Exception If anything goes wrong on curl request
52+
* @throws Exception If anything goes wrong on curl request
5253
*
5354
* @return string
5455
*/

tests/Unit/Api/AttachmentTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use PHPUnit\Framework\TestCase;
56
use Redmine\Api\Attachment;
67

78
/**
89
* @coversDefaultClass \Redmine\Api\Attachment
910
*
1011
* @author Malte Gerth <mail@malte-gerth.de>
1112
*/
12-
class AttachmentTest extends \PHPUnit\Framework\TestCase
13+
class AttachmentTest extends TestCase
1314
{
1415
/**
1516
* Test lastCallFailed().

tests/Unit/Api/CustomFieldTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use PHPUnit\Framework\TestCase;
56
use Redmine\Api\CustomField;
67

78
/**
89
* @coversDefaultClass \Redmine\Api\CustomField
910
*
1011
* @author Malte Gerth <mail@malte-gerth.de>
1112
*/
12-
class CustomFieldTest extends \PHPUnit\Framework\TestCase
13+
class CustomFieldTest extends TestCase
1314
{
1415
/**
1516
* Test all().
@@ -111,8 +112,8 @@ public function testAllReturnsClientGetResponseWithHighLimit()
111112
// Perform the tests
112113
$retrievedDataSet = $api->all($allParameters);
113114
$this->assertTrue(is_array($retrievedDataSet));
114-
$this->assertTrue(array_key_exists('limit', $retrievedDataSet));
115-
$this->assertTrue(array_key_exists('items', $retrievedDataSet));
115+
$this->assertArrayHasKey('limit', $retrievedDataSet);
116+
$this->assertArrayHasKey('items', $retrievedDataSet);
116117
}
117118

118119
/**
@@ -152,8 +153,8 @@ public function testAllCallsEndpointUntilOffsetIsHigherThanTotalCount()
152153
// Perform the tests
153154
$retrievedDataSet = $api->all($allParameters);
154155
$this->assertTrue(is_array($retrievedDataSet));
155-
$this->assertTrue(array_key_exists('limit', $retrievedDataSet));
156-
$this->assertTrue(array_key_exists('items', $retrievedDataSet));
156+
$this->assertArrayHasKey('limit', $retrievedDataSet);
157+
$this->assertArrayHasKey('items', $retrievedDataSet);
157158
}
158159

159160
/**

tests/Unit/Api/GroupTest.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use Exception;
6+
use PHPUnit\Framework\TestCase;
57
use Redmine\Api\Group;
68

79
/**
810
* @coversDefaultClass \Redmine\Api\Group
911
*
1012
* @author Malte Gerth <mail@malte-gerth.de>
1113
*/
12-
class GroupTest extends \PHPUnit\Framework\TestCase
14+
class GroupTest extends TestCase
1315
{
1416
/**
1517
* Test all().
@@ -332,11 +334,12 @@ public function testCreateCallsPost()
332334
*
333335
* @covers ::create
334336
* @covers ::post
335-
* @expectedException \Exception
337+
*
336338
* @test
337339
*/
338340
public function testCreateThrowsExceptionIsNameIsMissing()
339341
{
342+
$this->expectException(Exception::class);
340343
// Test values
341344
$postParameter = [];
342345

tests/Unit/Api/IssueCategoryTest.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use Exception;
6+
use PHPUnit\Framework\TestCase;
57
use Redmine\Api\IssueCategory;
68

79
/**
810
* @coversDefaultClass \Redmine\Api\IssueCategory
911
*
1012
* @author Malte Gerth <mail@malte-gerth.de>
1113
*/
12-
class IssueCategoryTest extends \PHPUnit\Framework\TestCase
14+
class IssueCategoryTest extends TestCase
1315
{
1416
/**
1517
* Test all().
@@ -332,11 +334,11 @@ public function testGetIdByNameMakesGetRequest()
332334
*
333335
* @covers ::post
334336
* @covers ::create
335-
* @expectedException \Exception
336337
* @test
337338
*/
338339
public function testCreateThrowsExceptionIfNameIsMissing()
339340
{
341+
$this->expectException(Exception::class);
340342
// Test values
341343
$parameters = [
342344
'name' => null,

tests/Unit/Api/IssuePriorityTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use PHPUnit\Framework\TestCase;
56
use Redmine\Api\IssuePriority;
67

78
/**
89
* @coversDefaultClass \Redmine\Api\IssuePriority
910
*
1011
* @author Malte Gerth <mail@malte-gerth.de>
1112
*/
12-
class IssuePriorityTest extends \PHPUnit\Framework\TestCase
13+
class IssuePriorityTest extends TestCase
1314
{
1415
/**
1516
* Test all().

tests/Unit/Api/IssueRelationTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use PHPUnit\Framework\TestCase;
56
use Redmine\Api\IssueRelation;
67

78
/**
89
* @coversDefaultClass \Redmine\Api\IssueRelation
910
*
1011
* @author Malte Gerth <mail@malte-gerth.de>
1112
*/
12-
class IssueRelationTest extends \PHPUnit\Framework\TestCase
13+
class IssueRelationTest extends TestCase
1314
{
1415
/**
1516
* Test all().

tests/Unit/Api/IssueStatusTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use PHPUnit\Framework\TestCase;
56
use Redmine\Api\IssueStatus;
67

78
/**
89
* @coversDefaultClass \Redmine\Api\IssueStatus
910
*
1011
* @author Malte Gerth <mail@malte-gerth.de>
1112
*/
12-
class IssueStatusTest extends \PHPUnit\Framework\TestCase
13+
class IssueStatusTest extends TestCase
1314
{
1415
/**
1516
* Test all().

tests/Unit/Api/IssueTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use PHPUnit\Framework\TestCase;
56
use Redmine\Api\Issue;
67

78
/**
89
* @coversDefaultClass \Redmine\Api\Issue
910
*
1011
* @author Malte Gerth <mail@malte-gerth.de>
1112
*/
12-
class IssueTest extends \PHPUnit\Framework\TestCase
13+
class IssueTest extends TestCase
1314
{
1415
/**
1516
* Test the constants.

tests/Unit/Api/MembershipTest.php

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use Exception;
6+
use PHPUnit\Framework\TestCase;
57
use Redmine\Api\Membership;
68

79
/**
810
* @coversDefaultClass \Redmine\Api\Membership
911
*
1012
* @author Malte Gerth <mail@malte-gerth.de>
1113
*/
12-
class MembershipTest extends \PHPUnit\Framework\TestCase
14+
class MembershipTest extends TestCase
1315
{
1416
/**
1517
* Test all().
@@ -113,11 +115,12 @@ public function testRemoveCallsDelete()
113115
* Test create().
114116
*
115117
* @covers ::create
116-
* @expectedException \Exception
118+
*
117119
* @test
118120
*/
119121
public function testCreateThrowsExceptionWithEmptyParameters()
120122
{
123+
$this->expectException(Exception::class);
121124
// Test values
122125
$getResponse = 'API Response';
123126

@@ -137,11 +140,12 @@ public function testCreateThrowsExceptionWithEmptyParameters()
137140
* Test create().
138141
*
139142
* @covers ::create
140-
* @expectedException \Exception
143+
*
141144
* @test
142145
*/
143146
public function testCreateThrowsExceptionIfRoleIdsAreMissingInParameters()
144147
{
148+
$this->expectException(Exception::class);
145149
// Test values
146150
$getResponse = 'API Response';
147151

@@ -248,11 +252,12 @@ public function testCreateBuildsXml()
248252
* Test update().
249253
*
250254
* @covers ::update
251-
* @expectedException \Exception
255+
*
252256
* @test
253257
*/
254258
public function testUpdateThrowsExceptionIfRoleIdsAreMissingInParameters()
255259
{
260+
$this->expectException(Exception::class);
256261
// Test values
257262
$getResponse = 'API Response';
258263

tests/Unit/Api/NewsTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
namespace Redmine\Tests\Unit\Api;
44

5+
use PHPUnit\Framework\TestCase;
56
use Redmine\Api\News;
67

78
/**
89
* @coversDefaultClass \Redmine\Api\News
910
*
1011
* @author Malte Gerth <mail@malte-gerth.de>
1112
*/
12-
class NewsTest extends \PHPUnit\Framework\TestCase
13+
class NewsTest extends TestCase
1314
{
1415
/**
1516
* Test all().

0 commit comments

Comments
 (0)