| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- /**
- * Script simple pour tester POST_userV2.php
- */
- echo "🚀 Test POST_userV2.php\n\n";
- // Charger nos données
- $json_file = __DIR__ . '/post_user_request.json';
- $post_data = json_decode(file_get_contents($json_file), true);
- // Générer un nouveau login unique
- $timestamp = time();
- $post_data['login'] = "test.user.{$timestamp}@sipa-automobiles.fr";
- $post_data['mail'] = $post_data['login'];
- $post_data['employeeNumber'] = "TEST{$timestamp}";
- $post_data['dtContractStart'] = date('Y-m-d\TH:i:s', strtotime('+1 day'));
- $post_data['seniorityDate'] = $post_data['dtContractStart'];
- echo "📋 Données:\n";
- print_r($post_data);
- echo "\n";
- // Modifier POST_userV2.php temporairement
- $script_path = __DIR__ . '/../api/user/user/POST_userV2.php';
- $content = file_get_contents($script_path);
- // Activer USE_TEST_DATA et remplacer les données
- $content = str_replace(
- "define('USE_TEST_DATA', false);",
- "define('USE_TEST_DATA', true);",
- $content
- );
- // Remplacer les données de test
- $old_test_data = '$input = [
- // Champs REQUIS (non-nullable)
- "firstName" => "John",';
- $new_test_data = '$input = ' . var_export($post_data, true) . ';';
- $pos = strpos($content, $old_test_data);
- if ($pos !== false) {
- $end_pos = strpos($content, '];', $pos);
- if ($end_pos !== false) {
- $content = substr_replace($content, $new_test_data, $pos, $end_pos - $pos + 2);
- }
- }
- // Sauvegarder temporairement
- $temp_script = sys_get_temp_dir() . '/POST_userV2_test_' . $timestamp . '.php';
- file_put_contents($temp_script, $content);
- echo "📡 Exécution...\n\n";
- // Capturer la sortie
- ob_start();
- include $temp_script;
- $output = ob_get_clean();
- echo $output;
- // Nettoyer
- unlink($temp_script);
|