3 declare(strict_types=1);
28 private const ERROR =
'error_expected';
32 protected function setUp(): void
42 'empty string' => [
'', null],
43 'empty string - one space' => [
' ', null],
44 'empty string - more spaces' => [
' ', null],
45 'null' => [null, null],
46 'string' => [
'str', self::ERROR],
48 'negative int' => [-1, -1],
50 'array' => [[], self::ERROR],
51 'bool (false)' => [
false, self::ERROR],
52 'bool (true)' => [
true, self::ERROR]
63 $transformation = $this->
refinery->byTrying([
64 $this->
refinery->numeric()->isNumeric(),
68 if ($expected === self::ERROR) {
69 $this->expectException(ConstraintViolationException::class);
71 $transformed = $transformation->transform($value);
72 $this->assertEquals($expected, $transformed);
79 'string' => [
'str',
'str'],
80 'null' => [null, null],
81 'empty string' => [
'', null],
83 'bool (true)' => [
true, self::ERROR],
84 'array' => [[], self::ERROR]
95 $transformation = $this->
refinery->byTrying([
97 $this->
refinery->numeric()->isNumeric(),
101 if ($expected === self::ERROR) {
102 $this->expectException(ConstraintViolationException::class);
104 $transformed = $transformation->transform($value);
105 $this->assertEquals($expected, $transformed);
111 'string' => [
'str',
'str'],
112 'null' => [null, null],
113 'empty string' => [
'',
''],
114 'int' => [1, self::ERROR],
115 'array' => [[], self::ERROR]
126 $transformation = $this->
refinery->byTrying([
131 if ($expected === self::ERROR) {
132 $this->expectException(ConstraintViolationException::class);
134 $transformed = $transformation->transform($value);
135 $this->assertEquals($expected, $transformed);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...