Skip to content

Commit 9fc8de6

Browse files
committed
Increase code coverage
1 parent 9404453 commit 9fc8de6

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

tests/Unit/Client/NativeCurlClient/RequestTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/**
1313
* @covers \Redmine\Client\NativeCurlClient::request
1414
* @covers \Redmine\Client\NativeCurlClient::runRequest
15+
* @covers \Redmine\Client\NativeCurlClient::createHttpHeader
1516
*/
1617
class RequestTest extends TestCase
1718
{
@@ -68,6 +69,7 @@ public function testRequestReturnsCorrectResponse($method, $data, $statusCode, $
6869
public static function getRequestReponseData(): array
6970
{
7071
return [
72+
['GET', '', 101, '', ''],
7173
['GET', '', 101, 'text/plain', ''],
7274
['GET', '', 200, 'application/json', '{"foo_bar": 12345}'],
7375
['GET', '', 301, 'application/json', ''],

tests/Unit/Client/Psr18Client/RequestTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/**
2020
* @covers \Redmine\Client\Psr18Client::request
2121
* @covers \Redmine\Client\Psr18Client::runRequest
22+
* @covers \Redmine\Client\Psr18Client::createRequest
2223
*/
2324
class RequestTest extends TestCase
2425
{
@@ -73,9 +74,10 @@ public function testRequestReturnsCorrectResponse($method, $data, $statusCode, $
7374
public static function getRequestReponseData(): array
7475
{
7576
return [
77+
['GET', '', 101, '', ''],
7678
['GET', '', 101, 'text/plain', ''],
7779
['GET', '', 200, 'application/json', '{"foo_bar": 12345}'],
78-
['GET', '', 301, 'application/json', ''],
80+
['GET', '', 301, 'application/xml', ''],
7981
['GET', '', 404, 'application/json', '{"title": "404 Not Found"}'],
8082
['GET', '', 500, 'text/plain', 'Internal Server Error'],
8183
['POST', '{"foo":"bar"}', 101, 'text/plain', ''],

tests/Unit/Client/Psr18ClientTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Redmine\Tests\Unit\Client;
44

5+
use Exception;
56
use InvalidArgumentException;
67
use PHPUnit\Framework\TestCase;
78
use Psr\Http\Client\ClientInterface;
@@ -14,6 +15,7 @@
1415
use Redmine\Client\Client;
1516
use Redmine\Client\Psr18Client;
1617
use Redmine\Http\HttpClient;
18+
use stdClass;
1719

1820
class Psr18ClientTest extends TestCase
1921
{
@@ -298,6 +300,23 @@ public static function getApiClassesProvider(): array
298300
];
299301
}
300302

303+
/**
304+
* @covers \Redmine\Client\Psr18Client::__construct
305+
*/
306+
public function testCreateWithoutFactoryThrowsException()
307+
{
308+
$this->expectException(Exception::class);
309+
$this->expectExceptionMessage('Redmine\Client\Psr18Client::__construct(): Argument #2 ($requestFactory) must be of type Psr\Http\Message\RequestFactoryInterface');
310+
311+
$client = new Psr18Client(
312+
$this->createMock(ClientInterface::class),
313+
new stdClass(),
314+
$this->createMock(StreamFactoryInterface::class),
315+
'http://test.local',
316+
'access_token'
317+
);
318+
}
319+
301320
/**
302321
* @covers \Redmine\Client\Psr18Client
303322
* @test

0 commit comments

Comments
 (0)