ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Data\Description\DObjectTest Class Reference
+ Inheritance diagram for ILIAS\Data\Description\DObjectTest:
+ Collaboration diagram for ILIAS\Data\Description\DObjectTest:

Public Member Functions

 testSimpleObject (string $field, $object, $expected)
 @dataProvider simpleObjectsProvider More...
 
 testAllowedFieldNames (string $name, bool $is_allowed)
 @dataProvider fieldNamesProvider More...
 
 testObviouslyNotMatching ($data)
 @dataProvider obviousNoMatchProvider More...
 

Static Public Member Functions

static simpleObjectsProvider ()
 
static fieldNamesProvider ()
 
static obviousNoMatchProvider ()
 

Detailed Description

Definition at line 34 of file DObjectTest.php.

Member Function Documentation

◆ fieldNamesProvider()

static ILIAS\Data\Description\DObjectTest::fieldNamesProvider ( )
static

Definition at line 119 of file DObjectTest.php.

119 : array
120 {
121 return [
122 ["someName", true],
123 ["some_name", true],
124 ["some", true],
125 ["some1", true],
126 ["1some", false],
127 ["some one", false]
128 ];
129 }

◆ obviousNoMatchProvider()

static ILIAS\Data\Description\DObjectTest::obviousNoMatchProvider ( )
static

Definition at line 147 of file DObjectTest.php.

147 : array
148 {
149 return [
150 [1], ["1"], [null], [true], [[]]
151 ];
152 }

◆ simpleObjectsProvider()

static ILIAS\Data\Description\DObjectTest::simpleObjectsProvider ( )
static

Definition at line 65 of file DObjectTest.php.

65 : array
66 {
67 $v1 = "value";
68 $o1_a = new class () {
69 public function getValue(): int
70 {
71 return 42;
72 }
73 };
74 $o1_b = new class () {
75 public $value = 42;
76 };
77 $e1 = new \StdClass();
78 $e1->value = 42;
79
80 $v2 = "some_value";
81 $o2_a = new class () {
82 public function getSomeValue(): int
83 {
84 return 23;
85 }
86 };
87 $o2_b = new class () {
88 public $some_value = 23;
89 };
90 $o2_c = new class () {
91 public $someValue = 23;
92 };
93 $e2 = new \StdClass();
94 $e2->some_value = 23;
95
96
97 return [
98 [$v1, $o1_a, $e1],
99 [$v1, $o1_b, $e1],
100 [$v2, $o2_a, $e2],
101 [$v2, $o2_b, $e2],
102 [$v2, $o2_c, $e2],
103 ];
104 }
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:49

References ILIAS\UI\Implementation\Component\Input\getValue().

+ Here is the call graph for this function:

◆ testAllowedFieldNames()

ILIAS\Data\Description\DObjectTest::testAllowedFieldNames ( string  $name,
bool  $is_allowed 
)

@dataProvider fieldNamesProvider

Definition at line 109 of file DObjectTest.php.

109 : void
110 {
111 if (!$is_allowed) {
112 $this->expectException(\InvalidArgumentException::class);
113 }
114
115 $field = new Field($name, $this->createMock(Description::class));
116 $this->assertEquals($name, $field->getName());
117 }

◆ testObviouslyNotMatching()

ILIAS\Data\Description\DObjectTest::testObviouslyNotMatching (   $data)

@dataProvider obviousNoMatchProvider

Definition at line 134 of file DObjectTest.php.

134 : void
135 {
136 $desc = new DObject(
137 $this->createMock(\ILIAS\Data\Text\SimpleDocumentMarkdown::class)
138 );
139 $res = $desc->getPrimitiveRepresentation($data);
140
141 $this->assertInstanceOf(\Closure::class, $res);
142 $errors = iterator_to_array($res());
143 $this->assertCount(1, $errors);
144 $this->assertTrue(is_string($errors[0]));
145 }
$res
Definition: ltiservices.php:69
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References $data, and $res.

◆ testSimpleObject()

ILIAS\Data\Description\DObjectTest::testSimpleObject ( string  $field,
  $object,
  $expected 
)

@dataProvider simpleObjectsProvider

Definition at line 39 of file DObjectTest.php.

39 : void
40 {
41 $md = $this->createMock(\ILIAS\Data\Text\SimpleDocumentMarkdown::class);
42 $desc = new DObject(
43 $md,
44 new Field(
45 $field,
46 new DValue(
47 $this->createMock(\ILIAS\Data\Text\SimpleDocumentMarkdown::class),
48 ValueType::INT
49 )
50 )
51 );
52
53 $res = $desc->getPrimitiveRepresentation($object);
54
55 if (!is_null($expected)) {
56 $this->assertEquals($expected, $res);
57 } else {
58 $this->assertInstanceOf(\Closure::class, $res);
59 $errors = iterator_to_array($res());
60 $this->assertCount(1, $errors);
61 $this->assertTrue(is_string($errors[0]));
62 }
63 }

References $res.


The documentation for this class was generated from the following file: