appwrite/tests/extensions/TestHook.php

23 lines
525 B
PHP
Raw Normal View History

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