<?php
// Mocking session for CLI test
session_start();
$_SESSION['user_id'] = 1;
$_SESSION['company_id'] = 1;
$_SESSION['role'] = 'admin';

function isLoggedIn() { return true; }
function hasRole($roles) { return true; }

// Catch output
ob_start();
try {
    // We need to set up the request data
    $_POST['action'] = 'check-stock';
    $_POST['products'] = [['id' => 1, 'quantity' => 10]];
    
    include 'api/production-lines.php';
} catch (Throwable $e) {
    echo "ERROR: " . $e->getMessage();
}
$output = ob_get_clean();
echo $output;
