ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
DValueTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26
29use PHPUnit\Framework\TestCase;
30
31class DDValueTest extends TestCase
32{
36 public function testIntRepresentation(ValueType $type, $value, $is_match): void
37 {
38 $desc = new DValue(
39 $this->createMock(\ILIAS\Data\Text\SimpleDocumentMarkdown::class),
40 $type
41 );
42
43 $res = $desc->getPrimitiveRepresentation($value);
44
45 if ($is_match) {
46 $this->assertEquals($value, $res);
47 } else {
48 $this->assertInstanceOf(\Closure::class, $res);
49 $errors = iterator_to_array($res());
50 $this->assertCount(1, $errors);
51 $this->assertTrue(is_string($errors[0]));
52 }
53 }
54
55 public static function casesProvider(): array
56 {
57 return [
58 [ValueType::INT, 42, true],
59 [ValueType::INT, "foo", false],
60 [ValueType::FLOAT, 2.3, true],
61 [ValueType::FLOAT, "foo", false],
62 [ValueType::STRING, "foo", true],
63 [ValueType::STRING, 2, false],
64 [ValueType::DATETIME, new \DateTimeImmutable(), true],
65 [ValueType::DATETIME, "foo", false],
66 [ValueType::BOOL, true, true],
67 [ValueType::BOOL, false, true],
68 [ValueType::BOOL, "true", false],
69 [ValueType::BOOL, 1, false],
70 [ValueType::BOOL, null, false],
71 [ValueType::NULL, null, true],
72 [ValueType::NULL, false, false],
73 ];
74 }
75}
testIntRepresentation(ValueType $type, $value, $is_match)
@dataProvider casesProvider
Definition: DValueTest.php:36
$res
Definition: ltiservices.php:69
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.