diff --git a/4dev/tests/CoreLibsDebugLoggingTest.php b/4dev/tests/CoreLibsDebugLoggingTest.php
new file mode 100644
index 00000000..6bb5d1c5
--- /dev/null
+++ b/4dev/tests/CoreLibsDebugLoggingTest.php
@@ -0,0 +1,36 @@
+ [
0 => null,
- 1 => '/^\d{4}\.\d{5,}$/'
+ 1 => '/^\d{4}\.\d{1,}$/'
],
'nanoseconds' => [
0 => 'ns',
@@ -28,19 +26,19 @@ final class CoreLibsDebugRunningTimeTest extends TestCase
],
'microseconds' => [
0 => 'ys',
- 1 => '/^\d{7}\.\d{3}$/'
+ 1 => '/^\d{7}\.\d{1,}$/'
],
'milliseconds' => [
0 => 'ms',
- 1 => '/^\d{4}\.\d{6}$/'
+ 1 => '/^\d{4}\.\d{1,}$/'
],
'seconds' => [
0 => 's',
- 1 => '/^\d{1}\.\d{9}$/'
+ 1 => '/^\d{1}\.\d{4,}$/'
],
'invalid fallback to ms' => [
0 => 'invalid',
- 1 => '/^\d{4}\.\d{6}$/'
+ 1 => '/^\d{4}\.\d{1,}$/'
]
];
}
@@ -49,9 +47,11 @@ final class CoreLibsDebugRunningTimeTest extends TestCase
{
return [
'run time test' => [
- 0 => '/^\d{1}$/',
- 1 => '/^Start: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 0\.\d{7,}$/',
- 2 => '/^Start:$/'
+ 0 => '/^\d{1,}\.\d{1,}$/',
+ 1 => '/^Start: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 0\.\d{8}, $/',
+ 2 => '/^Start: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 0\.\d{8}, '
+ . 'End: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 0\.\d{8}, '
+ . 'Run: \d{1,}\.\d{1,} s$/'
]
];
}
@@ -80,6 +80,7 @@ final class CoreLibsDebugRunningTimeTest extends TestCase
} else {
$end = \CoreLibs\Debug\RunningTime::hrRunningTime($out_time);
}
+ // print "E: " . $end . "\n";
$this->assertMatchesRegularExpression(
$expected,
(string)$end
@@ -100,20 +101,24 @@ final class CoreLibsDebugRunningTimeTest extends TestCase
public function testRunningTime(string $expected_number, string $expected_start, string $expected_end): void
{
$start = \CoreLibs\Debug\RunningTime::runningTime(true);
+ // print "Start: " . $start . "\n";
$this->assertEquals(
0,
$start
);
+ // print "STRING: " . \CoreLibs\Debug\RunningTime::runningTimeString() . "\n";
$this->assertMatchesRegularExpression(
$expected_start,
\CoreLibs\Debug\RunningTime::runningTimeString()
);
time_nanosleep(1, 500);
$end = \CoreLibs\Debug\RunningTime::runningTime(true);
+ // print "Start: " . $end . "\n";
$this->assertMatchesRegularExpression(
$expected_number,
(string)$end
);
+ // print "STRING: " . \CoreLibs\Debug\RunningTime::runningTimeString() . "\n";
$this->assertMatchesRegularExpression(
$expected_end,
\CoreLibs\Debug\RunningTime::runningTimeString()
diff --git a/www/admin/class_test.array.php b/www/admin/class_test.array.php
index df7c4c97..98524a19 100644
--- a/www/admin/class_test.array.php
+++ b/www/admin/class_test.array.php
@@ -65,6 +65,8 @@ echo "ARRAYSEARCHRECURSIVE(email, [array]['input'], type): "
// all return
echo "ARRAYSEARCHRECURSIVEALL(email, [array], type): "
. Dgs::printAr((array)ArrayHandler::arraySearchRecursiveAll('email', $test_array, 'type')) . "
";
+ echo "ARRAYSEARCHRECURSIVEALL(email, [array], type, false): "
+ . Dgs::printAr((array)ArrayHandler::arraySearchRecursiveAll('email', $test_array, 'type', false)) . "
";
// simple search
echo "ARRAYSEARCHSIMPLE([array], type, email): "
@@ -139,24 +141,6 @@ function rec(string $pre, string $cur, array $node = [])
return $node;
}
-/**
- * flatten array down to own level
- *
- * @param array $array
- * @param array $return
- * @return array
- */
-function flattenArrayKey(array $array, array $return = [])
-{
- foreach ($array as $key => $sub) {
- $return[] = $key;
- if (count($sub) > 0) {
- $return = flattenArrayKey($sub, $return);
- }
- }
- return $return;
-}
-
// $test = [
// 'A' => [
// 'B' => [],
@@ -193,7 +177,34 @@ $test = rec('F', 'U', $test);
$test = rec('', 'Al', $test);
$test = rec('B', 'B1', $test);
print "ORIGINAL: " . \CoreLibs\Debug\Support::printAr($test) . "
";
-print "FLATTEN: " . \CoreLibs\Debug\Support::printAr(flattenArrayKey($test)) . "
";
+print "FLATTEN-c: " . \CoreLibs\Debug\Support::printAr(ArrayHandler::flattenArrayKey($test)) . "
";
+
+$test = [
+ 'a' => ['a1' => 'a1foo', 'a2' => 'a1bar'],
+ 1 => 'bar',
+ 'c' => [2, 3, 4],
+ 'd' => [
+ 'e' => [
+ 'de1' => 'subfoo', 'de2' => 'subbar', 'a2' => 'a1bar'
+ ]
+ ]
+];
+print "ORIGINAL: " . \CoreLibs\Debug\Support::printAr($test) . "
";
+print "FLATTEN: " . \CoreLibs\Debug\Support::printAr(ArrayHandler::flattenArrayKey($test)) . "
";
+
+// genAssocArray
+$db_array = [
+ 0 => ['a' => 'a1', 'b' => 2],
+ 1 => ['a' => 'a2', 'b' => 3],
+ 2 => ['a' => '', 'b' => ''],
+];
+// $key = false;
+$key = 'a';
+// $value = false;
+$value = 'b';
+$flag = false;
+$output = \CoreLibs\Combined\ArrayHandler::genAssocArray($db_array, $key, $value, $flag);
+print "OUTPUT: " . \CoreLibs\Debug\Support::printAr($output) . "
";
// error message
print $basic->log->printErrorMsg();
diff --git a/www/admin/class_test.byte.php b/www/admin/class_test.byte.php
index 7cbacf84..b255ebc3 100644
--- a/www/admin/class_test.byte.php
+++ b/www/admin/class_test.byte.php
@@ -43,10 +43,23 @@ $byte = 254779258;
$string = '242.98 MB';
// static
print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte) . "
";
+print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_SI) . "
";
+print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_ADJUST) . "
";
+print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_NOSPACE) . "
";
+print "S::BYTE FROM: $string: " . $byte_class::stringByteFormat($string) . "
";
+//
+$byte = 314572800;
+$string = '300 MB';
+print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte) . "
";
+print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_SI) . "
";
+print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_ADJUST) . "
";
+print "S::BYTE TO: $byte: "
+ . $byte_class::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_ADJUST | Byte::BYTE_FORMAT_NOSPACE) . "
";
+print "S::BYTE TO: $byte: " . $byte_class::humanReadableByteFormat($byte, Byte::BYTE_FORMAT_NOSPACE) . "
";
print "S::BYTE FROM: $string: " . $byte_class::stringByteFormat($string) . "
";
// *** BYTES TEST ***
-$bytes = array(
+$bytes = [
-123123123,
999999, // KB-1
999999999, // MB-1
@@ -56,7 +69,7 @@ $bytes = array(
999999999999999999, // PB-1
9223372036854775807, // MAX INT
999999999999999999999, // EB-1
-);
+];
print "BYTE FORMAT TESTS
";
foreach ($bytes as $byte) {
print '