Skip to content

Commit 0effae2

Browse files
committed
:octocat: unbreak my tests 🎶
1 parent f34d84d commit 0effae2

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

Diff for: phpunit.xml.dist

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
<xml outputDirectory=".build/coverage/coverage-xml"/>
2222
</report>
2323
</coverage>
24+
<!--
2425
<groups>
2526
<exclude>
26-
<!--
2727
<group>output</group>
2828
<group>slow</group>
29-
-->
3029
</exclude>
3130
</groups>
31+
-->
3232
<php>
3333
<const name="REQUEST_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>
3434
<const name="RESPONSE_FACTORY" value="chillerlan\HTTP\Psr7\HTTPFactory"/>

Diff for: src/HTTPOptionsTrait.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace chillerlan\HTTP;
1616

17-
use function file_exists, ini_get, is_dir, is_file, is_link, readlink, trim;
17+
use function file_exists, ini_get, is_dir, is_file, is_link, readlink, realpath, trim;
1818
use const CURLOPT_CAINFO, CURLOPT_CAPATH;
1919

2020
/**
@@ -152,9 +152,13 @@ protected function setCA(string|null $ca_info = null):void{
152152
if($ca_info !== null){
153153

154154
if($this->checkCA($ca_info)){
155-
$this->ca_info = $ca_info;
155+
$ca_info = realpath($ca_info);
156156

157-
return;
157+
if($ca_info !== false){
158+
$this->ca_info = $ca_info;
159+
160+
return;
161+
}
158162
}
159163

160164
throw new ClientException('invalid path to SSL CA bundle: '.$ca_info);

Diff for: tests/HTTPOptionsTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use chillerlan\HTTP\{CurlHandle, HTTPOptions};
1616
use PHPUnit\Framework\TestCase;
1717
use Psr\Http\Client\ClientExceptionInterface;
18+
use function realpath;
1819
use const CURLOPT_CAINFO, CURLOPT_CAPATH, CURLOPT_SSL_VERIFYHOST, CURLOPT_SSL_VERIFYPEER;
1920

2021
/**
@@ -51,7 +52,7 @@ public function testInvalidCAException():void{
5152
}
5253

5354
public function testCaInfoFile():void{
54-
$file = __DIR__.'/cacert.pem';
55+
$file = realpath(__DIR__.'/cacert.pem');
5556
// via the ca_info option
5657
$options = new HTTPOptions(['ca_info' => $file]);
5758
$curl_options = $this->createTestHandleOptions($options);

Diff for: tests/LoggingClientTest.php

+8-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
namespace chillerlan\HTTPTest;
1414

15-
use chillerlan\HTTP\LoggingClient;
15+
use chillerlan\HTTP\{CurlClient, LoggingClient};
1616
use PHPUnit\Framework\Attributes\Group;
17+
use Psr\Http\Client\ClientInterface;
1718
use Psr\Log\AbstractLogger;
1819
use Stringable;
1920
use function date, printf;
@@ -23,18 +24,19 @@
2324
*/
2425
#[Group('slow')]
2526
#[Group('output')]
26-
class LoggingClientTest extends CurlClientTest{
27+
class LoggingClientTest extends HTTPClientTestAbstract{
2728

28-
protected function setUp():void{
29-
parent::setUp();
29+
protected function initClient():ClientInterface{
30+
$this->options->ssl_verifypeer = false; // whyyy???
3031
32+
$http = new CurlClient($this->responseFactory, $this->options);
3133
$logger = new class () extends AbstractLogger{
3234
public function log($level, string|Stringable $message, array $context = []):void{
3335
printf("\n[%s][%s] LoggingClientTest: %s", date('Y-m-d H:i:s'), $level, $message);
3436
}
3537
};
36-
// we'll just wrap the parent's client
37-
$this->http = new LoggingClient($this->http, $logger);
38+
39+
return new LoggingClient($http, $logger);
3840
}
3941

4042
public function testNetworkError():void{

0 commit comments

Comments
 (0)