correction php
This commit is contained in:
parent
b6a95259a7
commit
5f15e1ea8c
|
@ -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
|
|
|
@ -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>
|
|
|
@ -2,13 +2,11 @@
|
||||||
<module type="WEB_MODULE" version="4">
|
<module type="WEB_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/php/src_base" isTestSource="false" packagePrefix="nucore\" />
|
<sourceFolder url="file://$MODULE_DIR$/php/src_base" isTestSource="false" packagePrefix="nulib\" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/php/tests" isTestSource="true" packagePrefix="nucore\" />
|
<sourceFolder url="file://$MODULE_DIR$/php/tests" isTestSource="true" packagePrefix="nulib\" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -3,21 +3,6 @@
|
||||||
<component name="PhpDockerContainerSettings">
|
<component name="PhpDockerContainerSettings">
|
||||||
<list>
|
<list>
|
||||||
<map>
|
<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">
|
<entry key="c4cf2564-ed91-488c-a93d-fe2daeae80db">
|
||||||
<value>
|
<value>
|
||||||
<DockerContainerSettings>
|
<DockerContainerSettings>
|
||||||
|
|
|
@ -12,36 +12,36 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpIncludePathManager">
|
<component name="PhpIncludePathManager">
|
||||||
<include_path>
|
<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/phar-io/manifest" />
|
||||||
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
|
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
|
||||||
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
|
<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/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/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/sebastian/code-unit-reverse-lookup" />
|
||||||
<path value="$PROJECT_DIR$/vendor/mur/tests" />
|
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
|
||||||
</include_path>
|
</include_path>
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />
|
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />
|
||||||
|
|
|
@ -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>
|
|
|
@ -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>
|
|
|
@ -2,6 +2,5 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -198,7 +198,7 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.univ-reunion.fr/sda-php/nulib-tests.git",
|
"url": "https://git.univ-reunion.fr/sda-php/nulib-tests.git",
|
||||||
"reference": "8902035bef6ddfe9864675a00844dd14872f6d13"
|
"reference": "6758a43c241cf51ab3ecff3d2260a583f20c0b19"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.3",
|
"php": ">=7.3",
|
||||||
|
@ -207,12 +207,12 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"mur\\tests\\": "src"
|
"nulib\\tests\\": "src"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"mur\\tests\\": "tests"
|
"nulib\\tests\\": "tests"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"authors": [
|
"authors": [
|
||||||
|
@ -222,7 +222,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "fonctions et classes pour les tests",
|
"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",
|
"name": "phar-io/manifest",
|
||||||
|
|
|
@ -445,10 +445,10 @@ class cl {
|
||||||
static final function compare(array $keys): callable {
|
static final function compare(array $keys): callable {
|
||||||
return function ($a, $b) use ($keys) {
|
return function ($a, $b) use ($keys) {
|
||||||
foreach ($keys as $key) {
|
foreach ($keys as $key) {
|
||||||
if (cstr::del_prefix($key, "+")) $w = 1;
|
if (str::del_prefix($key, "+")) $w = 1;
|
||||||
elseif (cstr::del_prefix($key, "-")) $w = -1;
|
elseif (str::del_prefix($key, "-")) $w = -1;
|
||||||
elseif (cstr::del_suffix($key, "|asc")) $w = 1;
|
elseif (str::del_suffix($key, "|asc")) $w = 1;
|
||||||
elseif (cstr::del_suffix($key, "|desc")) $w = -1;
|
elseif (str::del_suffix($key, "|desc")) $w = -1;
|
||||||
else $w = 1;
|
else $w = 1;
|
||||||
if ($c = $w * cv::compare(cl::get($a, $key), cl::get($b, $key))) {
|
if ($c = $w * cv::compare(cl::get($a, $key), cl::get($b, $key))) {
|
||||||
return $c;
|
return $c;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
namespace nulib;
|
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
|
* Retourner $s converti en chaine non nulle, ou "" si $s est fausse (cela
|
||||||
* n'inclue pas la chaine "0")
|
* n'inclue pas la chaine "0")
|
|
@ -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"));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue