<?php
/**
 * Smoke test EduBrain — session → complete → accounting
 */
declare(strict_types=1);
if ( ! defined( 'ACC_BASE_PATH' ) ) {
    define( 'ACC_BASE_PATH', __DIR__ );
    require __DIR__ . '/standalone/bootstrap.php';
}
header( 'Content-Type: application/json; charset=utf-8' );

require_once ACC_PATH . 'includes/helpers/education-platform.php';

global $wpdb;
$student_uid = (int) $wpdb->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_login='edu_student_01'" );
$mentor_uid  = (int) $wpdb->get_var( "SELECT ID FROM {$wpdb->users} WHERE user_login='edu_mentor_01'" );
if ( ! $student_uid || ! $mentor_uid ) {
    echo json_encode( [ 'success' => false, 'message' => 'Run run-education-install.php first' ] );
    exit;
}

$req = Education_Platform::create_session_request( $student_uid, [
    'session_type'  => 'academic',
    'domain'        => 'math',
    'delivery_mode' => 'in_person',
    'venue_type'    => 'home',
    'distance_km'   => 12,
    'duration_min'  => 90,
    'track'         => 'konkur',
] );
$sid = (int) ( $req['session_id'] ?? 0 );
$assign = Education_Platform::assign_session( $sid, $mentor_uid );
$complete = Education_Platform::complete_session( $sid, $mentor_uid, [ 'summary' => 'test' ] );

echo json_encode( [
    'success'  => true,
    'session'  => $req,
    'assign'   => $assign,
    'complete' => $complete,
], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT );
