1<?
php declare(strict_types=1);
5require_once(
'./libs/composer/vendor/autoload.php');
23 $this->refine = new \ILIAS\Refinery\Factory($df,
$lang);
29 'empty string' => [
'',
null],
30 'empty string - one space' => [
' ',
null],
31 'empty string - more spaces' => [
' ',
null],
32 'null' => [
null,
null],
35 'negative int' => [-1, -1],
48 $transformation = $this->refine->byTrying([
49 $this->refine->numeric()->isNumeric(),
50 $this->refine->kindlyTo()->null()
53 if ($expected === self::ERROR) {
54 $this->expectException(ConstraintViolationException::class);
56 $transformed = $transformation->transform($value);
57 $this->assertEquals($expected, $transformed);
64 'string' => [
'str',
'str'],
65 'null' => [
null,
null],
66 'empty string' => [
'',
null],
78 $transformation = $this->refine->byTrying([
79 $this->refine->kindlyTo()->null(),
80 $this->refine->numeric()->isNumeric(),
81 $this->refine->to()->string()
84 if ($expected === self::ERROR) {
85 $this->expectException(ConstraintViolationException::class);
87 $transformed = $transformation->transform($value);
88 $this->assertEquals($expected, $transformed);
94 'string' => [
'str',
'str'],
95 'null' => [
null,
null],
96 'empty string' => [
'',
''],
107 $transformation = $this->refine->byTrying([
108 $this->refine->to()->string(),
109 $this->refine->kindlyTo()->null()
112 if ($expected === self::ERROR) {
113 $this->expectException(ConstraintViolationException::class);
115 $transformed = $transformation->transform($value);
116 $this->assertEquals($expected, $transformed);
An exception for terminatinating execution or to throw for unit testing.