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