ILIAS  release_7 Revision v7.30-3-g800a261c036
NullTransformationTest.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3/* Copyright (c) 2020 Nils Haagen <nils.haagen@concepts-and-training.de>, Extended GPL, see docs/LICENSE */
4
5require_once('./libs/composer/vendor/autoload.php');
6
10
15{
19 protected $transformation;
20
21 public function setUp() : void
22 {
23 $this->transformation = new NullTransformation();
24 }
25
26 public function NullTestDataProvider()
27 {
28 return [
29 'empty string' => ['', true],
30 'space' => [' ', true],
31 'spaces' => [' ', true],
32 'null' => [null, true],
33 'string' => ['str', false],
34 'int' => [1, false],
35 'negative int' => [-1, false],
36 'zero' => [0, false],
37 'array' => [[], false],
38 'bool (false)' => [false, false],
39 'bool (true)' => [true, false]
40 ];
41 }
42
46 public function testNullTransformation($value, bool $valid)
47 {
48 if (!$valid) {
49 $this->expectException(ConstraintViolationException::class);
50 }
51 $transformed = $this->transformation->transform($value);
52 $this->assertNull($transformed);
53 }
54}
An exception for terminatinating execution or to throw for unit testing.
Test kind transformation to null.
$transformation
NullTransformation.
testNullTransformation($value, bool $valid)
@dataProvider NullTestDataProvider
$valid