Repository navigation
Expand file tree
/
Copy pathtest_controller.php
More file actions
57 lines (44 loc) · 1.88 KB
/
Copy pathtest_controller.php
File metadata and controls
57 lines (44 loc) · 1.88 KB
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
<?php
use App\Http\Controllers\StudentScholarshipController;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Http\Request;
use Inertia\Response;
require_once 'vendor/autoload.php';
$app = require_once 'bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
try {
echo "Test du contrôleur StudentScholarshipController\n";
$controller = app(StudentScholarshipController::class);
$request = new Request;
$response = $controller->index($request);
// Vérifier si c'est une réponse Inertia
if ($response instanceof Response) {
// Essayer d'accéder aux propriétés directement
$reflection = new ReflectionClass($response);
$propsProperty = $reflection->getProperty('props');
$propsProperty->setAccessible(true);
$data = $propsProperty->getValue($response);
echo "Données chargées avec succès\n";
echo 'Clés disponibles: '.implode(', ', array_keys($data))."\n";
if (isset($data['studentScholarships'])) {
echo '- Type de studentScholarships: '.gettype($data['studentScholarships'])."\n";
if (is_array($data['studentScholarships']) && isset($data['studentScholarships']['data'])) {
echo '- Attributions: '.count($data['studentScholarships']['data'])."\n";
}
}
if (isset($data['scholarships'])) {
echo '- Bourses disponibles: '.count($data['scholarships'])."\n";
}
if (isset($data['academicYears'])) {
echo '- Années académiques: '.count($data['academicYears'])."\n";
}
if (isset($data['filters'])) {
echo '- Filtres: '.json_encode($data['filters'])."\n";
}
} else {
echo 'Erreur: réponse inattendue - '.get_class($response)."\n";
}
} catch (Exception $e) {
echo 'Erreur: '.$e->getMessage()."\n";
echo 'Trace: '.$e->getTraceAsString()."\n";
}