Skip to content

Commit 0ab0d20

Browse files
committed
Merge branch 'v2.x' into create-named-constructors-in-api
2 parents 67d5c27 + 00d823f commit 0ab0d20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+324
-242
lines changed

.docker/PHP85-Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM php:8.5-fpm
2+
3+
RUN apt-get update
4+
RUN apt-get --yes --no-install-recommends install \
5+
apt-utils \
6+
curl \
7+
git \
8+
vim
9+
10+
ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
11+
12+
RUN install-php-extensions \
13+
bcmath \
14+
exif \
15+
gd \
16+
intl \
17+
mysqli \
18+
opcache \
19+
pdo \
20+
pdo_mysql \
21+
sockets \
22+
xdebug-^3.5 \
23+
zip \
24+
@composer
25+
26+
COPY build/php/opcache.ini /usr/local/etc/php/conf.d/
27+
COPY build/php/custom.ini /usr/local/etc/php/conf.d/
28+
29+
30+
RUN php --version
31+
32+
RUN composer --version
33+
34+
RUN usermod -u 1000 www-data
35+
RUN usermod -a -G www-data root
36+
RUN mkdir -p /var/www/.composer
37+
RUN chown -R www-data:www-data /var/www
38+
39+
WORKDIR /var/www/project/

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ services:
22
php:
33
build: # Info to build the Docker image
44
context: ./.docker # Specify where the Dockerfile is located (e.g. in the root directory of the project)
5-
dockerfile: PHP-Dockerfile # Specify the name of the Dockerfile
5+
dockerfile: PHP74-Dockerfile # Specify the name of the Dockerfile
66
ports:
77
- 8111:80
88
depends_on:

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
beStrictAboutCoverageMetadata="false"
88
beStrictAboutOutputDuringTests="true"
99
displayDetailsOnIncompleteTests="true"
10-
displayDetailsOnPhpunitDeprecations="true"
1110
displayDetailsOnSkippedTests="true"
1211
displayDetailsOnTestsThatTriggerDeprecations="true"
12+
displayDetailsOnPhpunitDeprecations="true"
1313
displayDetailsOnTestsThatTriggerErrors="true"
1414
displayDetailsOnTestsThatTriggerNotices="true"
1515
displayDetailsOnTestsThatTriggerWarnings="true"

src/Redmine/Client/NativeCurlClient.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,11 @@ private function runRequest(string $method, string $path, string $body = '', str
309309

310310
if (CURLE_OK !== $curlErrorNumber) {
311311
$e = new ClientException(curl_error($curl), $curlErrorNumber);
312-
curl_close($curl);
312+
313+
if (PHP_VERSION_ID < 80000) {
314+
curl_close($curl);
315+
}
316+
313317
throw $e;
314318
}
315319

@@ -321,7 +325,9 @@ private function runRequest(string $method, string $path, string $body = '', str
321325
$this->lastResponseContentType = $possibleContentType;
322326
}
323327

324-
curl_close($curl);
328+
if (PHP_VERSION_ID < 80000) {
329+
curl_close($curl);
330+
}
325331

326332
return $this->lastResponseStatusCode < 400;
327333
}

tests/Fixtures/AssertingHttpClient.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PHPUnit\Framework\MockObject\MockBuilder;
88
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
9+
use PHPUnit\Framework\MockObject\TestStubBuilder;
910
use PHPUnit\Framework\TestCase;
1011
use Redmine\Http\HttpClient;
1112
use Redmine\Http\Request;
@@ -100,8 +101,14 @@ public function request(Request $request): Response
100101
$this->testCase->assertSame($data['content'], $request->getContent());
101102
}
102103

103-
/** @var \PHPUnit\Framework\MockObject\MockObject&Response */
104-
$response = (new MockBuilder($this->testCase, Response::class))->getMock();
104+
$createStubMethod = new \ReflectionMethod($this->testCase, 'createStub');
105+
106+
if (PHP_VERSION_ID < 80100) {
107+
$createStubMethod->setAccessible(true);
108+
}
109+
110+
/** @var \PHPUnit\Framework\MockObject\Stub&Response $response */
111+
$response = $createStubMethod->invoke($this->testCase, Response::class);
105112

106113
$response->method('getStatusCode')->willReturn($data['responseCode']);
107114
$response->method('getContentType')->willReturn($data['responseContentType']);

tests/Integration/Psr18ClientRequestGenerationTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ public function testPsr18ClientCreatesCorrectRequests(
3333
$data,
3434
string $expectedOutput
3535
): void {
36-
$response = $this->createMock(ResponseInterface::class);
36+
$response = $this->createStub(ResponseInterface::class);
3737

3838
/** @var ClientInterface&\PHPUnit\Framework\MockObject\MockObject */
39-
$httpClient = $this->createMock(ClientInterface::class);
40-
$httpClient->method('sendRequest')->willReturnCallback(function ($request) use ($response, $expectedOutput): \PHPUnit\Framework\MockObject\MockObject {
39+
$httpClient = $this->createStub(ClientInterface::class);
40+
$httpClient->method('sendRequest')->willReturnCallback(function ($request) use ($response, $expectedOutput): \PHPUnit\Framework\MockObject\Stub {
4141
// Create a text representation of the HTTP request
4242
$content = $request->getBody()->__toString();
4343

@@ -64,7 +64,7 @@ public function testPsr18ClientCreatesCorrectRequests(
6464
return $response;
6565
});
6666

67-
$requestFactory = $this->createMock(RequestFactoryInterface::class);
67+
$requestFactory = $this->createStub(RequestFactoryInterface::class);
6868
$requestFactory->method('createRequest')->willReturnCallback(fn($method, $uri): \GuzzleHttp\Psr7\Request => new Request($method, $uri));
6969

7070
$streamFactory = new class implements StreamFactoryInterface {

tests/RedmineExtension/RedmineInstance.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ private function runHealthChecks(RedmineVersion $version): void
105105
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
106106
$data = curl_exec($ch);
107107
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
108-
curl_close($ch);
108+
if (PHP_VERSION_ID < 80000) {
109+
curl_close($ch);
110+
}
109111

110112
if ($data === false || $statusCode !== 200) {
111113
throw new InvalidArgumentException(sprintf(

tests/Unit/Api/AbstractApi/DeleteTest.php

Lines changed: 7 additions & 3 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');
@@ -47,14 +49,16 @@ public function testDeleteWithHttpClient(): void
4749
#[DataProvider('getXmlDecodingFromDeleteMethodData')]
4850
public function testXmlDecodingFromDeleteMethod(string $response, string $expected): void
4951
{
50-
$client = $this->createMock(Client::class);
52+
$client = $this->createStub(Client::class);
5153
$client->method('getLastResponseBody')->willReturn($response);
5254
$client->method('getLastResponseContentType')->willReturn('application/xml');
5355

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: 11 additions & 5 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(
@@ -49,14 +51,16 @@ public function testGetWithHttpClient(): void
4951
#[DataProvider('getJsonDecodingFromGetMethodData')]
5052
public function testJsonDecodingFromGetMethod(string $response, ?bool $decode, $expected): void
5153
{
52-
$client = $this->createMock(Client::class);
54+
$client = $this->createStub(Client::class);
5355
$client->method('getLastResponseBody')->willReturn($response);
5456
$client->method('getLastResponseContentType')->willReturn('application/json');
5557

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)) {
@@ -84,14 +88,16 @@ public static function getJsonDecodingFromGetMethodData(): array
8488
#[DataProvider('getXmlDecodingFromGetMethodData')]
8589
public function testXmlDecodingFromGetMethod(string $response, ?bool $decode, string $expected): void
8690
{
87-
$client = $this->createMock(Client::class);
91+
$client = $this->createStub(Client::class);
8892
$client->method('getLastResponseBody')->willReturn($response);
8993
$client->method('getLastResponseContentType')->willReturn('application/xml');
9094

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);

0 commit comments

Comments
 (0)