correction php

This commit is contained in:
Jephté Clain 2023-10-20 10:25:20 +04:00
parent b6a95259a7
commit 5f15e1ea8c
13 changed files with 93 additions and 157 deletions

8
.idea/.gitignore vendored
View File

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Codeception">
<option name="configurations">
<list>
<Configuration>
<option name="path" value="$PROJECT_DIR$/tests" />
</Configuration>
<Configuration>
<option name="path" value="$PROJECT_DIR$/tests" />
</Configuration>
</list>
</option>
</component>
</project>

View File

@ -2,10 +2,8 @@
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/php/src_base" isTestSource="false" packagePrefix="nucore\" />
<sourceFolder url="file://$MODULE_DIR$/php/tests" isTestSource="true" packagePrefix="nucore\" />
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/php/src_base" isTestSource="false" packagePrefix="nulib\" />
<sourceFolder url="file://$MODULE_DIR$/php/tests" isTestSource="true" packagePrefix="nulib\" />
<excludeFolder url="file://$MODULE_DIR$/vendor" />
</content>
<orderEntry type="inheritedJdk" />

View File

@ -3,21 +3,6 @@
<component name="PhpDockerContainerSettings">
<list>
<map>
<entry key="125ffb9d-fd5f-4e71-8182-94191665795a">
<value>
<DockerContainerSettings>
<option name="version" value="1" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/opt/project" />
<option name="hostPath" value="$PROJECT_DIR$" />
</DockerVolumeBindingImpl>
</list>
</option>
</DockerContainerSettings>
</value>
</entry>
<entry key="c4cf2564-ed91-488c-a93d-fe2daeae80db">
<value>
<DockerContainerSettings>

View File

@ -12,36 +12,36 @@
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
<path value="$PROJECT_DIR$/vendor/sebastian/complexity" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-invoker" />
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
<path value="$PROJECT_DIR$/vendor/sebastian/resource-operations" />
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-invoker" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-reflector" />
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
<path value="$PROJECT_DIR$/vendor/sebastian/exporter" />
<path value="$PROJECT_DIR$/vendor/sebastian/environment" />
<path value="$PROJECT_DIR$/vendor/sebastian/recursion-context" />
<path value="$PROJECT_DIR$/vendor/sebastian/global-state" />
<path value="$PROJECT_DIR$/vendor/sebastian/object-enumerator" />
<path value="$PROJECT_DIR$/vendor/sebastian/complexity" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
<path value="$PROJECT_DIR$/vendor/nulib/tests" />
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
<path value="$PROJECT_DIR$/vendor/sebastian/version" />
<path value="$PROJECT_DIR$/vendor/sebastian/comparator" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit-reverse-lookup" />
<path value="$PROJECT_DIR$/vendor/mur/tests" />
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PHPSpec">
<suites>
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
<PhpSpecSuiteConfiguration>
<option name="myPath" value="$PROJECT_DIR$" />
</PhpSpecSuiteConfiguration>
</suites>
</component>
</project>

View File

@ -1,10 +0,0 @@
<?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>

View File

@ -2,6 +2,5 @@
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

8
composer.lock generated
View File

@ -198,7 +198,7 @@
"source": {
"type": "git",
"url": "https://git.univ-reunion.fr/sda-php/nulib-tests.git",
"reference": "8902035bef6ddfe9864675a00844dd14872f6d13"
"reference": "6758a43c241cf51ab3ecff3d2260a583f20c0b19"
},
"require": {
"php": ">=7.3",
@ -207,12 +207,12 @@
"type": "library",
"autoload": {
"psr-4": {
"mur\\tests\\": "src"
"nulib\\tests\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"mur\\tests\\": "tests"
"nulib\\tests\\": "tests"
}
},
"authors": [
@ -222,7 +222,7 @@
}
],
"description": "fonctions et classes pour les tests",
"time": "2023-10-01T11:57:55+00:00"
"time": "2023-10-20T06:17:30+00:00"
},
{
"name": "phar-io/manifest",

View File

@ -445,10 +445,10 @@ class cl {
static final function compare(array $keys): callable {
return function ($a, $b) use ($keys) {
foreach ($keys as $key) {
if (cstr::del_prefix($key, "+")) $w = 1;
elseif (cstr::del_prefix($key, "-")) $w = -1;
elseif (cstr::del_suffix($key, "|asc")) $w = 1;
elseif (cstr::del_suffix($key, "|desc")) $w = -1;
if (str::del_prefix($key, "+")) $w = 1;
elseif (str::del_prefix($key, "-")) $w = -1;
elseif (str::del_suffix($key, "|asc")) $w = 1;
elseif (str::del_suffix($key, "|desc")) $w = -1;
else $w = 1;
if ($c = $w * cv::compare(cl::get($a, $key), cl::get($b, $key))) {
return $c;

View File

@ -2,9 +2,9 @@
namespace nulib;
/**
* Class cstr: gestion des chaines de caractère "simples"
* Class str: gestion des chaines de caractère "simples"
*/
class cstr {
class str {
/**
* Retourner $s converti en chaine non nulle, ou "" si $s est fausse (cela
* n'inclue pas la chaine "0")

View File

@ -1,56 +0,0 @@
<?php
namespace nulib;
use mur\tests\TestCase;
class cstrTest extends TestCase {
function testSplit_pair() {
self::assertSame([null, null], cstr::split_pair(null));
self::assertSame(["", null], cstr::split_pair(""));
self::assertSame(["first", null], cstr::split_pair("first"));
self::assertSame(["first", ""], cstr::split_pair("first:"));
self::assertSame(["first", "second"], cstr::split_pair("first:second"));
self::assertSame(["first", "second:third"], cstr::split_pair("first:second:third"));
}
function testXxxSuffix() {
$s = "blahSUF";
self::assertTrue(cstr::del_suffix($s, "SUF"));
self::assertSame("blah", $s);
self::assertFalse(cstr::del_suffix($s, "SUF"));
self::assertTrue(cstr::add_suffix($s, "SUF"));
self::assertSame("blahSUF", $s);
self::assertFalse(cstr::add_suffix($s, "SUF"));
}
function testXxxPrefix() {
$s = "PREblah";
self::assertTrue(cstr::del_prefix($s, "PRE"));
self::assertSame("blah", $s);
self::assertFalse(cstr::del_prefix($s, "PRE"));
self::assertTrue(cstr::add_prefix($s, "PRE"));
self::assertSame("PREblah", $s);
self::assertFalse(cstr::add_prefix($s, "PRE"));
}
function testUs2camel() {
# avec délimiteur
self::assertSame("myCamel", cstr::us2camel("my_camel"));
self::assertSame("myCamel", cstr::us2camel("MY_CAMEL"));
self::assertSame("myCamel", cstr::us2camel("My_Camel"));
self::assertSame("myCamel", cstr::us2camel("mY_cAMEL"));
self::assertSame("myCamel", cstr::us2camel("my-camel"));
self::assertSame("myCamel", cstr::us2camel("my camel"));
self::assertSame("myCamel", cstr::us2camel("my\tcamel"));
self::assertSame("myCamel", cstr::us2camel("my\rcamel"));
self::assertSame("myCamel", cstr::us2camel("my\ncamel"));
self::assertSame("myCamel", cstr::us2camel("my\fcamel"));
self::assertSame("myCamel", cstr::us2camel("my\vcamel"));
# sans délimiteur
self::assertSame("myCamel", cstr::us2camel("myCamel"));
self::assertSame("MyCamel", cstr::us2camel("MyCamel"));
self::assertSame("MyCaMEL", cstr::us2camel("MyCaMEL"));
}
}

56
php/tests/strTest.php Normal file
View File

@ -0,0 +1,56 @@
<?php
namespace nulib;
use nulib\tests\TestCase;
class strTest extends TestCase {
function testSplit_pair() {
self::assertSame([null, null], str::split_pair(null));
self::assertSame(["", null], str::split_pair(""));
self::assertSame(["first", null], str::split_pair("first"));
self::assertSame(["first", ""], str::split_pair("first:"));
self::assertSame(["first", "second"], str::split_pair("first:second"));
self::assertSame(["first", "second:third"], str::split_pair("first:second:third"));
}
function testXxxSuffix() {
$s = "blahSUF";
self::assertTrue(str::del_suffix($s, "SUF"));
self::assertSame("blah", $s);
self::assertFalse(str::del_suffix($s, "SUF"));
self::assertTrue(str::add_suffix($s, "SUF"));
self::assertSame("blahSUF", $s);
self::assertFalse(str::add_suffix($s, "SUF"));
}
function testXxxPrefix() {
$s = "PREblah";
self::assertTrue(str::del_prefix($s, "PRE"));
self::assertSame("blah", $s);
self::assertFalse(str::del_prefix($s, "PRE"));
self::assertTrue(str::add_prefix($s, "PRE"));
self::assertSame("PREblah", $s);
self::assertFalse(str::add_prefix($s, "PRE"));
}
function testUs2camel() {
# avec délimiteur
self::assertSame("myCamel", str::us2camel("my_camel"));
self::assertSame("myCamel", str::us2camel("MY_CAMEL"));
self::assertSame("myCamel", str::us2camel("My_Camel"));
self::assertSame("myCamel", str::us2camel("mY_cAMEL"));
self::assertSame("myCamel", str::us2camel("my-camel"));
self::assertSame("myCamel", str::us2camel("my camel"));
self::assertSame("myCamel", str::us2camel("my\tcamel"));
self::assertSame("myCamel", str::us2camel("my\rcamel"));
self::assertSame("myCamel", str::us2camel("my\ncamel"));
self::assertSame("myCamel", str::us2camel("my\fcamel"));
self::assertSame("myCamel", str::us2camel("my\vcamel"));
# sans délimiteur
self::assertSame("myCamel", str::us2camel("myCamel"));
self::assertSame("MyCamel", str::us2camel("MyCamel"));
self::assertSame("MyCaMEL", str::us2camel("MyCaMEL"));
}
}