-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurl.php
64 lines (53 loc) · 1.82 KB
/
Curl.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
/*
* This file is part of the QuidPHP package <https://quidphp.com>
* Author: Pierre-Philippe Emond <emondpph@gmail.com>
* License: https://github.com/quidphp/base/blob/master/LICENSE
*/
namespace Quid\Test\Base;
use Quid\Base;
// curl
// class for testing Quid\Base\Curl
class Curl extends Base\Test
{
// trigger
final public static function trigger(array $data):bool
{
// prepare
$mediaJpg = '[assertMedia]/jpg.jpg';
$mediaJpgUri = Base\Uri::relative($mediaJpg);
$mediaPhp = '[assertMedia]/php.php';
$http = Base\Res::open(Base\Uri::absolute($mediaJpgUri));
$curl = Base\Curl::make(Base\Uri::absolute($mediaPhp));
$curlOpen = Base\Curl::make(Base\Uri::absolute($mediaJpgUri));
// is
assert(Base\Curl::is($curl));
assert(!Base\Curl::is($http));
// open
// close
assert(Base\Curl::close($curlOpen) === null);
// meta
assert(count(Base\Curl::meta($curl)) === 4);
// info
assert(count(Base\Curl::info($curl)) > 26);
assert(Base\Curl::info($http) === null);
// make
$res2 = Base\Curl::make('http://perdu.com',true)['resource'];
assert(is_resource($res2));
// exec
$exec = Base\Curl::exec($curl,false);
assert(count($exec) === 7);
$res = $exec['resource'];
assert(is_array(Base\Res::headers($res)));
assert(Base\Res::mime($res) === 'text/html');
assert(Base\Res::basename($res) === 'php.html');
assert(Base\Res::uri($res) === 'php://temp');
assert(Base\Res::path($res) === 'php.html');
assert(!empty(Base\Res::size($res)));
assert(count(Base\Res::responseMeta($res)) === 4);
assert(Base\Res::isResponsable($res));
return true;
}
}
?>