ILIAS  release_8 Revision v8.24
NullTransformationTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
24
26{
28
29 protected function setUp(): void
30 {
31 $this->transformation = new NullTransformation();
32 }
33
34 public function NullTestDataProvider(): array
35 {
36 return [
37 'empty string' => ['', true],
38 'space' => [' ', true],
39 'spaces' => [' ', true],
40 'null' => [null, true],
41 'string' => ['str', false],
42 'int' => [1, false],
43 'negative int' => [-1, false],
44 'zero' => [0, false],
45 'array' => [[], false],
46 'bool (false)' => [false, false],
47 'bool (true)' => [true, false]
48 ];
49 }
50
57 public function testNullTransformation($value, bool $valid): void
58 {
59 if (!$valid) {
60 $this->expectException(ConstraintViolationException::class);
61 }
62 $transformed = $this->transformation->transform($value);
63 $this->assertNull($transformed);
64 }
65}
testNullTransformation($value, bool $valid)
@dataProvider NullTestDataProvider
NullTransformation $transformation
$valid