diff --git a/Code/Lib/JcsEddsa2022.php b/Code/Lib/JcsEddsa2022.php index d88dfb846..efa4f8a92 100644 --- a/Code/Lib/JcsEddsa2022.php +++ b/Code/Lib/JcsEddsa2022.php @@ -21,7 +21,7 @@ class JcsEddsa2022 $options = [ 'type' => 'DataIntegrityProof', 'cryptosuite' => 'eddsa-jcs-2022', - 'created' => datetime_convert(format: ATOM_TIME), + 'created' => new Time(format: ATOM_TIME), 'verificationMethod' => Channel::url($channel) . '#' . $pubkey, 'proofPurpose' => 'assertionMethod', ]; diff --git a/Code/Lib/Time.php b/Code/Lib/Time.php new file mode 100644 index 000000000..7547eb96d --- /dev/null +++ b/Code/Lib/Time.php @@ -0,0 +1,60 @@ +format($format); + } + + try { + $from_obj = new DateTimeZone($from); + } catch (Exception $e) { + $from_obj = new DateTimeZone('UTC'); + } + + try { + $d = new DateTime($datetime, $from_obj); + } catch (Exception $e) { + logger('exception: ' . $e->getMessage()); + $d = new DateTime('now', $from_obj); + } + + try { + $to_obj = new DateTimeZone($to); + } catch (Exception $e) { + $to_obj = new DateTimeZone('UTC'); + } + + $d->setTimeZone($to_obj); + + return($d->format($format)); + } +} diff --git a/boot.php b/boot.php index 91dcc3ee6..b65740c78 100755 --- a/boot.php +++ b/boot.php @@ -91,7 +91,7 @@ function sys_boot() { if (! App::$install) { DBA::dba_factory($db_host, $db_port, $db_user, $db_pass, $db_data, $db_type, App::$install); - if (! DBA::$dba->connected) { + if (! DBA::$dba->connected && !defined('UNIT_TEST')) { system_unavailable(); } diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index d925d62f4..b86e4d2f1 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -48,6 +48,10 @@ class DBA self::$dba = null; self::$dbtype = intval($dbtype); + if (defined('UNIT_TEST')) + return self::$dba; + } + if (self::$dbtype == DBTYPE_POSTGRES) { if (!($port)) { $port = 5432; diff --git a/tests/bootstrap.php b/tests/bootstrap.php index c77b2c2fe..808311ac2 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -6,4 +6,4 @@ set_include_path( . '../' ); define('UNIT_TESTING', 1); -require_once('include/cli_startup.php'); +require_once('boot.php');