Skip to content

Commit 0ac7e3e

Browse files
committed
Complete CURLRequest testing & update its UG page
1 parent 724f097 commit 0ac7e3e

6 files changed

Lines changed: 380 additions & 27 deletions

File tree

system/HTTP/CURLRequest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace CodeIgniter\HTTP;
34

45
/**
@@ -72,10 +73,10 @@ class CURLRequest extends Request
7273
* @var array
7374
*/
7475
protected $config = [
75-
'timeout' => 0.0,
76-
'connect_timeout' => 150,
77-
'debug' => false,
78-
'verify' => true
76+
'timeout' => 0.0,
77+
'connect_timeout' => 150,
78+
'debug' => false,
79+
'verify' => true
7980
];
8081

8182
/**
@@ -85,9 +86,9 @@ class CURLRequest extends Request
8586
* @var array
8687
*/
8788
protected $redirectDefaults = [
88-
'max' => 5,
89-
'strict' => true,
90-
'protocols' => ['http', 'https'],
89+
'max' => 5,
90+
'strict' => true,
91+
'protocols' => ['http', 'https'],
9192
];
9293

9394
/**

system/HTTP/Exceptions/HTTPException.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class HTTPException extends FrameworkException implements ExceptionInterface
1111
* For CurlRequest
1212
*
1313
* @return \CodeIgniter\HTTP\Exceptions\HTTPException
14+
*
15+
* Not testable with travis-ci
16+
* @codeCoverageIgnore
1417
*/
1518
public static function forMissingCurl()
1619
{
@@ -48,6 +51,9 @@ public static function forInvalidSSLKey(string $key)
4851
* @param string $error
4952
*
5053
* @return \CodeIgniter\HTTP\Exceptions\HTTPException
54+
*
55+
* Not testable with travis-ci; we over-ride the method which triggers it
56+
* @codeCoverageIgnore
5157
*/
5258
public static function forCurlError(string $errorNum, string $error)
5359
{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

tests/_support/HTTP/MockCURLRequest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php namespace Tests\Support\HTTP;
1+
<?php
2+
3+
namespace Tests\Support\HTTP;
24

35
use CodeIgniter\HTTP\CURLRequest;
46

@@ -11,8 +13,8 @@
1113
*/
1214
class MockCURLRequest extends CURLRequest
1315
{
14-
public $curl_options;
1516

17+
public $curl_options;
1618
protected $output = '';
1719

1820
//--------------------------------------------------------------------
@@ -35,5 +37,16 @@ protected function sendRequest(array $curl_options = []): string
3537
}
3638

3739
//--------------------------------------------------------------------
40+
// for testing purposes only
41+
public function getBaseURI()
42+
{
43+
return $this->baseURI;
44+
}
45+
46+
// for testing purposes only
47+
public function getDelay()
48+
{
49+
return $this->delay;
50+
}
3851

3952
}

0 commit comments

Comments
 (0)