ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
NullTransformationTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 
27 {
29 
30  protected function setUp(): void
31  {
32  $this->transformation = new NullTransformation();
33  }
34 
35  public static function NullTestDataProvider(): array
36  {
37  return [
38  'empty string' => ['', true],
39  'space' => [' ', true],
40  'spaces' => [' ', true],
41  'null' => [null, true],
42  'string' => ['str', false],
43  'int' => [1, false],
44  'negative int' => [-1, false],
45  'zero' => [0, false],
46  'array' => [[], false],
47  'bool (false)' => [false, false],
48  'bool (true)' => [true, false]
49  ];
50  }
51 
52  #[DataProvider('NullTestDataProvider')]
53  public function testNullTransformation(mixed $value, bool $valid): void
54  {
55  if (!$valid) {
56  $this->expectException(ConstraintViolationException::class);
57  }
58  $transformed = $this->transformation->transform($value);
59  $this->assertNull($transformed);
60  }
61 }
$valid
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
NullTransformation $transformation
testNullTransformation(mixed $value, bool $valid)