#!/usr/bin/env php
<?php declare(strict_types=1);
$files = [
    __DIR__.'/../../../autoload.php',
    __DIR__.'/../vendor/autoload.php',
];

$autoloadFileFound = false;
foreach ($files as $file) {
    if (file_exists($file)) {
        require $file;
        $autoloadFileFound = true;
        break;
    }
}

if (!$autoloadFileFound) {
    echo 'You need to set up the project dependencies using the following commands:'.PHP_EOL.
         'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
         'php composer.phar install'.PHP_EOL;
    die(1);
}

try {
    $pathToTest = $argv[1];
    $errors     = (new \EdmondsCommerce\PHPQA\PHPUnit\CheckAnnotations())->main($pathToTest);
} catch (\RuntimeException $e) {
    echo "\n".$e->getMessage()."\n";
    exit(1);
}
if ([] === $errors) {
    exit(0);
}
echo "

ERROR:

Found PHPUnit tests missing the @small and/or @medium annotations

";

var_export($errors);
exit(1);
