|
|
|
@ -15,7 +15,7 @@ class ScalarWrapperTest extends TestCase {
|
|
|
|
|
self::assertSame($normalized, $wrapper->isNormalized(), "normalized");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function checkVerifix(ScalarSchema $schema, $orig, bool $normalize, $value, bool $present, bool $available, bool $valid, bool $normalized, ?array $inputParams=null): void {
|
|
|
|
|
function checkNormalize(ScalarSchema $schema, $orig, bool $normalize, $value, bool $present, bool $available, bool $valid, bool $normalized, ?array $inputParams=null): void {
|
|
|
|
|
$wrapper = $schema->getWrapper();
|
|
|
|
|
$wrapper->resetParams(["normalize" => $normalize]);
|
|
|
|
|
if ($inputParams !== null) $input = new Input($orig, $inputParams);
|
|
|
|
@ -36,261 +36,261 @@ class ScalarWrapperTest extends TestCase {
|
|
|
|
|
function testRaw() {
|
|
|
|
|
$schema = new ScalarSchema();
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, false, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$obj = new stdClass();
|
|
|
|
|
$this->checkVerifix($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$schema = new ScalarSchema("raw");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, false, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$obj = new stdClass();
|
|
|
|
|
$this->checkVerifix($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testMixed() {
|
|
|
|
|
$schema = new ScalarSchema("mixed");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, false, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$obj = new stdClass();
|
|
|
|
|
$this->checkVerifix($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$schema = new ScalarSchema("?mixed");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, false, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, false, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$obj = new stdClass();
|
|
|
|
|
$this->checkVerifix($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, false, $obj, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, $obj, true, $obj, true, true, true, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testRawstring() {
|
|
|
|
|
$schema = new ScalarSchema("rawstring");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, null, true, false, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, "", true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, "", true, "", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "", false, "", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "", true, "", true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, " ", false, " ", true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, " ", true, " ", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, " ", false, " ", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, " ", true, " ", true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "text", false, "text", true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, "text", true, "text", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "text", false, "text", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "text", true, "text", true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, " text ", false, " text ", true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, " text ", true, " text ", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, " text ", false, " text ", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, " text ", true, " text ", true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, true, false, true, true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, true, true, "1", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, true, false, true, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, true, true, "1", true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, 42, false, 42, true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, 42, true, "42", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, 42, false, 42, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, 42, true, "42", true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, [], false, [], true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, [], false, [], true, true, false, false);
|
|
|
|
|
$this->checkException($schema, [], true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
## Tester valeur par défaut
|
|
|
|
|
$schema = new ScalarSchema(["rawstring", null]);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, null, true, false, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$schema = new ScalarSchema(["rawstring", "default"]);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, "default", true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, "default", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, "default", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, "default", true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
## Tester nullable
|
|
|
|
|
$schema = new ScalarSchema("?rawstring");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
## Tester required
|
|
|
|
|
$schema = new ScalarSchema(["rawstring", "required" => true]);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, null, true, false, false, false);
|
|
|
|
|
$this->checkNormalize($schema, false, false, null, true, false, false, false);
|
|
|
|
|
$this->checkException($schema, false, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
## Tester allow_empty === false
|
|
|
|
|
$inputParams = ["allow_empty" => false];
|
|
|
|
|
$schema = new ScalarSchema("rawstring");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false, $inputParams);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class, $inputParams);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
|
|
|
|
|
$schema = new ScalarSchema("?rawstring");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true, $inputParams);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testString() {
|
|
|
|
|
$schema = new ScalarSchema("string");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, null, true, false, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, "", true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, "", true, "", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "", false, "", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "", true, "", true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, " ", false, "", true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, " ", true, "", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, " ", false, "", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, " ", true, "", true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "text", false, "text", true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, "text", true, "text", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "text", false, "text", true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, "text", true, "text", true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, " text ", false, "text", true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, " text ", true, "text", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, " text ", false, "text", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, " text ", true, "text", true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, true, false, true, true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, true, true, "1", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, true, false, true, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, true, true, "1", true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, 42, false, 42, true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, 42, true, "42", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, 42, false, 42, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, 42, true, "42", true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, [], false, [], true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, [], false, [], true, true, false, false);
|
|
|
|
|
$this->checkException($schema, [], true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
## Tester nullable
|
|
|
|
|
$schema = new ScalarSchema("?string");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
## Tester required
|
|
|
|
|
$schema = new ScalarSchema(["string", "required" => true]);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, null, true, false, false, false);
|
|
|
|
|
$this->checkNormalize($schema, false, false, null, true, false, false, false);
|
|
|
|
|
$this->checkException($schema, false, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
## Tester allow_empty === false
|
|
|
|
|
$inputParams = ["allow_empty" => false];
|
|
|
|
|
$schema = new ScalarSchema("string");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false, $inputParams);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class, $inputParams);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
|
|
|
|
|
$schema = new ScalarSchema("?string");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true, $inputParams);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testInt() {
|
|
|
|
|
$schema = new ScalarSchema("int");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkVerifix($schema, false, true, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, false, null, true, false, true, true);
|
|
|
|
|
$this->checkNormalize($schema, false, true, null, true, false, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, 42, false, 42, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, 42, true, 42, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, 42, false, 42, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, 42, true, 42, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "42", false, "42", true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, "42", true, 42, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, "42", false, "42", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, "42", true, 42, true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "42.5", false, "42.5", true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, "42.5", true, 42, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, "42.5", false, "42.5", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, "42.5", true, 42, true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "42,5", false, "42,5", true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, "42,5", true, 42, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, "42,5", false, "42,5", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, "42,5", true, 42, true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, " 42 ", false, "42", true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, " 42 ", true, 42, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, " 42 ", false, "42", true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, " 42 ", true, 42, true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, "", true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, "", false, "", true, true, false, false);
|
|
|
|
|
$this->checkException($schema, "", true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, " ", false, " ", true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, " ", false, " ", true, true, false, false);
|
|
|
|
|
$this->checkException($schema, " ", true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "text", false, "text", true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, "text", false, "text", true, true, false, false);
|
|
|
|
|
$this->checkException($schema, "text", true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, true, false, true, true, true, true, false);
|
|
|
|
|
$this->checkVerifix($schema, true, true, 1, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, true, false, true, true, true, true, false);
|
|
|
|
|
$this->checkNormalize($schema, true, true, 1, true, true, true, false);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, [], false, [], true, true, false, false);
|
|
|
|
|
$this->checkNormalize($schema, [], false, [], true, true, false, false);
|
|
|
|
|
$this->checkException($schema, [], true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
## Tester nullable
|
|
|
|
|
$schema = new ScalarSchema("?int");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true);
|
|
|
|
|
|
|
|
|
|
## Tester required
|
|
|
|
|
$schema = new ScalarSchema(["int", "required" => true]);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, false, false, null, true, false, false, false);
|
|
|
|
|
$this->checkNormalize($schema, false, false, null, true, false, false, false);
|
|
|
|
|
$this->checkException($schema, false, true, ValueException::class);
|
|
|
|
|
|
|
|
|
|
## Tester allow_empty === false
|
|
|
|
|
$inputParams = ["allow_empty" => false];
|
|
|
|
|
$schema = new ScalarSchema("int");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, false, false, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, false, false, $inputParams);
|
|
|
|
|
$this->checkException($schema, null, true, ValueException::class, $inputParams);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
|
|
|
|
|
$schema = new ScalarSchema("?int");
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, null, false, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, null, true, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, false, null, true, true, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, null, true, null, true, true, true, true, $inputParams);
|
|
|
|
|
|
|
|
|
|
$this->checkVerifix($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkVerifix($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", false, null, true, false, true, true, $inputParams);
|
|
|
|
|
$this->checkNormalize($schema, "", true, null, true, false, true, true, $inputParams);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|