2021-03-22 03:26:05 +13:00
|
|
|
<?php
|
2022-05-24 02:54:50 +12:00
|
|
|
|
2021-03-22 03:26:05 +13:00
|
|
|
namespace Appwrite\Tests;
|
|
|
|
|
|
|
|
use PHPUnit\Runner\AfterTestHook;
|
2023-02-13 18:55:11 +13:00
|
|
|
use Exception;
|
2021-03-22 03:26:05 +13:00
|
|
|
|
|
|
|
class TestHook implements AfterTestHook
|
|
|
|
{
|
2023-02-13 19:02:20 +13:00
|
|
|
protected const MAX_SECONDS_ALLOWED = 15;
|
2021-03-22 03:26:05 +13:00
|
|
|
public function executeAfterTest(string $test, float $time): void
|
|
|
|
{
|
2022-05-24 02:54:50 +12:00
|
|
|
printf(
|
2022-08-03 16:17:49 +12:00
|
|
|
"%s ended in %s milliseconds\n",
|
2022-05-24 02:54:50 +12:00
|
|
|
$test,
|
2022-08-03 16:17:49 +12:00
|
|
|
$time * 1000
|
2021-03-22 03:26:05 +13:00
|
|
|
);
|
2023-02-13 18:55:11 +13:00
|
|
|
|
|
|
|
if($time > self::MAX_SECONDS_ALLOWED) {
|
2023-02-13 19:24:22 +13:00
|
|
|
fwrite(STDOUT, sprintf("\e[31mThe %s test is slow, it took %s seconds!\n\e[0m", $test, $time));
|
2023-02-13 18:55:11 +13:00
|
|
|
}
|
2021-03-22 03:26:05 +13:00
|
|
|
}
|
2022-05-24 02:54:50 +12:00
|
|
|
}
|