Skip to content

Commit 67dd1e5

Browse files
committed
feat: implement enableFutureMode() in Client implementations
1 parent 2de02d8 commit 67dd1e5

4 files changed

Lines changed: 72 additions & 0 deletions

File tree

src/Redmine/Client/ClientApiTrait.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Redmine\Api;
66
use Redmine\Exception\InvalidApiNameException;
7+
use Redmine\Future;
78

89
/**
910
* Provide API instantiation to clients.
@@ -60,6 +61,11 @@ public function getApi(string $name): Api
6061
return $this->apiInstances[$name];
6162
}
6263

64+
public function enableFutureMode(): void
65+
{
66+
Future::enableForwardCompatibility();
67+
}
68+
6369
private function isUploadCall(string $path): bool
6470
{
6571
$path = strtolower($path);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Redmine\Tests\Unit\Client\NativeCurlClient;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\TestCase;
9+
use Redmine\Client\NativeCurlClient;
10+
use Redmine\Future;
11+
12+
#[CoversClass(NativeCurlClient::class)]
13+
final class EnableFutureModeTest extends TestCase
14+
{
15+
public function testEnableFutureModeEnablesFutureMode(): void
16+
{
17+
Future::disableForwardCompatibility();
18+
19+
$client = new NativeCurlClient(
20+
'',
21+
'',
22+
);
23+
$client->enableFutureMode();
24+
25+
self::assertTrue(Future::isForwardCompatibilityEnabled());
26+
27+
Future::disableForwardCompatibility();
28+
}
29+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Redmine\Tests\Unit\Client\Psr18Client;
6+
7+
use PHPUnit\Framework\Attributes\CoversClass;
8+
use PHPUnit\Framework\TestCase;
9+
use Psr\Http\Client\ClientInterface;
10+
use Psr\Http\Message\RequestFactoryInterface;
11+
use Psr\Http\Message\StreamFactoryInterface;
12+
use Redmine\Client\Psr18Client;
13+
use Redmine\Future;
14+
15+
#[CoversClass(Psr18Client::class)]
16+
final class EnableFutureModeTest extends TestCase
17+
{
18+
public function testEnableFutureModeEnablesFutureMode(): void
19+
{
20+
Future::disableForwardCompatibility();
21+
22+
$client = new Psr18Client(
23+
$this->createStub(ClientInterface::class),
24+
$this->createStub(RequestFactoryInterface::class),
25+
$this->createStub(StreamFactoryInterface::class),
26+
'',
27+
'',
28+
);
29+
$client->enableFutureMode();
30+
31+
self::assertTrue(Future::isForwardCompatibilityEnabled());
32+
33+
Future::disableForwardCompatibility();
34+
}
35+
}

tests/Unit/FutureTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
namespace Redmine\Tests\Unit;
66

7+
use PHPUnit\Framework\Attributes\CoversClass;
78
use PHPUnit\Framework\TestCase;
89
use Redmine\Future;
910

11+
#[CoversClass(Future::class)]
1012
final class FutureTest extends TestCase
1113
{
1214
public function testIsForwardCompatabilityEnabledReturnsFalseByDefault(): void

0 commit comments

Comments
 (0)