Skip to content

Commit f6f546a

Browse files
committed
1 parent a37dc41 commit f6f546a

12 files changed

+73
-100
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
"psr/http-factory":"^1.0"
3131
},
3232
"require-dev": {
33-
"guzzlehttp/psr7": "^2.6",
33+
"ext-curl": "*",
34+
"chillerlan/phpunit-http": "^1.0",
35+
"guzzlehttp/guzzle": "^7.8",
3436
"phan/phan": "^5.4",
3537
"phpmd/phpmd": "^2.15",
3638
"phpunit/phpunit": "^10.5",

tests/CookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
*
2222
*/
23-
class CookieTest extends TestCase{
23+
final class CookieTest extends TestCase{
2424

2525
public function testEmptyNameException():void{
2626
$this->expectException(InvalidArgumentException::class);

tests/Emitter/SapiEmitterTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@
1414

1515
use chillerlan\HTTP\Utils\Emitter\ResponseEmitterInterface;
1616
use chillerlan\HTTP\Utils\Emitter\SapiEmitter;
17-
use chillerlan\HTTPTest\Utils\FactoryTrait;
17+
use chillerlan\HTTPTest\Utils\UtilTestAbstract;
1818
use PHPUnit\Framework\Attributes\DataProvider;
19-
use PHPUnit\Framework\TestCase;
2019
use Psr\Http\Message\ResponseInterface;
2120
use Generator, RuntimeException;
2221
use function array_column, array_map, array_pop, explode, header, implode, sprintf, strlen;
2322

24-
class SapiEmitterTest extends TestCase{
25-
use FactoryTrait;
23+
final class SapiEmitterTest extends UtilTestAbstract{
2624

2725
protected ResponseEmitterInterface $emitter;
2826

tests/FactoryTrait.php

Lines changed: 0 additions & 75 deletions
This file was deleted.

tests/HeaderUtilTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@
1414

1515
use chillerlan\HTTP\Utils\HeaderUtil;
1616
use PHPUnit\Framework\Attributes\DataProvider;
17-
use PHPUnit\Framework\TestCase;
1817

1918
/**
2019
*
2120
*/
22-
class HeaderUtilTest extends TestCase{
23-
use FactoryTrait;
21+
final class HeaderUtilTest extends UtilTestAbstract{
2422

2523
public static function headerDataProvider():array{
2624
return [

tests/MessageUtilTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@
1414

1515
use chillerlan\HTTP\Utils\MessageUtil;
1616
use PHPUnit\Framework\Attributes\DataProvider;
17-
use PHPUnit\Framework\TestCase;
1817
use RuntimeException;
1918
use function extension_loaded, file_get_contents, function_exists, sprintf, str_repeat;
2019
use function json_decode;
2120

2221
/**
2322
*
2423
*/
25-
class MessageUtilTest extends TestCase{
26-
use FactoryTrait;
24+
final class MessageUtilTest extends UtilTestAbstract{
2725

2826
public function testGetJSON():void{
2927

tests/MimeTypeUtilTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
*
2121
*/
22-
class MimeTypeUtilTest extends TestCase{
22+
final class MimeTypeUtilTest extends TestCase{
2323

2424
public function testGetMimetypeFromExtension():void{
2525
$this::assertSame('application/json', MimeTypeUtil::getFromExtension('json'));

tests/QueryUtilTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
/**
2424
*
2525
*/
26-
class QueryUtilTest extends TestCase{
26+
final class QueryUtilTest extends TestCase{
2727

2828
public static function queryParamDataProvider():array{
2929
return [

tests/ServerUtilTest.php

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,33 @@
1414

1515
namespace chillerlan\HTTPTest\Utils;
1616

17+
use chillerlan\HTTP\Utils\ServerUtil;
1718
use PHPUnit\Framework\Attributes\DataProvider;
18-
use PHPUnit\Framework\TestCase;
19-
use InvalidArgumentException;
20-
use function microtime, time;
19+
use InvalidArgumentException, Throwable;
20+
use function microtime, realpath, time;
2121
use const UPLOAD_ERR_OK, UPLOAD_ERR_PARTIAL;
2222

23-
class ServerUtilTest extends TestCase{
24-
use FactoryTrait;
23+
final class ServerUtilTest extends UtilTestAbstract{
24+
25+
private ServerUtil $server;
26+
27+
protected function setUp():void{
28+
29+
try{
30+
$this->initFactories();
31+
}
32+
catch(Throwable $e){
33+
$this->markTestSkipped('unable to init http factories: '.$e->getMessage());
34+
}
35+
36+
$this->server = new ServerUtil(
37+
$this->serverRequestFactory,
38+
$this->uriFactory,
39+
$this->uploadedFileFactory,
40+
$this->streamFactory
41+
);
42+
43+
}
2544

2645
public static function dataGetUriFromGlobals():array{
2746

tests/StreamUtilTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
namespace chillerlan\HTTPTest\Utils;
1414

1515
use chillerlan\HTTP\Utils\StreamUtil;
16-
use PHPUnit\Framework\TestCase;
1716
use InvalidArgumentException, RuntimeException;
1817
use function fclose, fopen, stream_get_meta_data, strlen, substr;
1918

2019
/**
2120
*
2221
*/
23-
class StreamUtilTest extends TestCase{
24-
use FactoryTrait;
22+
final class StreamUtilTest extends UtilTestAbstract{
2523

2624
public function testModeAllowsRead():void{
2725
$this::assertTrue(StreamUtil::modeAllowsRead('r+'));

0 commit comments

Comments
 (0)