Skip to content

Commit deae2b8

Browse files
committed
Improve test script.
1 parent bdc0bc7 commit deae2b8

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tests/test.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
/**
1212
* A test script for the RollingCurlX class
1313
*
14-
* This example fetches the value of €1 on different currencies through the freecurrencyconverterapi.com
14+
* This script will fetch the value of €1 on different currencies through the freecurrencyconverterapi.com
1515
*
1616
* NOTE: freecurrencyconverterapi.com IS A FREE SERVICE, PLEASE, BE CONSIDERATE AND DON'T THROW TOO MANY REQUESTS
17-
* AGAINST THEIR SERVERS.
17+
* AGAINST THEIR SERVERS.
1818
*
1919
* By Julio Foulquie <jfoulquie@gmail.com>, freely reusable.
2020
*/
@@ -33,7 +33,7 @@
3333
$curl_options = array(
3434
CURLOPT_SSL_VERIFYPEER => FALSE,
3535
CURLOPT_SSL_VERIFYHOST => FALSE,
36-
CURLOPT_USERAGENT, 'RollingCurlX test script',
36+
CURLOPT_USERAGENT, '[RollingCurlX test script] - [!!!!! Ban this user agent if it becomes a hassle on your server !!!!!!]',
3737
);
3838

3939
echo "Using $max_requests concurrent requests at max." . PHP_EOL;
@@ -46,11 +46,12 @@
4646
$rolling_curl->execute();
4747

4848
// After running 'execute' the number of max_requests gets overwritten to the number of actual requests so reset it.
49-
///TODO: Fix this on the class, _maxConcurrent should go back to its original value after an 'execute' call.
5049
$rolling_curl->setMaxConcurrent($max_requests);
5150
$rolling_curl->setOptions($curl_options);
5251

53-
foreach ($currencies as $currency => $data) {
52+
53+
for($i = 0; $i < 20; $i++) {
54+
$currency = array_rand($currencies);
5455
$user_data = array("1€ in $currency", $currency);
5556
$search_url = $base_url . 'convert?q=EUR_'.$currency. '&compact=y';
5657
$rolling_curl->addRequest($search_url, NULL, 'on_request_done', $user_data);
@@ -63,6 +64,7 @@
6364
* CALLBACKS
6465
*/
6566

67+
// Process the first call
6668
function process_currencies($response, $url, $request_info, $user_data, $time) {
6769
global $currencies;
6870

0 commit comments

Comments
 (0)