ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
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)
 simpleObjectsProvider More...
 
 testAllowedFieldNames (string $name, bool $is_allowed)
 fieldNamesProvider More...
 
 testObviouslyNotMatching ($data)
 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.

References null.

147  : array
148  {
149  return [
150  [1], ["1"], [null], [true], [[]]
151  ];
152  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ simpleObjectsProvider()

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

Definition at line 65 of file DObjectTest.php.

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

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
+ Here is the call graph for this function:

◆ testAllowedFieldNames()

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

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)

obviousNoMatchProvider

Definition at line 134 of file DObjectTest.php.

References $data, and $res.

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:66
Interface Observer Contains several chained tasks and infos about them.

◆ testSimpleObject()

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

simpleObjectsProvider

Definition at line 39 of file DObjectTest.php.

References $res.

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  }
$res
Definition: ltiservices.php:66
Interface Observer Contains several chained tasks and infos about them.

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