importation initiale

This commit is contained in:
Jephté Clain 2025-02-28 20:52:44 +04:00
commit e1f04b98d6
15 changed files with 281 additions and 0 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
/sbin/composer.phar -delta

12
.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
/.composer.lock.runphp
.~lock*#
.*.swp
/vendor/
/.idea/shelf/
/.idea/workspace.xml
/.idea/httpRequests/
/.idea/dataSources/
/.idea/dataSources.local.xml
/.phpunit.result.cache

View File

@ -0,0 +1,14 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PhpAbstractStaticMethodInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="PhpDocMissingReturnTagInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PhpDocSignatureInspection" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="PhpSignatureMismatchDuringInheritanceInspection" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="SpellCheckingInspection" enabled="false" level="TYPO" enabled_by_default="false">
<option name="processCode" value="true" />
<option name="processLiterals" value="true" />
<option name="processComments" value="true" />
</inspection_tool>
</profile>
</component>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/nulib-tests.iml" filepath="$PROJECT_DIR$/.idea/nulib-tests.iml" />
</modules>
</component>
</project>

12
.idea/nulib-tests.iml generated Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="nulib\tests\" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" packagePrefix="nulib\tests\" />
<excludeFolder url="file://$MODULE_DIR$/vendor" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

24
.idea/php-docker-settings.xml generated Normal file
View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<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>
</map>
</list>
</component>
</project>

58
.idea/php.xml generated Normal file
View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MessDetectorOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCSFixerOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PHPCodeSnifferOptionsConfiguration">
<option name="highlightLevel" value="WARNING" />
<option name="transferred" value="true" />
</component>
<component name="PhpIncludePathManager">
<include_path>
<path value="$PROJECT_DIR$/vendor/myclabs/deep-copy" />
<path value="$PROJECT_DIR$/vendor/doctrine/instantiator" />
<path value="$PROJECT_DIR$/vendor/phar-io/version" />
<path value="$PROJECT_DIR$/vendor/composer" />
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
<path value="$PROJECT_DIR$/vendor/phar-io/manifest" />
<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/code-unit-reverse-lookup" />
<path value="$PROJECT_DIR$/vendor/sebastian/resource-operations" />
<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/object-reflector" />
<path value="$PROJECT_DIR$/vendor/sebastian/type" />
<path value="$PROJECT_DIR$/vendor/sebastian/diff" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-file-iterator" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-timer" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-text-template" />
<path value="$PROJECT_DIR$/vendor/phpunit/phpunit" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-code-coverage" />
<path value="$PROJECT_DIR$/vendor/sebastian/cli-parser" />
<path value="$PROJECT_DIR$/vendor/sebastian/complexity" />
<path value="$PROJECT_DIR$/vendor/sebastian/code-unit" />
<path value="$PROJECT_DIR$/vendor/sebastian/lines-of-code" />
<path value="$PROJECT_DIR$/vendor/phpunit/php-invoker" />
<path value="$PROJECT_DIR$/vendor/nikic/php-parser" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.3" />
<component name="PhpStanOptionsConfiguration">
<option name="transferred" value="true" />
</component>
<component name="PhpUnit">
<phpunit_settings>
<PhpUnitSettings custom_loader_path="$PROJECT_DIR$/vendor/autoload.php" />
</phpunit_settings>
</component>
<component name="PsalmOptionsConfiguration">
<option name="transferred" value="true" />
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

11
.pman.conf Normal file
View File

@ -0,0 +1,11 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
UPSTREAM=
DEVELOP=dev
FEATURE=wip/
RELEASE=
MAIN=
TAG_SUFFIX=
HOTFIX=
DIST=
NOAUTO=

8
.runphp.conf Normal file
View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
# Chemin vers runphp, e.g sbin/runphp
RUNPHP=
# Si RUNPHP n'est pas défini, les variables suivantes peuvent être définies
DIST=d11
#REGISTRY=pubdocker.univ-reunion.fr/dist

29
composer.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "nulib/tests",
"description": "fonctions et classes pour les tests",
"type": "library",
"repositories": [
{
"type": "composer",
"url": "https://repos.univ-reunion.fr/composer"
}
],
"require": {
},
"autoload": {
"psr-4": {
"nulib\\tests\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"nulib\\tests\\": "tests"
}
},
"authors": [
{
"name": "Jephte Clain",
"email": "Jephte.Clain@univ-reunion.fr"
}
]
}

18
composer.lock generated Normal file
View File

@ -0,0 +1,18 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4bf96ddf8e061d71f11bf0a8906a344b",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.2.0"
}

4
run-tests Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
MYDIR="$(dirname -- "$0")"
"$MYDIR/vendor/bin/phpunit" --bootstrap "$MYDIR/vendor/autoload.php" "$@" "$MYDIR/tests"

76
src/TestCase.php Normal file
View File

@ -0,0 +1,76 @@
<?php
namespace nulib\tests;
use Error;
use Exception;
use PHPUnit\Framework\Constraint\Exception as ConstraintException;
use PHPUnit\Framework\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase {
const UNCHANGED_ARRAY = ["unchanged"];
static function assertException($class, callable $func, ...$args) {
try {
call_user_func_array($func, $args);
$e = null;
} catch (Exception $e) {
}
self::assertThat($e, new ConstraintException($class));
}
static function assertNotException(callable $func, ...$args) {
try {
call_user_func_array($func, $args);
$e = null;
$message = "";
} catch (Exception $e) {
$message = "L'exception ".get_class($e)." a été lancée";
}
self::assertTrue($e === null, $message);
}
static function assertError($class, callable $func, ...$args) {
try {
call_user_func_array($func, $args);
$e = null;
} catch (Error $e) {
}
self::assertThat($e, new ConstraintException($class));
}
static function assertNotError(callable $func, ...$args) {
try {
call_user_func_array($func, $args);
$e = null;
$message = "";
} catch (Error $e) {
$message = "L'exception ".get_class($e)." a été lancée";
}
self::assertTrue($e === null, $message);
}
static function assertSameKeys(array $expected, array $actual) {
self::assertSame($expected, array_keys($actual));
}
static function assertSameValues(array $expected, array $actual) {
self::assertSame($expected, array_values($actual));
}
protected $origTz = '';
/**
* forcer systématiquement le timezone dans Indian/Reunion pour que les tests
* de date soient corrects
*/
protected function setUp(): void {
$this->origTz = date_default_timezone_get();
date_default_timezone_set("Indian/Reunion");
}
protected function tearDown(): void {
if ($this->origTz !== '') {
date_default_timezone_set($this->origTz);
}
}
}

0
tests/.keep Normal file
View File