Compare commits
6 Commits
118aacee28
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
188f0b57d0 | ||
|
|
b84fb5cef5 | ||
|
|
9a28c86991 | ||
|
|
38b2ffe82a | ||
|
|
6e547abccb | ||
|
|
676af5e1a4 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,10 +1,8 @@
|
||||
.libs
|
||||
node_modules/
|
||||
composer.lock
|
||||
vendor/
|
||||
**/composer.lock
|
||||
**/vendor/
|
||||
tools/
|
||||
www/composer.lock
|
||||
www/vendor
|
||||
**/.env
|
||||
**/.target
|
||||
package-lock.json
|
||||
|
||||
@@ -62,9 +62,9 @@ fi;
|
||||
php_bin="${PHP_BIN_PATH}${php_version}";
|
||||
echo "Use PHP Version: ${php_version}";
|
||||
if [ "${use_composer}" -eq 1 ]; then
|
||||
echo "Use composer installed phan";
|
||||
echo "Use composer installed";
|
||||
else
|
||||
echo "Use phan installed via phives";
|
||||
echo "Use phive installed";
|
||||
fi;
|
||||
|
||||
if [ ! -f "${php_bin}" ]; then
|
||||
|
||||
@@ -62,9 +62,9 @@ fi;
|
||||
php_bin="${PHP_BIN_PATH}${php_version}";
|
||||
echo "Use PHP Version: ${php_version}";
|
||||
if [ "${use_composer}" -eq 1 ]; then
|
||||
echo "Use composer installed phan";
|
||||
echo "Use composer installed";
|
||||
else
|
||||
echo "Use phan installed via phives";
|
||||
echo "Use phive installed";
|
||||
fi;
|
||||
|
||||
if [ ! -f "${php_bin}" ]; then
|
||||
|
||||
@@ -19,6 +19,7 @@ Available options:
|
||||
-v, --verbose Enable verbose output for PHPunit
|
||||
-c, --composer Use composer version and not the default phives bundle
|
||||
-p, --php VERSION Chose PHP version in the form of "N.N", if not found will exit
|
||||
-C, --coverage Generate code coverage report in text format (default: disabled)
|
||||
EOF
|
||||
exit
|
||||
}
|
||||
@@ -47,6 +48,7 @@ opt_verbose="";
|
||||
php_version="";
|
||||
no_php_version=0;
|
||||
use_composer=0;
|
||||
opt_generate_coverage="";
|
||||
while [ -n "${1-}" ]; do
|
||||
case "${1}" in
|
||||
-t | --testdox)
|
||||
@@ -59,6 +61,10 @@ while [ -n "${1-}" ]; do
|
||||
use_composer=1;
|
||||
shift
|
||||
;;
|
||||
-C | --coverage)
|
||||
opt_generate_coverage="--coverage-text";
|
||||
shift
|
||||
;;
|
||||
-p | --php)
|
||||
php_version="${2-}";
|
||||
shift
|
||||
@@ -81,9 +87,9 @@ fi;
|
||||
php_bin="${PHP_BIN_PATH}${php_version}";
|
||||
echo "Use PHP Version: ${php_version}";
|
||||
if [ "${use_composer}" -eq 1 ]; then
|
||||
echo "Use composer installed phan";
|
||||
echo "Use composer installed";
|
||||
else
|
||||
echo "Use phan installed via phives";
|
||||
echo "Use phive installed";
|
||||
fi;
|
||||
|
||||
if [ ! -f "${php_bin}" ]; then
|
||||
@@ -100,9 +106,14 @@ if [ "${use_composer}" -eq 1 ]; then
|
||||
else
|
||||
PHPUNIT_CALL+=("${BASE_PATH}tools/phpunit");
|
||||
fi;
|
||||
if [ -n "${opt_generate_coverage}" ]; then
|
||||
echo "Will run coverage report";
|
||||
export XDEBUG_MODE=coverage
|
||||
fi;
|
||||
PHPUNIT_CALL+=(
|
||||
"${opt_testdox}"
|
||||
"${opt_verbose}"
|
||||
"${opt_generate_coverage}"
|
||||
"-c" "${PHPUNIT_CONFIG}"
|
||||
"${BASE_PATH}4dev/tests/"
|
||||
);
|
||||
|
||||
@@ -164,6 +164,51 @@ final class CoreLibsConvertJsonTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* test with flags
|
||||
*
|
||||
* @covers ::jsonConvertToArray
|
||||
* @testdox jsonConvertToArray flag test, if flag is used
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testJsonConvertToArrayWithFlags(): void
|
||||
{
|
||||
$input = '{"valid":"json","invalid":"\xB1\x31"}';
|
||||
/* $expected_without_flag = [
|
||||
'valid' => 'json'
|
||||
];
|
||||
$expected_with_flag = [
|
||||
'valid' => 'json',
|
||||
'invalid' => "\xB1\x31"
|
||||
]; */
|
||||
// no idea why in both it throws an erro
|
||||
$expected_without_flag = [];
|
||||
$expected_with_flag = [];
|
||||
$this->assertEquals(
|
||||
$expected_without_flag,
|
||||
\CoreLibs\Convert\Json::jsonConvertToArray($input)
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expected_with_flag,
|
||||
\CoreLibs\Convert\Json::jsonConvertToArray($input, flags:JSON_INVALID_UTF8_IGNORE)
|
||||
);
|
||||
}
|
||||
|
||||
public function testJsonConvertToArrayRemoveThrowFlag(): void
|
||||
{
|
||||
$input = '{"valid":"json","invalid":"\xB1\x31"}';
|
||||
// show NOT throw an exception
|
||||
try {
|
||||
$this->assertEquals(
|
||||
[],
|
||||
\CoreLibs\Convert\Json::jsonConvertToArray($input, flags:JSON_THROW_ON_ERROR)
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
$this->fail('Exception was thrown despite flag removal');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* test json error states
|
||||
*
|
||||
@@ -189,6 +234,49 @@ final class CoreLibsConvertJsonTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* test json error states
|
||||
*
|
||||
* @covers ::jsonValidate
|
||||
* @dataProvider jsonErrorProvider
|
||||
* @testdox jsonValidate $input will be $expected_i/$expected_s [$_dataName]
|
||||
*
|
||||
* @param string|null $input
|
||||
* @param int $expected_i
|
||||
* @param string $expected_s
|
||||
* @return void
|
||||
*/
|
||||
public function testJsonValidateGetLastError(?string $input, int $expected_i, string $expected_s): void
|
||||
{
|
||||
\CoreLibs\Convert\Json::jsonValidate($input);
|
||||
$this->assertEquals(
|
||||
$expected_i,
|
||||
\CoreLibs\Convert\Json::jsonGetLastError()
|
||||
);
|
||||
$this->assertEquals(
|
||||
$expected_s,
|
||||
\CoreLibs\Convert\Json::jsonGetLastError(true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* test json validation
|
||||
*
|
||||
* @covers ::jsonValidate
|
||||
* @testdox jsonValidate test valid and invalid json
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testJsonValidate(): void
|
||||
{
|
||||
$this->assertTrue(
|
||||
\CoreLibs\Convert\Json::jsonValidate('{"valid": "json"}')
|
||||
);
|
||||
$this->assertFalse(
|
||||
\CoreLibs\Convert\Json::jsonValidate('not valid json')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
||||
@@ -45,7 +45,6 @@ use CoreLibs\DB\Support\ConvertPlaceholder;
|
||||
* Test class for DB\IO + DB\SQL\PgSQL
|
||||
* This will only test the PgSQL parts
|
||||
* @coversDefaultClass \CoreLibs\DB\IO
|
||||
* @coversDefaultClass \CoreLibs\DB\SQL\PgSQL
|
||||
* @testdox \CoreLibs\DB\IO method tests for SQL\PgSQL
|
||||
*/
|
||||
final class CoreLibsDBIOTest extends TestCase
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$set = 0;
|
||||
foreach (['/../../www', '/../www', '/../..', '/..', '/../../src', '/../src'] as $src) {
|
||||
foreach (['/../../www', '/../www', '/../../src', '/../src', '/../..', '/..'] as $src) {
|
||||
if (is_file(dirname(__DIR__) . $src . '/vendor/autoload.php')) {
|
||||
require dirname(__DIR__) . $src . '/vendor/autoload.php';
|
||||
$set = 1;
|
||||
|
||||
10
phpunit.xml
10
phpunit.xml
@@ -10,4 +10,14 @@
|
||||
<directory>4dev/tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<coverage processUncoveredFiles="true">
|
||||
<include>
|
||||
<directory suffix=".php">./www/lib/CoreLibs</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
<!-- <source>
|
||||
<include>
|
||||
<directory>./www/lib/CoreLibs</directory>
|
||||
</include>
|
||||
</source> -->
|
||||
</phpunit>
|
||||
|
||||
@@ -46,6 +46,7 @@ $json = '["f: {b"""ar}]';
|
||||
$output = Json::jsonConvertToArray($json);
|
||||
print "S::E-JSON: $json: " . DgS::printAr($output) . "<br>";
|
||||
print "S::E-JSON ERROR: " . Json::jsonGetLastError() . ": " . Json::jsonGetLastError(true) . "<br>";
|
||||
print "S::E Validate: " . Json::jsonValidate($json) . ": " . Json::jsonGetLastError(true) . "<br>";
|
||||
|
||||
// direct
|
||||
$json = '{"direct": "static function call"}';
|
||||
@@ -58,6 +59,24 @@ $output = $json_class::jsonConvertToArray($json);
|
||||
print "J/S::E-JSON: $json: " . DgS::printAr($output) . "<br>";
|
||||
print "J/S::E-JSON ERROR: " . $json_class::jsonGetLastError() . ": " . $json_class::jsonGetLastError(true) . "<br>";
|
||||
|
||||
echo "<hr>";
|
||||
$json = '{"valid":"json","invalid":"\xB1\x31"}';
|
||||
// $json = '{"valid":"json","invalid":"abc\x80def"}';
|
||||
$output_no_flag = Json::jsonConvertToArray($json);
|
||||
print "No Flag JSON: $json: " . DgS::printAr($output_no_flag) . "<br>";
|
||||
print "No Flag JSON ERROR: " . Json::jsonGetLastError() . ": " . Json::jsonGetLastError(true) . "<br>";
|
||||
$output_flag = Json::jsonConvertToArray($json, flags:JSON_INVALID_UTF8_IGNORE);
|
||||
print "No Flag JSON: $json: " . DgS::printAr($output_flag) . "<br>";
|
||||
print "No Flag JSON ERROR: " . Json::jsonGetLastError() . ": " . Json::jsonGetLastError(true) . "<br>";
|
||||
$output_raw = json_decode($json, true, flags:JSON_INVALID_UTF8_IGNORE);
|
||||
print "No Flag JSON RAW (F-1): $json: " . DgS::printAr($output_raw) . "<br>";
|
||||
$output_raw = json_decode($json, true, flags:JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
print "No Flag JSON RAW (F-2): $json: " . DgS::printAr($output_raw) . "<br>";
|
||||
$output_raw = json_decode($json, true);
|
||||
print "No Flag JSON RAW: $json: " . DgS::printAr($output_raw) . "<br>";
|
||||
echo "<hr>";
|
||||
|
||||
|
||||
// $json = '{"foo": "bar"}';
|
||||
// $output = Jason::jsonConvertToArray($json);
|
||||
// print "S::JSON: $json: " . DgS::printAr($output) . "<br>";
|
||||
|
||||
9680
www/admin/layout/javascript/jquery-4.0.0.js
vendored
Normal file
9680
www/admin/layout/javascript/jquery-4.0.0.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
www/admin/layout/javascript/jquery-4.0.0.min.js
vendored
Normal file
2
www/admin/layout/javascript/jquery-4.0.0.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -17,7 +17,7 @@
|
||||
"repositories": {
|
||||
"git.egplusww.jp.Composer": {
|
||||
"type": "composer",
|
||||
"url": "https://git.egplusww.jp/api/packages/Composer/composer"
|
||||
"url": "https://packages.omnicomproduction.jp/api/packages/Composer/composer"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
|
||||
@@ -27,10 +27,14 @@ class Json
|
||||
* set original value as array
|
||||
* @return array<mixed> returns an array from the json values
|
||||
*/
|
||||
public static function jsonConvertToArray(?string $json, bool $override = false): array
|
||||
public static function jsonConvertToArray(?string $json, bool $override = false, int $flags = 0): array
|
||||
{
|
||||
if ($json !== null) {
|
||||
$_json = json_decode($json, true);
|
||||
// if flags has JSON_THROW_ON_ERROR remove it
|
||||
if ($flags & JSON_THROW_ON_ERROR) {
|
||||
$flags = $flags & ~JSON_THROW_ON_ERROR;
|
||||
}
|
||||
$_json = json_decode($json, true, flags:$flags);
|
||||
if (self::$json_last_error = json_last_error()) {
|
||||
if ($override == true) {
|
||||
// init return as array with original as element
|
||||
@@ -65,6 +69,21 @@ class Json
|
||||
return (string)$json_string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate if a json string could be decoded.
|
||||
* Weill set the internval last error state and info can be read with jsonGetLastError
|
||||
*
|
||||
* @param string $json
|
||||
* @param int $flags only JSON_INVALID_UTF8_IGNORE is currently allowed
|
||||
* @return bool
|
||||
*/
|
||||
public static function jsonValidate(string $json, int $flags = 0): bool
|
||||
{
|
||||
$json_valid = json_validate($json, flags:$flags);
|
||||
self::$json_last_error = json_last_error();
|
||||
return $json_valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns human readable string for json errors thrown in jsonConvertToArray
|
||||
* Source: https://www.php.net/manual/en/function.json-last-error.php
|
||||
|
||||
@@ -134,8 +134,8 @@ class Support
|
||||
* Convert bool value to string value. Short name alias for printBool
|
||||
*
|
||||
* @param bool $bool Bool value to be transformed
|
||||
* @param string $true [='true'] Override default string 'true'
|
||||
* @param string $false [=false'] Override default string 'false'
|
||||
* @param string $true [=true] Override default string 'true'
|
||||
* @param string $false [=false] Override default string 'false'
|
||||
* @return string $true or $false string for true/false bool
|
||||
*/
|
||||
public static function prBl(
|
||||
|
||||
Reference in New Issue
Block a user