3declare(strict_types=1);
28 private const ERROR =
'error_expected';
32 protected function setUp(): void
34 $df =
new DataFactory();
42 'empty string' => [
'',
null],
43 'empty string - one space' => [
' ',
null],
44 'empty string - more spaces' => [
' ',
null],
45 'null' => [
null,
null],
48 'negative int' => [-1, -1],
63 $transformation = $this->
refinery->byTrying([
64 $this->
refinery->numeric()->isNumeric(),
65 $this->refinery->kindlyTo()->null()
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],
95 $transformation = $this->
refinery->byTrying([
97 $this->refinery->numeric()->isNumeric(),
98 $this->refinery->to()->string()
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' => [
'',
''],
126 $transformation = $this->
refinery->byTrying([
128 $this->refinery->kindlyTo()->null()
131 if ($expected === self::ERROR) {
132 $this->expectException(ConstraintViolationException::class);
134 $transformed = $transformation->transform($value);
135 $this->assertEquals($expected, $transformed);