initialiser msg::
This commit is contained in:
parent
2b97eebc92
commit
b6607d9d27
@ -3,19 +3,21 @@ namespace nulib\tests;
|
||||
|
||||
use Error;
|
||||
use Exception;
|
||||
use nulib\cache\cache;
|
||||
use nulib\db\sqlite\SqliteStorage;
|
||||
use PHPUnit\Framework\Constraint\Exception as ConstraintException;
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase {
|
||||
const UNCHANGED_ARRAY = ["unchanged"];
|
||||
|
||||
static function assertException($class, callable $func, ...$args) {
|
||||
static function assertException($exceptionClass, callable $func, ...$args) {
|
||||
try {
|
||||
call_user_func_array($func, $args);
|
||||
$e = null;
|
||||
} catch (Exception $e) {
|
||||
}
|
||||
self::assertThat($e, new ConstraintException($class));
|
||||
self::assertThat($e, new ConstraintException($exceptionClass));
|
||||
}
|
||||
|
||||
static function assertNotException(callable $func, ...$args) {
|
||||
@ -29,13 +31,13 @@ abstract class TestCase extends BaseTestCase {
|
||||
self::assertTrue($e === null, $message);
|
||||
}
|
||||
|
||||
static function assertError($class, callable $func, ...$args) {
|
||||
static function assertError($errorClass, callable $func, ...$args) {
|
||||
try {
|
||||
call_user_func_array($func, $args);
|
||||
$e = null;
|
||||
} catch (Error $e) {
|
||||
}
|
||||
self::assertThat($e, new ConstraintException($class));
|
||||
self::assertThat($e, new ConstraintException($errorClass));
|
||||
}
|
||||
|
||||
static function assertNotError(callable $func, ...$args) {
|
||||
@ -57,6 +59,13 @@ abstract class TestCase extends BaseTestCase {
|
||||
self::assertSame($expected, array_values($actual));
|
||||
}
|
||||
|
||||
static function setUpBeforeClass(): void {
|
||||
parent::setUpBeforeClass();
|
||||
if (class_exists('nulib\output\msg')) {
|
||||
\nulib\output\msg::set_messenger_class(\nulib\output\std\StdMessenger::class);
|
||||
}
|
||||
}
|
||||
|
||||
protected $origTz = '';
|
||||
|
||||
/**
|
||||
@ -64,11 +73,13 @@ abstract class TestCase extends BaseTestCase {
|
||||
* de date soient corrects
|
||||
*/
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->origTz = date_default_timezone_get();
|
||||
date_default_timezone_set("Indian/Reunion");
|
||||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
parent::tearDown();
|
||||
if ($this->origTz !== '') {
|
||||
date_default_timezone_set($this->origTz);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user