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

Public Member Functions

 testTransform1 ()
 
 testTransform2 ()
 
 testTransform3 ()
 
 testTransformFails ()
 
 testInvoke ()
 
 testInvokeFails ()
 
 testApplyToWithValidValueReturnsAnOkResult ()
 
 testApplyToWithInvalidValueWillLeadToErrorResult ()
 
 testUnknownLanguageKey ()
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Private Attributes

const LANGUAGE_KEY = "en"
 
const SENSELESS_LANGUAGE_KEY = "this_language_key_will_never_exist"
 
const TEST_STRING_1 = "I am a test string for the title capitalization and I hope that works even if it is complicated :)"
 
const TEST_STRING_2 = "I switch the computer on and go online"
 
const TEST_STRING_3 = "Now it is working"
 
const EXPECTED_RESULT_TEST_STRING_1 = "I Am a Test String for the Title Capitalization and I Hope that Works even if It Is Complicated :)"
 
const EXPECTED_RESULT_TEST_STRING_2 = "I Switch the Computer on and Go Online"
 
const EXPECTED_RESULT_TEST_STRING_3 = "Now It Is Working"
 
Transformation $case_of_label_if_possible
 
Refinery $f
 

Detailed Description

Definition at line 26 of file CaseOfLabelTest.php.

Member Function Documentation

◆ setUp()

CaseOfLabelTest::setUp ( )
protected

Definition at line 40 of file CaseOfLabelTest.php.

40 : void
41 {
42 $dataFactory = new DataFactory();
43
44 $language = $this->createMock(ILIAS\Language\Language::class);
45
46 $this->f = new Refinery($dataFactory, $language);
47 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
48 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

◆ tearDown()

CaseOfLabelTest::tearDown ( )
protected

Definition at line 50 of file CaseOfLabelTest.php.

50 : void
51 {
52 $this->f = null;
53 $this->case_of_label_if_possible = null;
54 }

◆ testApplyToWithInvalidValueWillLeadToErrorResult()

CaseOfLabelTest::testApplyToWithInvalidValueWillLeadToErrorResult ( )

Definition at line 161 of file CaseOfLabelTest.php.

161 : void
162 {
163 $factory = new DataFactory();
164
165 $valueObject = $factory->ok(42);
166
167 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
168
169 $this->assertTrue($resultObject->isError());
170 }

◆ testApplyToWithValidValueReturnsAnOkResult()

CaseOfLabelTest::testApplyToWithValidValueReturnsAnOkResult ( )

Definition at line 149 of file CaseOfLabelTest.php.

149 : void
150 {
151 $factory = new DataFactory();
152
153 $valueObject = $factory->ok(self::TEST_STRING_1);
154
155 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
156
157 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $resultObject->value());
158 $this->assertFalse($resultObject->isError());
159 }

◆ testInvoke()

CaseOfLabelTest::testInvoke ( )

Definition at line 108 of file CaseOfLabelTest.php.

108 : void
109 {
110 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
111
112 $str = ($this->case_of_label_if_possible)(self::TEST_STRING_1);
113
114 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
115 }
Transformation $case_of_label_if_possible

References $case_of_label_if_possible.

◆ testInvokeFails()

CaseOfLabelTest::testInvokeFails ( )

Definition at line 117 of file CaseOfLabelTest.php.

117 : void
118 {
119 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
120
121 $raised = false;
122 try {
123 $arr = [];
124 $next_str = ($this->case_of_label_if_possible)($arr);
125 } catch (InvalidArgumentException $e) {
126 $raised = true;
127 }
128 $this->assertTrue($raised);
129
130 $raised = false;
131 try {
132 $int = 1001;
133 $next_str = ($this->case_of_label_if_possible)($int);
134 } catch (InvalidArgumentException $e) {
135 $raised = true;
136 }
137 $this->assertTrue($raised);
138
139 $raised = false;
140 try {
141 $std_class = new stdClass();
142 $next_str = ($this->case_of_label_if_possible)($std_class);
143 } catch (InvalidArgumentException $e) {
144 $raised = true;
145 }
146 $this->assertTrue($raised);
147 }

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

◆ testTransform1()

CaseOfLabelTest::testTransform1 ( )

Definition at line 56 of file CaseOfLabelTest.php.

56 : void
57 {
58 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
59
60 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
61 }

◆ testTransform2()

CaseOfLabelTest::testTransform2 ( )

Definition at line 63 of file CaseOfLabelTest.php.

63 : void
64 {
65 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_2);
66
67 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_2, $str);
68 }

◆ testTransform3()

CaseOfLabelTest::testTransform3 ( )

Definition at line 71 of file CaseOfLabelTest.php.

71 : void
72 {
73 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_3);
74
75 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_3, $str);
76 }

◆ testTransformFails()

CaseOfLabelTest::testTransformFails ( )

Definition at line 78 of file CaseOfLabelTest.php.

78 : void
79 {
80 $raised = false;
81 try {
82 $arr = [];
83 $next_str = $this->case_of_label_if_possible->transform($arr);
84 } catch (InvalidArgumentException $e) {
85 $raised = true;
86 }
87 $this->assertTrue($raised);
88
89 $raised = false;
90 try {
91 $int = 1001;
92 $next_str = $this->case_of_label_if_possible->transform($int);
93 } catch (InvalidArgumentException $e) {
94 $raised = true;
95 }
96 $this->assertTrue($raised);
97
98 $raised = false;
99 try {
100 $std_class = new stdClass();
101 $next_str = $this->case_of_label_if_possible->transform($std_class);
102 } catch (InvalidArgumentException $e) {
103 $raised = true;
104 }
105 $this->assertTrue($raised);
106 }

References Vendor\Package\$e.

◆ testUnknownLanguageKey()

CaseOfLabelTest::testUnknownLanguageKey ( )

Definition at line 172 of file CaseOfLabelTest.php.

172 : void
173 {
174 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::SENSELESS_LANGUAGE_KEY);
175
176 $raised = false;
177 try {
178 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
179 } catch (LogicException $e) {
180 $raised = true;
181 }
182 $this->assertTrue($raised);
183 }

References Vendor\Package\$e.

Field Documentation

◆ $case_of_label_if_possible

Transformation CaseOfLabelTest::$case_of_label_if_possible
private

Definition at line 37 of file CaseOfLabelTest.php.

Referenced by testInvoke(), and testInvokeFails().

◆ $f

Refinery CaseOfLabelTest::$f
private

Definition at line 38 of file CaseOfLabelTest.php.

◆ EXPECTED_RESULT_TEST_STRING_1

const CaseOfLabelTest::EXPECTED_RESULT_TEST_STRING_1 = "I Am a Test String for the Title Capitalization and I Hope that Works even if It Is Complicated :)"
private

Definition at line 33 of file CaseOfLabelTest.php.

◆ EXPECTED_RESULT_TEST_STRING_2

const CaseOfLabelTest::EXPECTED_RESULT_TEST_STRING_2 = "I Switch the Computer on and Go Online"
private

Definition at line 34 of file CaseOfLabelTest.php.

◆ EXPECTED_RESULT_TEST_STRING_3

const CaseOfLabelTest::EXPECTED_RESULT_TEST_STRING_3 = "Now It Is Working"
private

Definition at line 35 of file CaseOfLabelTest.php.

◆ LANGUAGE_KEY

const CaseOfLabelTest::LANGUAGE_KEY = "en"
private

Definition at line 28 of file CaseOfLabelTest.php.

◆ SENSELESS_LANGUAGE_KEY

const CaseOfLabelTest::SENSELESS_LANGUAGE_KEY = "this_language_key_will_never_exist"
private

Definition at line 29 of file CaseOfLabelTest.php.

◆ TEST_STRING_1

const CaseOfLabelTest::TEST_STRING_1 = "I am a test string for the title capitalization and I hope that works even if it is complicated :)"
private

Definition at line 30 of file CaseOfLabelTest.php.

◆ TEST_STRING_2

const CaseOfLabelTest::TEST_STRING_2 = "I switch the computer on and go online"
private

Definition at line 31 of file CaseOfLabelTest.php.

◆ TEST_STRING_3

const CaseOfLabelTest::TEST_STRING_3 = "Now it is working"
private

Definition at line 32 of file CaseOfLabelTest.php.


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