ILIAS  release_7 Revision v7.30-3-g800a261c036
AddLabelTest Class Reference

TestCase for AddLabel transformations. More...

+ Inheritance diagram for AddLabelTest:
+ Collaboration diagram for AddLabelTest:

Public Member Functions

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

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Static Protected Attributes

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

Private Attributes

 $f
 

Detailed Description

TestCase for AddLabel transformations.

Author
Stefan Hecken stefa.nosp@m.n.he.nosp@m.cken@.nosp@m.conc.nosp@m.epts-.nosp@m.and-.nosp@m.train.nosp@m.ing..nosp@m.de

Definition at line 13 of file AddLabelTest.php.

Member Function Documentation

◆ setUp()

AddLabelTest::setUp ( )
protected

Definition at line 23 of file AddLabelTest.php.

23 : void
24 {
25 $dataFactory = new ILIAS\Data\Factory();
26 $language = $this->createMock('\ilLanguage');
27
28 $this->f = new ILIAS\Refinery\Factory($dataFactory, $language);
29 $this->add_label = $this->f->container()->addLabels(self::$labels);
30 }
Builds data types.
Definition: Factory.php:20

◆ tearDown()

AddLabelTest::tearDown ( )
protected

Definition at line 32 of file AddLabelTest.php.

32 : void
33 {
34 $this->f = null;
35 $this->add_label = null;
36 }

◆ testInvoke()

AddLabelTest::testInvoke ( )

Definition at line 83 of file AddLabelTest.php.

84 {
85 $add_label = $this->f->container()->addLabels(self::$labels);
86 $with = $add_label(self::$test_array);
87 $this->assertEquals(self::$result_array, $with);
88 }

◆ testInvokeFails()

AddLabelTest::testInvokeFails ( )

Definition at line 90 of file AddLabelTest.php.

91 {
92 $add_label = $this->f->container()->addLabels(self::$labels);
93
94 $raised = false;
95 try {
96 $with = null;
97 $next_with = $add_label($with);
98 } catch (InvalidArgumentException $e) {
99 $raised = true;
100 }
101 $this->assertTrue($raised);
102
103 $raised = false;
104 try {
105 $without = array(1, 2, 3, 4);
106 $with = $add_label($without);
107 } catch (InvalidArgumentException $e) {
108 $raised = true;
109 }
110 $this->assertTrue($raised);
111
112 $raised = false;
113 try {
114 $without = "1, 2, 3";
115 $with = $add_label($without);
116 } catch (InvalidArgumentException $e) {
117 $raised = true;
118 }
119 $this->assertTrue($raised);
120
121 $raised = false;
122 try {
123 $std_class = new stdClass();
124 $with = $add_label($std_class);
125 } catch (InvalidArgumentException $e) {
126 $raised = true;
127 }
128 $this->assertTrue($raised);
129 }

References Vendor\Package\$e.

◆ testTransform()

AddLabelTest::testTransform ( )

Definition at line 38 of file AddLabelTest.php.

39 {
40 $with = $this->add_label->transform(self::$test_array);
41 $this->assertEquals(self::$result_array, $with);
42 }

◆ testTransformFails()

AddLabelTest::testTransformFails ( )

Definition at line 44 of file AddLabelTest.php.

45 {
46 $raised = false;
47 try {
48 $with = null;
49 $next_with = $this->add_label->transform($with);
50 } catch (InvalidArgumentException $e) {
51 $raised = true;
52 }
53 $this->assertTrue($raised);
54
55 $raised = false;
56 try {
57 $without = array(1, 2, 3, 4);
58 $with = $this->add_label->transform($without);
59 } catch (InvalidArgumentException $e) {
60 $raised = true;
61 }
62 $this->assertTrue($raised);
63
64 $raised = false;
65 try {
66 $without = "1, 2, 3";
67 $with = $this->add_label->transform($without);
68 } catch (InvalidArgumentException $e) {
69 $raised = true;
70 }
71 $this->assertTrue($raised);
72
73 $raised = false;
74 try {
75 $std_class = new stdClass();
76 $with = $this->add_label->transform($std_class);
77 } catch (InvalidArgumentException $e) {
78 $raised = true;
79 }
80 $this->assertTrue($raised);
81 }

References Vendor\Package\$e.

Field Documentation

◆ $f

AddLabelTest::$f
private

Definition at line 21 of file AddLabelTest.php.

◆ $labels

AddLabelTest::$labels = array("A", "B", "C")
staticprotected

Definition at line 15 of file AddLabelTest.php.

◆ $result_array

AddLabelTest::$result_array = array("A" => 1, "B" => 2, "C" => 3)
staticprotected

Definition at line 17 of file AddLabelTest.php.

◆ $test_array

AddLabelTest::$test_array = array(1, 2, 3)
staticprotected

Definition at line 16 of file AddLabelTest.php.


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