modifs.mineures sans commentaires
This commit is contained in:
parent
9723c146d5
commit
953f614caa
37
php/tests/clTest.php
Normal file
37
php/tests/clTest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace nulib;
|
||||
|
||||
use nulib\tests\TestCase;
|
||||
|
||||
class clTest extends TestCase {
|
||||
function checkKeys(?array $array, ?array $ref, bool $sameKeys, array $expectedKeys, array $expectedRemains, array $expectedMissings): void {
|
||||
self::assertSame($sameKeys, cl::same_keys($array, $ref, $keys, $remains, $missings), "sameKeys");
|
||||
self::assertSame($expectedKeys, $keys, "keys");
|
||||
self::assertSame($expectedRemains, $remains, "remains");
|
||||
self::assertSame($expectedMissings, $missings, "missings");
|
||||
}
|
||||
function test_same_keys() {
|
||||
$array = ["a" => 42, "b" => "tesxt"]; $arrayKeys = array_keys($array);
|
||||
$xarray = ["parasite0", "a" => 42, "parasite1", "b" => "tesxt"]; $xarrayKeys = array_keys($array);
|
||||
$ref = ["a" => "int", "b" => "text"]; $refKeys = array_keys($ref);
|
||||
$missingArray = ["c" => true]; $missingKeys = array_keys($missingArray);
|
||||
$missingRef = ["c" => "bool"]; $missingKeys = array_keys($missingRef);
|
||||
|
||||
$this->checkKeys(null, null, true, [], [], []);
|
||||
$this->checkKeys(null, [], true, [], [], []);
|
||||
$this->checkKeys([], null, true, [], [], []);
|
||||
$this->checkKeys([], [], true, [], [], []);
|
||||
|
||||
$this->checkKeys(null, $ref, false, [], [], $refKeys);
|
||||
$this->checkKeys([], $ref, false, [], [], $refKeys);
|
||||
|
||||
$this->checkKeys($array, null, true, [], $arrayKeys, []);
|
||||
$this->checkKeys($array, [], true, [], $arrayKeys, []);
|
||||
|
||||
$this->checkKeys($array, $ref, true, $arrayKeys, [], []);
|
||||
$this->checkKeys(cl::merge($array, $missingArray), $ref, true, $arrayKeys, $missingKeys, []);
|
||||
$this->checkKeys($array, cl::merge($ref, $missingRef), false, $arrayKeys, [], $missingKeys);
|
||||
|
||||
$this->checkKeys($xarray, $ref, false, $arrayKeys, [0, 1], []);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user