Json phpunit tests updates, fixes in test php with ignore for deprecated
This commit is contained in:
@@ -16,7 +16,7 @@ final class CoreLibsConvertJsonTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* test list for json convert tests
|
* test list for json convert tests
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array<mixed>
|
||||||
*/
|
*/
|
||||||
public function jsonProvider(): array
|
public function jsonProvider(): array
|
||||||
{
|
{
|
||||||
@@ -54,10 +54,36 @@ final class CoreLibsConvertJsonTest extends TestCase
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @return array<mixed>
|
||||||
|
*/
|
||||||
|
public function jsonArrayProvider(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'valid json' => [
|
||||||
|
[
|
||||||
|
'm' => 2,
|
||||||
|
'f' => 'sub_2'
|
||||||
|
],
|
||||||
|
'{"m":2,"f":"sub_2"}',
|
||||||
|
],
|
||||||
|
'empty json array' => [
|
||||||
|
[],
|
||||||
|
'[]'
|
||||||
|
],
|
||||||
|
'empty json hash' => [
|
||||||
|
['' => ''],
|
||||||
|
'{"":""}'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* json error list
|
* json error list
|
||||||
*
|
*
|
||||||
* @return array JSON error list
|
* @return array<mixed> JSON error list
|
||||||
*/
|
*/
|
||||||
public function jsonErrorProvider(): array
|
public function jsonErrorProvider(): array
|
||||||
{
|
{
|
||||||
@@ -127,7 +153,7 @@ final class CoreLibsConvertJsonTest extends TestCase
|
|||||||
*
|
*
|
||||||
* @param string|null $input
|
* @param string|null $input
|
||||||
* @param bool $flag
|
* @param bool $flag
|
||||||
* @param array $expected
|
* @param array<mixed> $expected
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testJsonConvertToArray(?string $input, bool $flag, array $expected): void
|
public function testJsonConvertToArray(?string $input, bool $flag, array $expected): void
|
||||||
@@ -146,7 +172,8 @@ final class CoreLibsConvertJsonTest extends TestCase
|
|||||||
* @testdox jsonGetLastError $input will be $expected_i/$expected_s [$_dataName]
|
* @testdox jsonGetLastError $input will be $expected_i/$expected_s [$_dataName]
|
||||||
*
|
*
|
||||||
* @param string|null $input
|
* @param string|null $input
|
||||||
* @param string $expected
|
* @param int $expected_i
|
||||||
|
* @param string $expected_s
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testJsonGetLastError(?string $input, int $expected_i, string $expected_s): void
|
public function testJsonGetLastError(?string $input, int $expected_i, string $expected_s): void
|
||||||
@@ -161,6 +188,25 @@ final class CoreLibsConvertJsonTest extends TestCase
|
|||||||
\CoreLibs\Convert\Json::jsonGetLastError(true)
|
\CoreLibs\Convert\Json::jsonGetLastError(true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Undocumented function
|
||||||
|
*
|
||||||
|
* @covers ::jsonConvertArrayTo
|
||||||
|
* @dataProvider jsonArrayProvider
|
||||||
|
* @testdox jsonConvertArrayTo $input (Override: $flag) will be $expected [$_dataName]
|
||||||
|
*
|
||||||
|
* @param array<mixed> $input
|
||||||
|
* @param string $expected
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testJsonConvertArrayto(array $input, string $expected): void
|
||||||
|
{
|
||||||
|
$this->assertEquals(
|
||||||
|
$expected,
|
||||||
|
\CoreLibs\Convert\Json::jsonConvertArrayTo($input)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
parameters:
|
|
||||||
ignoreErrors:
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_escape_bytea expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_escape_identifier expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_escape_literal expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_escape_string expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_execute expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_parameter_status expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_prepare expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_query expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Parameter \\#1 \\$connection of function pg_query_params expects PgSql\\\\Connection\\|string, object\\|resource given\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: www/lib/CoreLibs/DB/SQL/PgSQL.php
|
|
||||||
|
|
||||||
@@ -75,6 +75,7 @@ print "EL_O: <pre>" . print_r($el_o, true) . "</pre>";
|
|||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
print "buildHtml(): <pre>" . htmlentities($el_o->buildHtml()) . "</pre>";
|
print "buildHtml(): <pre>" . htmlentities($el_o->buildHtml()) . "</pre>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
print "phfo(\$el_o): <pre>" . htmlentities($el_o::printHtmlFromObject($el_o, true)) . "</pre>";
|
print "phfo(\$el_o): <pre>" . htmlentities($el_o::printHtmlFromObject($el_o, true)) . "</pre>";
|
||||||
echo "<hr>";
|
echo "<hr>";
|
||||||
print "phfa(\$el_list): <pre>" . htmlentities($el_o::buildHtmlFromList($el_o_list, true)) . "</pre>";
|
print "phfa(\$el_list): <pre>" . htmlentities($el_o::buildHtmlFromList($el_o_list, true)) . "</pre>";
|
||||||
|
|||||||
@@ -63,6 +63,11 @@ print "J/S::E-JSON ERROR: " . $json_class::jsonGetLastError() . ": " . $json_cla
|
|||||||
// print "S::JSON: $json: " . DgS::printAr($output) . "<br>";
|
// print "S::JSON: $json: " . DgS::printAr($output) . "<br>";
|
||||||
// print "S::JSON ERROR: " . Jason::jsonGetLastError() . ": " . Jason::jsonGetLastError(true) . "<br>";
|
// print "S::JSON ERROR: " . Jason::jsonGetLastError() . ": " . Jason::jsonGetLastError(true) . "<br>";
|
||||||
|
|
||||||
|
// convert an array to json
|
||||||
|
$array = ['foo' => 'bar'];
|
||||||
|
$output = Json::jsonConvertArrayTo($array);
|
||||||
|
print "S::JSON: " . DgS::printAr($array) . " => " . $output . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ echo "<br><b>AUTO DETECT</b><br>";
|
|||||||
// DEPRECATED
|
// DEPRECATED
|
||||||
// $get_locale = Language\GetLocale::setLocale();
|
// $get_locale = Language\GetLocale::setLocale();
|
||||||
// print "[AUTO, DEPRECATED]: " . Support::printAr($get_locale) . "<br>";
|
// print "[AUTO, DEPRECATED]: " . Support::printAr($get_locale) . "<br>";
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||||
SITE_LOCALE,
|
SITE_LOCALE,
|
||||||
str_replace('/', '', CONTENT_PATH),
|
str_replace('/', '', CONTENT_PATH),
|
||||||
@@ -58,6 +59,7 @@ $get_locale = Language\GetLocale::setLocaleFromSession(
|
|||||||
BASE . INCLUDES . LOCALE
|
BASE . INCLUDES . LOCALE
|
||||||
);
|
);
|
||||||
print "[NAMED CONSTANTS OUTSIDE]: " . Support::printAr($get_locale) . "<br>";
|
print "[NAMED CONSTANTS OUTSIDE]: " . Support::printAr($get_locale) . "<br>";
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||||
'en',
|
'en',
|
||||||
'foo',
|
'foo',
|
||||||
@@ -74,6 +76,7 @@ $_SESSION['DEFAULT_LOCALE'] = 'ja_JP.UTF-8';
|
|||||||
$_SESSION['DEFAULT_CHARSET'] = 'UTF-8';
|
$_SESSION['DEFAULT_CHARSET'] = 'UTF-8';
|
||||||
$_SESSION['DEFAULT_DOMAIN'] = 'admin';
|
$_SESSION['DEFAULT_DOMAIN'] = 'admin';
|
||||||
$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE;
|
$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE;
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||||
SITE_LOCALE,
|
SITE_LOCALE,
|
||||||
SITE_DOMAIN,
|
SITE_DOMAIN,
|
||||||
@@ -90,6 +93,7 @@ $_SESSION['DEFAULT_LOCALE'] = '00000#####';
|
|||||||
$_SESSION['DEFAULT_CHARSET'] = '';
|
$_SESSION['DEFAULT_CHARSET'] = '';
|
||||||
$_SESSION['DEFAULT_DOMAIN'] = 'admin';
|
$_SESSION['DEFAULT_DOMAIN'] = 'admin';
|
||||||
$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE;
|
$_SESSION['LOCALE_PATH'] = BASE . INCLUDES . LOCALE;
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$get_locale = Language\GetLocale::setLocaleFromSession(
|
$get_locale = Language\GetLocale::setLocaleFromSession(
|
||||||
SITE_LOCALE,
|
SITE_LOCALE,
|
||||||
SITE_DOMAIN,
|
SITE_DOMAIN,
|
||||||
|
|||||||
@@ -35,10 +35,12 @@ print '<div><h1>' . $PAGE_NAME . '</h1></div>';
|
|||||||
print "ALREADY from config.php: " . \CoreLibs\Debug\Support::printAr($_ENV) . "<br>";
|
print "ALREADY from config.php: " . \CoreLibs\Debug\Support::printAr($_ENV) . "<br>";
|
||||||
|
|
||||||
// test .env in local
|
// test .env in local
|
||||||
|
/** @phpstan-ignore-next-line */
|
||||||
$status = \CoreLibs\Get\DotEnv::readEnvFile('.', 'test.env');
|
$status = \CoreLibs\Get\DotEnv::readEnvFile('.', 'test.env');
|
||||||
print "test.env: STATUS: " . $status . "<br>";
|
print "test.env: STATUS: " . $status . "<br>";
|
||||||
print "AFTER reading test.env file: " . \CoreLibs\Debug\Support::printAr($_ENV) . "<br>";
|
print "AFTER reading test.env file: " . \CoreLibs\Debug\Support::printAr($_ENV) . "<br>";
|
||||||
|
|
||||||
print "</body></html>";
|
print "</body></html>";
|
||||||
|
// ;;
|
||||||
|
|
||||||
// __END__
|
// __END__
|
||||||
|
|||||||
Reference in New Issue
Block a user