ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
TransformationsCustomTest Class Reference
+ Inheritance diagram for TransformationsCustomTest:
+ Collaboration diagram for TransformationsCustomTest:

Public Member Functions

 testTransform ()
 
 testTransformFails ()
 
 testInvoke ()
 
 testInvokeFails ()
 
 testApplyToWithValidValueReturnsAnOkResult ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Private Attributes

const TEST_STRING = "Test"
 
Transformation $custom
 
Refinery $f
 

Detailed Description

Definition at line 26 of file TransformationsCustomTest.php.

Member Function Documentation

◆ setUp()

TransformationsCustomTest::setUp ( )
protected

Definition at line 33 of file TransformationsCustomTest.php.

References ILIAS\UI\examples\Chart\Bar\Horizontal\custom().

33  : void
34  {
35  $language = $this->createMock(ILIAS\Language\Language::class);
36  $this->f = new Refinery(new DataFactory(), $language);
37 
38  $this->custom = $this->f->custom()->transformation(
39  function ($value) {
40  if (!is_string($value)) {
41  throw new InvalidArgumentException("'" . gettype($value) . "' is not a string.");
42  }
43  return $value;
44  }
45  );
46  }
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
+ Here is the call graph for this function:

◆ tearDown()

TransformationsCustomTest::tearDown ( )
protected

Definition at line 48 of file TransformationsCustomTest.php.

References ILIAS\UI\examples\Chart\Bar\Horizontal\custom(), and null.

48  : void
49  {
50  $this->f = null;
51  $this->custom = null;
52  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
+ Here is the call graph for this function:

◆ testApplyToWithValidValueReturnsAnOkResult()

TransformationsCustomTest::testApplyToWithValidValueReturnsAnOkResult ( )

Definition at line 146 of file TransformationsCustomTest.php.

References ILIAS\UI\examples\Chart\Bar\Horizontal\custom().

146  : void
147  {
148  $factory = new DataFactory();
149  $valueObject = $factory->ok(self::TEST_STRING);
150 
151  $resultObject = $this->custom->applyTo($valueObject);
152 
153  $this->assertEquals(self::TEST_STRING, $resultObject->value());
154  $this->assertFalse($resultObject->isError());
155  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
+ Here is the call graph for this function:

◆ testInvoke()

TransformationsCustomTest::testInvoke ( )

Definition at line 91 of file TransformationsCustomTest.php.

References $custom.

91  : void
92  {
93  $custom = $this->f->custom()->transformation(
94  function ($value) {
95  if (!is_string($value)) {
96  throw new InvalidArgumentException("'" . gettype($value) . "' is not a string.");
97  }
98  return $value;
99  }
100  );
101 
102  $result = $custom(self::TEST_STRING);
103  $this->assertEquals(self::TEST_STRING, $result);
104  }

◆ testInvokeFails()

TransformationsCustomTest::testInvokeFails ( )

Definition at line 106 of file TransformationsCustomTest.php.

References $custom, and Vendor\Package\$e.

106  : void
107  {
108  $custom = $this->f->custom()->transformation(
109  function ($value) {
110  if (!is_string($value)) {
111  throw new InvalidArgumentException("'" . gettype($value) . "' is not a string.");
112  }
113  return $value;
114  }
115  );
116 
117  $raised = false;
118  try {
119  $lower_string = $custom([]);
120  } catch (InvalidArgumentException $e) {
121  $this->assertEquals("'array' is not a string.", $e->getMessage());
122  $raised = true;
123  }
124  $this->assertTrue($raised);
125 
126  $raised = false;
127  try {
128  $lower_string = $custom(12345);
129  } catch (InvalidArgumentException $e) {
130  $this->assertEquals("'integer' is not a string.", $e->getMessage());
131  $raised = true;
132  }
133  $this->assertTrue($raised);
134 
135  $raised = false;
136  try {
137  $std_class = new stdClass();
138  $lower_string = $custom($std_class);
139  } catch (InvalidArgumentException $e) {
140  $this->assertEquals("'object' is not a string.", $e->getMessage());
141  $raised = true;
142  }
143  $this->assertTrue($raised);
144  }

◆ testTransform()

TransformationsCustomTest::testTransform ( )

Definition at line 54 of file TransformationsCustomTest.php.

References ILIAS\UI\examples\Chart\Bar\Horizontal\custom().

54  : void
55  {
56  $result = $this->custom->transform(self::TEST_STRING);
57  $this->assertEquals(self::TEST_STRING, $result);
58  }
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
+ Here is the call graph for this function:

◆ testTransformFails()

TransformationsCustomTest::testTransformFails ( )

Definition at line 60 of file TransformationsCustomTest.php.

References Vendor\Package\$e, and ILIAS\UI\examples\Chart\Bar\Horizontal\custom().

60  : void
61  {
62  $raised = false;
63  try {
64  $lower_string = $this->custom->transform([]);
65  } catch (InvalidArgumentException $e) {
66  $this->assertEquals("'array' is not a string.", $e->getMessage());
67  $raised = true;
68  }
69  $this->assertTrue($raised);
70 
71  $raised = false;
72  try {
73  $lower_string = $this->custom->transform(12345);
74  } catch (InvalidArgumentException $e) {
75  $this->assertEquals("'integer' is not a string.", $e->getMessage());
76  $raised = true;
77  }
78  $this->assertTrue($raised);
79 
80  $raised = false;
81  try {
82  $std_class = new stdClass();
83  $lower_string = $this->custom->transform($std_class);
84  } catch (InvalidArgumentException $e) {
85  $this->assertEquals("'object' is not a string.", $e->getMessage());
86  $raised = true;
87  }
88  $this->assertTrue($raised);
89  }
custom()
expected output: > ILIAS shows a base horizontal bar chart but customized with e.g.
Definition: custom.php:33
+ Here is the call graph for this function:

Field Documentation

◆ $custom

Transformation TransformationsCustomTest::$custom
private

Definition at line 30 of file TransformationsCustomTest.php.

Referenced by testInvoke(), and testInvokeFails().

◆ $f

Refinery TransformationsCustomTest::$f
private

Definition at line 31 of file TransformationsCustomTest.php.

◆ TEST_STRING

const TransformationsCustomTest::TEST_STRING = "Test"
private

Definition at line 28 of file TransformationsCustomTest.php.


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