48 lines
No EOL
1.4 KiB
PHP
48 lines
No EOL
1.4 KiB
PHP
<?php
|
|
// Test script for the new city-followup API endpoint
|
|
|
|
// Replace with your actual Symfony application URL
|
|
$url = 'http://localhost:8000/api/city-followup';
|
|
|
|
// Test data
|
|
$data = [
|
|
'insee_code' => '75056', // Example INSEE code for Paris
|
|
'measure_label' => 'test_measure',
|
|
'measure_value' => 42.5
|
|
];
|
|
|
|
// Function to make a POST request
|
|
function makePostRequest($url, $data) {
|
|
$options = [
|
|
'http' => [
|
|
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
|
|
'method' => 'POST',
|
|
'content' => http_build_query($data)
|
|
]
|
|
];
|
|
$context = stream_context_create($options);
|
|
$result = file_get_contents($url, false, $context);
|
|
|
|
if ($result === FALSE) {
|
|
echo "Error making request\n";
|
|
return null;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
// First request should succeed
|
|
echo "Making first request...\n";
|
|
$response = makePostRequest($url, $data);
|
|
echo "Response: " . $response . "\n\n";
|
|
|
|
// Second request within an hour should fail
|
|
echo "Making second request (should fail due to 1-hour limit)...\n";
|
|
$response = makePostRequest($url, $data);
|
|
echo "Response: " . $response . "\n\n";
|
|
|
|
// Try with a different measure label (should succeed)
|
|
echo "Making request with different measure label...\n";
|
|
$data['measure_label'] = 'another_test_measure';
|
|
$response = makePostRequest($url, $data);
|
|
echo "Response: " . $response . "\n"; |