Test updates: add timezone, some fixes for debug callers
This commit is contained in:
@@ -12,6 +12,8 @@ use PHPUnit\Framework\TestCase;
|
|||||||
*/
|
*/
|
||||||
final class CoreLibsAAASetupDataTest extends TestCase
|
final class CoreLibsAAASetupDataTest extends TestCase
|
||||||
{
|
{
|
||||||
|
public const TIME_ZONE = 'Asia/Tokyo';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Covers nothing
|
* Covers nothing
|
||||||
*
|
*
|
||||||
@@ -34,6 +36,9 @@ final class CoreLibsAAASetupDataTest extends TestCase
|
|||||||
BASE,
|
BASE,
|
||||||
'BASE Path set check'
|
'BASE Path set check'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// if time zone is not set, errors can happen
|
||||||
|
ini_set('date.timezone', self::TIME_ZONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,25 +24,25 @@ if [ -z "${db_user}" ] || [ -z "${db_name}" ] || [ -z "${db_host}" ]; then
|
|||||||
exit 2;
|
exit 2;
|
||||||
fi;
|
fi;
|
||||||
# drop database, on error exit with 3
|
# drop database, on error exit with 3
|
||||||
dropdb -U ${db_user} -h ${db_host} ${db_name} 2>&1;
|
dropdb -U "${db_user}" -h "${db_host}" "${db_name}" 2>&1;
|
||||||
if [ $? -ne 0 ]; then
|
if ! $?; then
|
||||||
echo 3;
|
echo 3;
|
||||||
exit 3;
|
exit 3;
|
||||||
fi;
|
fi;
|
||||||
# create database, on error exit with 4
|
# create database, on error exit with 4
|
||||||
createdb -U ${db_user} -O ${db_user} -h ${db_host} -E utf8 ${db_name} 2>&1;
|
createdb -U "${db_user}" -O "${db_user}" -h "${db_host}" -E utf8 "${db_name}" 2>&1;
|
||||||
if [ $? -ne 0 ]; then
|
if ! $?; then
|
||||||
echo 4;
|
echo 4;
|
||||||
exit 4;
|
exit 4;
|
||||||
fi;
|
fi;
|
||||||
# if error 5 thrown, test with enabled below
|
# if error 5 thrown, test with enabled below
|
||||||
if [ ! -z "${5}" ]; then
|
if [ -n "${5}" ]; then
|
||||||
psql -U ${db_user} -h ${db_host} -f ${load_sql} ${db_name};
|
psql -U "${db_user}" -h "${db_host}" -f "${load_sql}" "${db_name}";
|
||||||
else
|
else
|
||||||
# load data (redirect ALL error to null), on error exit with 5
|
# load data (redirect ALL error to null), on error exit with 5
|
||||||
psql -U ${db_user} -h ${db_host} -f ${load_sql} ${db_name} 2>&1 1>/dev/null 2>/dev/null;
|
psql -U "${db_user}" -h "${db_host}" -f "${load_sql}" "${db_name}" 2>&1 1>/dev/null 2>/dev/null;
|
||||||
fi;
|
fi;
|
||||||
if [ $? -ne 0 ]; then
|
if ! $?; then
|
||||||
echo 5;
|
echo 5;
|
||||||
exit 5;
|
exit 5;
|
||||||
fi;
|
fi;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php // phpcs:disable Generic.Files.LineLength
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
@@ -71,15 +71,16 @@ final class CoreLibsCombinedDateTimeTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @covers ::dateStringFormat
|
* @covers ::dateStringFormat
|
||||||
* @dataProvider timestampProvider
|
* @dataProvider timestampProvider
|
||||||
* @testdox dateStringFormat $input (microtime $flag) will be $expected [$_dataName]
|
* @testdox dateStringFormat $input (mt $flag_show_micro, float mt $flag_micro_as_float) will be $expected [$_dataName]
|
||||||
*
|
*
|
||||||
* @param int|float $input
|
* @param int|float $input
|
||||||
* @param bool $flag
|
* @param bool $flag_show_micro
|
||||||
|
* @param bool $flag_micro_as_float
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testDateStringFormat(
|
public function testDateStringFormat(
|
||||||
$input,
|
int|float $input,
|
||||||
bool $flag_show_micro,
|
bool $flag_show_micro,
|
||||||
bool $flag_micro_as_float,
|
bool $flag_micro_as_float,
|
||||||
string $expected
|
string $expected
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ final class CoreLibsDebugSupportTest extends TestCase
|
|||||||
* @dataProvider printTimeProvider
|
* @dataProvider printTimeProvider
|
||||||
* @testdox printTime test with $microtime and match to regex [$_dataName]
|
* @testdox printTime test with $microtime and match to regex [$_dataName]
|
||||||
*
|
*
|
||||||
* @param int|null $mircrotime
|
* @param ?int $microtime
|
||||||
* @param string $expected
|
* @param string $regex
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testPrintTime(?int $microtime, string $regex): void
|
public function testPrintTime(?int $microtime, string $regex): void
|
||||||
@@ -460,10 +460,8 @@ final class CoreLibsDebugSupportTest extends TestCase
|
|||||||
* Undocumented function
|
* Undocumented function
|
||||||
*
|
*
|
||||||
* @cover ::getCallerFileLine
|
* @cover ::getCallerFileLine
|
||||||
* @testWith ["vendor/phpunit/phpunit/src/Framework/TestCase.php:6434","phar:///home/clemens/.phive/phars/phpunit-9.6.13.phar/phpunit/Framework/TestCase.php:6434"]
|
|
||||||
* @testdox getCallerFileLine check based on regex .../Framework/TestCase.php:\d+ [$_dataName]
|
* @testdox getCallerFileLine check based on regex .../Framework/TestCase.php:\d+ [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string $expected
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetCallerFileLine(): void
|
public function testGetCallerFileLine(): void
|
||||||
@@ -471,15 +469,19 @@ final class CoreLibsDebugSupportTest extends TestCase
|
|||||||
// regex prefix with path "/../" and then fixed vendor + \d+
|
// regex prefix with path "/../" and then fixed vendor + \d+
|
||||||
// or phar start if phiev installed
|
// or phar start if phiev installed
|
||||||
// phar:///home/clemens/.phive/phars/phpunit-9.6.13.phar/phpunit/Framework/TestCase.php
|
// phar:///home/clemens/.phive/phars/phpunit-9.6.13.phar/phpunit/Framework/TestCase.php
|
||||||
|
// phar:///usr/local/bin/phpunit/phpunit/Framework/TestCase.php
|
||||||
$regex = "/^("
|
$regex = "/^("
|
||||||
. "\/.*\/vendor\/phpunit\/phpunit\/src"
|
. "\/.*\/vendor\/phpunit\/phpunit\/src"
|
||||||
. "|"
|
. "|"
|
||||||
. "phar:\/\/\/.*\.phive\/phars\/phpunit-\d+\.\d+\.\d+\.phar\/phpunit"
|
. "phar:\/\/\/.*\.phive\/phars\/phpunit-\d+\.\d+\.\d+\.phar\/phpunit"
|
||||||
|
. "|"
|
||||||
|
. "phar:\/\/\/usr\/local\/bin\/phpunit\/phpunit"
|
||||||
. ")"
|
. ")"
|
||||||
. "\/Framework\/TestCase.php:\d+$/";
|
. "\/Framework\/TestCase.php:\d+$/";
|
||||||
$this->assertMatchesRegularExpression(
|
$this->assertMatchesRegularExpression(
|
||||||
$regex,
|
$regex,
|
||||||
Support::getCallerFileLine()
|
Support::getCallerFileLine(),
|
||||||
|
'Failed for: ' . Support::getCallerFileLine()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,7 +524,7 @@ final class CoreLibsDebugSupportTest extends TestCase
|
|||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
$compare,
|
$compare,
|
||||||
'assert expected 10'
|
'assert expected 10: ' . print_r($compare, true)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
@@ -545,7 +547,7 @@ final class CoreLibsDebugSupportTest extends TestCase
|
|||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
$compare,
|
$compare,
|
||||||
'assert expected 11'
|
'assert expected 11: ' . print_r($compare, true)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
@@ -565,7 +567,7 @@ final class CoreLibsDebugSupportTest extends TestCase
|
|||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$expected,
|
$expected,
|
||||||
$compare,
|
$compare,
|
||||||
'assert expected 12'
|
'assert expected 12: ' . print_r($compare, true)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -589,7 +591,7 @@ final class CoreLibsDebugSupportTest extends TestCase
|
|||||||
if ($call_stack < 8) {
|
if ($call_stack < 8) {
|
||||||
$this->assertFalse(true, 'getCallStack too low: 8');
|
$this->assertFalse(true, 'getCallStack too low: 8');
|
||||||
} else {
|
} else {
|
||||||
$this->assertTrue(true, 'getCallSteck ok');
|
$this->assertTrue(true, 'getCallStack ok');
|
||||||
}
|
}
|
||||||
// just test top entry
|
// just test top entry
|
||||||
$first = array_shift($call_stack);
|
$first = array_shift($call_stack);
|
||||||
|
|||||||
Reference in New Issue
Block a user