]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - tests/utils/CurlUtils.php
3 * Old-style mock for cURL, as PHPUnit doesn't allow to mock global functions
7 * Returns code 200 or html content type.
9 * @param resource $ch cURL resource
10 * @param int $type cURL info type
12 * @return int|string 200 or 'text/html'
14 function ut_curl_getinfo_ok($ch, $type)
17 case CURLINFO_RESPONSE_CODE
:
19 case CURLINFO_CONTENT_TYPE
:
20 return 'text/html; charset=utf-8';
25 * Returns code 200 or html content type without charset.
27 * @param resource $ch cURL resource
28 * @param int $type cURL info type
30 * @return int|string 200 or 'text/html'
32 function ut_curl_getinfo_no_charset($ch, $type)
35 case CURLINFO_RESPONSE_CODE
:
37 case CURLINFO_CONTENT_TYPE
:
43 * Invalid response code.
45 * @param resource $ch cURL resource
46 * @param int $type cURL info type
48 * @return int|string 404 or 'text/html'
50 function ut_curl_getinfo_rc_ko($ch, $type)
53 case CURLINFO_RESPONSE_CODE
:
55 case CURLINFO_CONTENT_TYPE
:
56 return 'text/html; charset=utf-8';
61 * Invalid content type.
63 * @param resource $ch cURL resource
64 * @param int $type cURL info type
66 * @return int|string 200 or 'text/plain'
68 function ut_curl_getinfo_ct_ko($ch, $type)
71 case CURLINFO_RESPONSE_CODE
:
73 case CURLINFO_CONTENT_TYPE
:
79 * Invalid response code and content type.
81 * @param resource $ch cURL resource
82 * @param int $type cURL info type
84 * @return int|string 404 or 'text/plain'
86 function ut_curl_getinfo_rs_ct_ko($ch, $type)
89 case CURLINFO_RESPONSE_CODE
:
91 case CURLINFO_CONTENT_TYPE
: