<?php

require_once __DIR__ . '/Domain/Tasks/WorkTimeRepositoryTest.php';
require_once __DIR__ . '/Domain/Tasks/TaskAttachmentRepositoryTest.php';
require_once __DIR__ . '/Domain/Tasks/MailToTaskImporterTest.php';
require_once __DIR__ . '/Domain/Users/UserRepositoryTest.php';
require_once __DIR__ . '/Domain/Users/PermissionRepositoryTest.php';
require_once __DIR__ . '/Controllers/TasksControllerTest.php';
require_once __DIR__ . '/Controllers/UsersControllerTest.php';

$tests = [
  'run_work_time_repository_tests',
  'run_task_attachment_repository_tests',
  'run_mail_to_task_importer_tests',
  'run_user_repository_tests',
  'run_permission_repository_tests',
  'run_tasks_controller_tests',
  'run_users_controller_tests'
];

$failed = 0;

foreach ( $tests as $test )
{
  try
  {
    $test();
    echo "[OK] {$test}\n";
  }
  catch ( Throwable $e )
  {
    $failed++;
    echo "[FAIL] {$test}: " . $e -> getMessage() . "\n";
  }
}

if ( $failed )
{
  echo "\nFailed: {$failed}\n";
  exit( 1 );
}

echo "\nAll tests passed.\n";
