Compare commits
2 Commits
8cab7b6064
...
5ecc9ac3d7
Author | SHA1 | Date | |
---|---|---|---|
5ecc9ac3d7 | |||
88436296e7 |
1
.idea/nulib-base.iml
generated
1
.idea/nulib-base.iml
generated
@ -4,6 +4,7 @@
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/php/src" isTestSource="false" packagePrefix="nulib\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/php/tests" isTestSource="true" packagePrefix="nulib\" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/php/vendor" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
|
14
.idea/php-test-framework.xml
generated
Normal file
14
.idea/php-test-framework.xml
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PhpTestFrameworkVersionCache">
|
||||
<tools_cache>
|
||||
<tool tool_name="PHPUnit">
|
||||
<cache>
|
||||
<versions>
|
||||
<info id="Local/php/vendor/autoload.php" version="9.6.23" />
|
||||
</versions>
|
||||
</cache>
|
||||
</tool>
|
||||
</tools_cache>
|
||||
</component>
|
||||
</project>
|
12
.idea/php.xml
generated
12
.idea/php.xml
generated
@ -1,5 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="MessDetector">
|
||||
<phpmd_settings>
|
||||
<phpmd_by_interpreter asDefaultInterpreter="true" interpreter_id="846389f7-9fb5-4173-a868-1dc6b8fbb3fa" timeout="30000" />
|
||||
</phpmd_settings>
|
||||
</component>
|
||||
<component name="MessDetectorOptionsConfiguration">
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
@ -10,6 +15,11 @@
|
||||
<option name="highlightLevel" value="WARNING" />
|
||||
<option name="transferred" value="true" />
|
||||
</component>
|
||||
<component name="PhpCodeSniffer">
|
||||
<phpcs_settings>
|
||||
<phpcs_by_interpreter asDefaultInterpreter="true" interpreter_id="846389f7-9fb5-4173-a868-1dc6b8fbb3fa" timeout="30000" />
|
||||
</phpcs_settings>
|
||||
</component>
|
||||
<component name="PhpIncludePathManager">
|
||||
<include_path>
|
||||
<path value="$PROJECT_DIR$/php/vendor/symfony/polyfill-ctype" />
|
||||
@ -55,7 +65,7 @@
|
||||
</component>
|
||||
<component name="PhpUnit">
|
||||
<phpunit_settings>
|
||||
<PhpUnitSettings configuration_file_path="$PROJECT_DIR$/php/vendor/sebastian/object-enumerator/phpunit.xml" custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" use_configuration_file="true" />
|
||||
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/php/vendor/autoload.php" phpunit_phar_path="" />
|
||||
</phpunit_settings>
|
||||
</component>
|
||||
<component name="PsalmOptionsConfiguration">
|
||||
|
10
.idea/phpunit.xml
generated
Normal file
10
.idea/phpunit.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PHPUnit">
|
||||
<option name="directories">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/tests" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -32,19 +32,29 @@ abstract class CapacitorStorage {
|
||||
return $channel;
|
||||
}
|
||||
|
||||
/** DOIT être défini dans les classes dérivées */
|
||||
const PRIMARY_KEY_DEFINITION = null;
|
||||
const PRIMARY_KEY_DEFINITION = [
|
||||
"id_" => "genserial",
|
||||
];
|
||||
|
||||
# les définitions sont par défaut pour MariaDB/MySQL
|
||||
const SERDATA_DEFINITION = "mediumtext";
|
||||
const SERSUM_DEFINITION = "varchar(40)";
|
||||
const SERTS_DEFINITION = "datetime";
|
||||
const GENSERIAL_DEFINITION = "integer primary key autoincrement";
|
||||
const GENLIC_DEFINITION = "varchar(80)";
|
||||
const GENLIB_DEFINITION = "varchar(255)";
|
||||
const GENTEXT_DEFINITION = "mediumtext";
|
||||
|
||||
protected static function sercol($def): string {
|
||||
protected static function gencol($def): string {
|
||||
if (!is_string($def)) $def = strval($def);
|
||||
switch ($def) {
|
||||
case "serdata": $def = static::SERDATA_DEFINITION; break;
|
||||
case "sersum": $def = static::SERSUM_DEFINITION; break;
|
||||
case "serts": $def = static::SERTS_DEFINITION; break;
|
||||
case "genserial": $def = static::GENSERIAL_DEFINITION; break;
|
||||
case "genlic": $def = static::GENLIC_DEFINITION; break;
|
||||
case "genlib": $def = static::GENLIB_DEFINITION; break;
|
||||
case "gentext": $def = static::GENTEXT_DEFINITION; break;
|
||||
}
|
||||
return $def;
|
||||
}
|
||||
@ -81,7 +91,7 @@ abstract class CapacitorStorage {
|
||||
$mindex++;
|
||||
} else {
|
||||
if ($mdef) {
|
||||
$definitions[$mcol] = self::sercol($mdef);
|
||||
$definitions[$mcol] = self::gencol($mdef);
|
||||
} else {
|
||||
unset($definitions[$mcol]);
|
||||
}
|
||||
@ -92,7 +102,7 @@ abstract class CapacitorStorage {
|
||||
$constraints[] = $def;
|
||||
}
|
||||
} else {
|
||||
$definitions[$col] = self::sercol($def);
|
||||
$definitions[$col] = self::gencol($def);
|
||||
}
|
||||
}
|
||||
return cl::merge($definitions, $constraints);
|
||||
|
@ -19,10 +19,6 @@ class MysqlStorage extends CapacitorStorage {
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
const PRIMARY_KEY_DEFINITION = [
|
||||
"id_" => "integer primary key auto_increment",
|
||||
];
|
||||
|
||||
protected function tableExists(string $tableName): bool {
|
||||
$db = $this->db;
|
||||
$found = $db->get([
|
||||
|
@ -9,6 +9,8 @@ class PgsqlStorage extends CapacitorStorage {
|
||||
const SERDATA_DEFINITION = "text";
|
||||
const SERSUM_DEFINITION = "varchar(40)";
|
||||
const SERTS_DEFINITION = "timestamp";
|
||||
const GENSERIAL_DEFINITION = "serial primary key";
|
||||
const GENTEXT_DEFINITION = "text";
|
||||
|
||||
function __construct($pgsql) {
|
||||
$this->db = Pgsql::with($pgsql);
|
||||
@ -20,10 +22,6 @@ class PgsqlStorage extends CapacitorStorage {
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
const PRIMARY_KEY_DEFINITION = [
|
||||
"id_" => "serial primary key",
|
||||
];
|
||||
|
||||
protected function tableExists(string $tableName): bool {
|
||||
if (($index = strpos($tableName, ".")) !== false) {
|
||||
$schemaName = substr($tableName, 0, $index);
|
||||
|
@ -19,10 +19,6 @@ class SqliteStorage extends CapacitorStorage {
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
const PRIMARY_KEY_DEFINITION = [
|
||||
"id_" => "integer primary key autoincrement",
|
||||
];
|
||||
|
||||
protected function tableExists(string $tableName): bool {
|
||||
$found = $this->db->get([
|
||||
# depuis la version 3.33.0 le nom officiel de la table est sqlite_schema,
|
||||
|
@ -7,6 +7,12 @@ use nulib\db\Capacitor;
|
||||
use nulib\db\CapacitorChannel;
|
||||
|
||||
class SqliteStorageTest extends TestCase {
|
||||
static function Txx(...$values): void {
|
||||
foreach ($values as $value) {
|
||||
var_export($value);
|
||||
}
|
||||
}
|
||||
|
||||
function _testChargeStrings(SqliteStorage $storage, ?string $channel) {
|
||||
$storage->reset($channel);
|
||||
$storage->charge($channel, "first");
|
||||
@ -78,7 +84,7 @@ class SqliteStorageTest extends TestCase {
|
||||
$capacitor->each(["age" => [">", 10]], $setDone, ["++"]);
|
||||
$capacitor->each(["done" => 0], $setDone, null);
|
||||
|
||||
Txx(cl::all($capacitor->discharge(false)));
|
||||
self::Txx(cl::all($capacitor->discharge(false)));
|
||||
$capacitor->close();
|
||||
self::assertTrue(true);
|
||||
}
|
||||
@ -133,16 +139,16 @@ class SqliteStorageTest extends TestCase {
|
||||
$capacitor->charge(["a" => null, "b" => null]);
|
||||
$capacitor->charge(["a" => "first", "b" => "second"]);
|
||||
|
||||
Txx("=== all");
|
||||
self::Txx("=== all");
|
||||
/** @var Sqlite $sqlite */
|
||||
$sqlite = $capacitor->getStorage()->db();
|
||||
Txx(cl::all($sqlite->all([
|
||||
self::Txx(cl::all($sqlite->all([
|
||||
"select",
|
||||
"from" => $capacitor->getChannel()->getTableName(),
|
||||
])));
|
||||
Txx("=== each");
|
||||
self::Txx("=== each");
|
||||
$capacitor->each(null, function ($item, $values) {
|
||||
Txx($values);
|
||||
self::Txx($values);
|
||||
});
|
||||
|
||||
$capacitor->close();
|
||||
|
@ -41,9 +41,9 @@ p == 1 {
|
||||
}
|
||||
|
||||
declare -A PHPWRAPPER_DESTDIRS=(
|
||||
[_bg_launcher.php]=sbin
|
||||
[.launcher.php]=cli
|
||||
[_wrapper.sh]=cli
|
||||
[_bg_launcher.php]=@@SBIN@@
|
||||
[.launcher.php]=@@CLI@@
|
||||
[_wrapper.sh]=@@CLI@@
|
||||
)
|
||||
declare -A PHPWRAPPER_MODES=(
|
||||
[_bg_launcher.php]=+x
|
||||
@ -156,20 +156,20 @@ if [ -n "$projdir" ]; then
|
||||
'
|
||||
fi
|
||||
|
||||
sbin_dest=sbin
|
||||
cli_dest=cli_config
|
||||
sbin_path=sbin
|
||||
cli_path=cli_config
|
||||
if [ "$install_phpwrappers" == auto ]; then
|
||||
if [ ! -f "$PROJDIR/$COMPOSERDIR/composer.json" ]; then
|
||||
# ce doit être un projet PHP
|
||||
install_phpwrappers=
|
||||
elif [ -d "$projdir/cli_config" ]; then
|
||||
install_phpwrappers=1
|
||||
sbin_dest=sbin
|
||||
cli_dest=cli_config
|
||||
sbin_path=sbin
|
||||
cli_path=cli_config
|
||||
elif [ -d "$projdir/_cli" ]; then
|
||||
install_phpwrappers=1
|
||||
sbin_dest=sbin
|
||||
cli_dest=_cli
|
||||
sbin_path=sbin
|
||||
cli_path=_cli
|
||||
else
|
||||
install_phpwrappers=
|
||||
fi
|
||||
@ -184,15 +184,17 @@ if [ -n "$projdir" ]; then
|
||||
mode="${PHPWRAPPER_MODES[$destname]}"
|
||||
|
||||
case "$destdir" in
|
||||
sbin) destdir="$PROJDIR/$sbin_dest";;
|
||||
cli) destdir="$PROJDIR/$cli_dest";;
|
||||
@@SBIN@@) destdir="$PROJDIR/$sbin_path";;
|
||||
@@CLI@@) destdir="$PROJDIR/$cli_path";;
|
||||
*) destdir="$PROJDIR/$destdir";;
|
||||
esac
|
||||
|
||||
estep "$(relpath "$destdir/$destname")"
|
||||
mkdir -p "$destdir"
|
||||
tail -n+4 "$MYDIR/$phpwrapper" |
|
||||
sed "s|/@@CLI@@/|/$cli_dest/|" >"$destdir/$destname"
|
||||
tail -n+4 "$MYDIR/$phpwrapper" | sed "
|
||||
s|/@@SBIN@@/|/$sbin_path/|
|
||||
s|/@@CLI@@/|/$cli_path/|
|
||||
" >"$destdir/$destname"
|
||||
[ -n "$mode" ] && chmod "$mode" "$destdir/$destname"
|
||||
done
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user