ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AddLabelTest Class Reference
+ Inheritance diagram for AddLabelTest:
+ Collaboration diagram for AddLabelTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Private Attributes

Refinery $f
 
Transformation $add_label
 

Static Private Attributes

static array $labels = ["A", "B", "C"]
 
static array $test_array = [1, 2, 3]
 
static array $result_array = ["A" => 1, "B" => 2, "C" => 3]
 

Detailed Description

Definition at line 26 of file AddLabelTest.php.

Member Function Documentation

◆ setUp()

AddLabelTest::setUp ( )
protected

Definition at line 38 of file AddLabelTest.php.

38 : void
39 {
40 $dataFactory = new DataFactory();
41 $language = $this->createMock(ILIAS\Language\Language::class);
42
43 $this->f = new Refinery($dataFactory, $language);
44 $this->add_label = $this->f->container()->addLabels(self::$labels);
45 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ tearDown()

AddLabelTest::tearDown ( )
protected

Definition at line 47 of file AddLabelTest.php.

47 : void
48 {
49 $this->f = null;
50 $this->add_label = null;
51 }

◆ testInvoke()

AddLabelTest::testInvoke ( )

Definition at line 98 of file AddLabelTest.php.

98 : void
99 {
100 $add_label = $this->f->container()->addLabels(self::$labels);
101 $with = $add_label(self::$test_array);
102 $this->assertEquals(self::$result_array, $with);
103 }
Transformation $add_label

References $add_label.

◆ testInvokeFails()

AddLabelTest::testInvokeFails ( )

Definition at line 105 of file AddLabelTest.php.

105 : void
106 {
107 $add_label = $this->f->container()->addLabels(self::$labels);
108
109 $raised = false;
110 try {
111 $with = null;
112 $next_with = $add_label($with);
113 } catch (InvalidArgumentException $e) {
114 $raised = true;
115 }
116 $this->assertTrue($raised);
117
118 $raised = false;
119 try {
120 $without = [1, 2, 3, 4];
121 $with = $add_label($without);
122 } catch (InvalidArgumentException $e) {
123 $raised = true;
124 }
125 $this->assertTrue($raised);
126
127 $raised = false;
128 try {
129 $without = "1, 2, 3";
130 $with = $add_label($without);
131 } catch (InvalidArgumentException $e) {
132 $raised = true;
133 }
134 $this->assertTrue($raised);
135
136 $raised = false;
137 try {
138 $std_class = new stdClass();
139 $with = $add_label($std_class);
140 } catch (InvalidArgumentException $e) {
141 $raised = true;
142 }
143 $this->assertTrue($raised);
144 }

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

◆ testTransform()

AddLabelTest::testTransform ( )

Definition at line 53 of file AddLabelTest.php.

53 : void
54 {
55 $with = $this->add_label->transform(self::$test_array);
56 $this->assertEquals(self::$result_array, $with);
57 }

◆ testTransformFails()

AddLabelTest::testTransformFails ( )

Definition at line 59 of file AddLabelTest.php.

59 : void
60 {
61 $raised = false;
62 try {
63 $with = null;
64 $next_with = $this->add_label->transform($with);
65 } catch (InvalidArgumentException $e) {
66 $raised = true;
67 }
68 $this->assertTrue($raised);
69
70 $raised = false;
71 try {
72 $without = [1, 2, 3, 4];
73 $with = $this->add_label->transform($without);
74 } catch (InvalidArgumentException $e) {
75 $raised = true;
76 }
77 $this->assertTrue($raised);
78
79 $raised = false;
80 try {
81 $without = "1, 2, 3";
82 $with = $this->add_label->transform($without);
83 } catch (InvalidArgumentException $e) {
84 $raised = true;
85 }
86 $this->assertTrue($raised);
87
88 $raised = false;
89 try {
90 $std_class = new stdClass();
91 $with = $this->add_label->transform($std_class);
92 } catch (InvalidArgumentException $e) {
93 $raised = true;
94 }
95 $this->assertTrue($raised);
96 }

References Vendor\Package\$e.

Field Documentation

◆ $add_label

Transformation AddLabelTest::$add_label
private

Definition at line 36 of file AddLabelTest.php.

Referenced by testInvoke(), and testInvokeFails().

◆ $f

Refinery AddLabelTest::$f
private

Definition at line 35 of file AddLabelTest.php.

◆ $labels

array AddLabelTest::$labels = ["A", "B", "C"]
staticprivate

Definition at line 29 of file AddLabelTest.php.

◆ $result_array

array AddLabelTest::$result_array = ["A" => 1, "B" => 2, "C" => 3]
staticprivate

Definition at line 33 of file AddLabelTest.php.

◆ $test_array

array AddLabelTest::$test_array = [1, 2, 3]
staticprivate

Definition at line 31 of file AddLabelTest.php.


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