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

Class CaseOfLabelTest. More...

+ Inheritance diagram for CaseOfLabelTest:
+ Collaboration diagram for CaseOfLabelTest:

Public Member Functions

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

Data Fields

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"
 

Protected Member Functions

 setUp ()
 
 tearDown ()
 

Protected Attributes

 $case_of_label_if_possible
 
 $f
 

Detailed Description

Member Function Documentation

◆ setUp()

CaseOfLabelTest::setUp ( )
protected

Definition at line 38 of file CaseOfLabelTest.php.

38 : void
39 {
40 $dataFactory = new Data\Factory();
41
42 $language = $this->createMock('\\' . ilLanguage::class);
43
44 $this->f = new Refinery\Factory($dataFactory, $language);
45 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
46 }

◆ tearDown()

CaseOfLabelTest::tearDown ( )
protected

Definition at line 52 of file CaseOfLabelTest.php.

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

◆ testApplyToWithInvalidValueWillLeadToErrorResult()

CaseOfLabelTest::testApplyToWithInvalidValueWillLeadToErrorResult ( )

Definition at line 194 of file CaseOfLabelTest.php.

194 : void
195 {
196 $factory = new Data\Factory();
197
198 $valueObject = $factory->ok(42);
199
200 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
201
202 $this->assertTrue($resultObject->isError());
203 }
$factory
Definition: metadata.php:58

References $factory.

◆ testApplyToWithValidValueReturnsAnOkResult()

CaseOfLabelTest::testApplyToWithValidValueReturnsAnOkResult ( )

Definition at line 178 of file CaseOfLabelTest.php.

178 : void
179 {
180 $factory = new Data\Factory();
181
182 $valueObject = $factory->ok(self::TEST_STRING_1);
183
184 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
185
186 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $resultObject->value());
187 $this->assertFalse($resultObject->isError());
188 }

References $factory.

◆ testInvoke()

CaseOfLabelTest::testInvoke ( )

Definition at line 129 of file CaseOfLabelTest.php.

129 : void
130 {
131 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
132
133 $str = ($this->case_of_label_if_possible)(self::TEST_STRING_1);
134
135 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
136 }

References $case_of_label_if_possible.

◆ testInvokeFails()

CaseOfLabelTest::testInvokeFails ( )

Definition at line 142 of file CaseOfLabelTest.php.

142 : void
143 {
144 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
145
146 $raised = false;
147 try {
148 $arr = [];
149 $next_str = ($this->case_of_label_if_possible)($arr);
150 } catch (InvalidArgumentException $e) {
151 $raised = true;
152 }
153 $this->assertTrue($raised);
154
155 $raised = false;
156 try {
157 $int = 1001;
158 $next_str = ($this->case_of_label_if_possible)($int);
159 } catch (InvalidArgumentException $e) {
160 $raised = true;
161 }
162 $this->assertTrue($raised);
163
164 $raised = false;
165 try {
166 $std_class = new stdClass();
167 $next_str = ($this->case_of_label_if_possible)($std_class);
168 } catch (InvalidArgumentException $e) {
169 $raised = true;
170 }
171 $this->assertTrue($raised);
172 }

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

◆ testTransform1()

CaseOfLabelTest::testTransform1 ( )

Definition at line 62 of file CaseOfLabelTest.php.

62 : void
63 {
64 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
65
66 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
67 }

◆ testTransform2()

CaseOfLabelTest::testTransform2 ( )

Definition at line 73 of file CaseOfLabelTest.php.

73 : void
74 {
75 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_2);
76
77 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_2, $str);
78 }

◆ testTransform3()

CaseOfLabelTest::testTransform3 ( )

Definition at line 84 of file CaseOfLabelTest.php.

84 : void
85 {
86 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_3);
87
88 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_3, $str);
89 }

◆ testTransformFails()

CaseOfLabelTest::testTransformFails ( )

Definition at line 95 of file CaseOfLabelTest.php.

95 : void
96 {
97 $raised = false;
98 try {
99 $arr = [];
100 $next_str = $this->case_of_label_if_possible->transform($arr);
101 } catch (InvalidArgumentException $e) {
102 $raised = true;
103 }
104 $this->assertTrue($raised);
105
106 $raised = false;
107 try {
108 $int = 1001;
109 $next_str = $this->case_of_label_if_possible->transform($int);
110 } catch (InvalidArgumentException $e) {
111 $raised = true;
112 }
113 $this->assertTrue($raised);
114
115 $raised = false;
116 try {
117 $std_class = new stdClass();
118 $next_str = $this->case_of_label_if_possible->transform($std_class);
119 } catch (InvalidArgumentException $e) {
120 $raised = true;
121 }
122 $this->assertTrue($raised);
123 }

References Vendor\Package\$e.

◆ testUnknownLanguageKey()

CaseOfLabelTest::testUnknownLanguageKey ( )

Definition at line 209 of file CaseOfLabelTest.php.

209 : void
210 {
211 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::SENSELESS_LANGUAGE_KEY);
212
213 $raised = false;
214 try {
215 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
216 } catch (LogicException $e) {
217 $raised = true;
218 }
219 $this->assertTrue($raised);
220 }

References Vendor\Package\$e.

Field Documentation

◆ $case_of_label_if_possible

CaseOfLabelTest::$case_of_label_if_possible
protected

Definition at line 28 of file CaseOfLabelTest.php.

Referenced by testInvoke(), and testInvokeFails().

◆ $f

CaseOfLabelTest::$f
protected

Definition at line 32 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 :)"

Definition at line 22 of file CaseOfLabelTest.php.

◆ EXPECTED_RESULT_TEST_STRING_2

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

Definition at line 23 of file CaseOfLabelTest.php.

◆ EXPECTED_RESULT_TEST_STRING_3

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

Definition at line 24 of file CaseOfLabelTest.php.

◆ LANGUAGE_KEY

const CaseOfLabelTest::LANGUAGE_KEY = "en"

Definition at line 17 of file CaseOfLabelTest.php.

◆ SENSELESS_LANGUAGE_KEY

const CaseOfLabelTest::SENSELESS_LANGUAGE_KEY = "this_language_key_will_never_exist"

Definition at line 18 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 :)"

Definition at line 19 of file CaseOfLabelTest.php.

◆ TEST_STRING_2

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

Definition at line 20 of file CaseOfLabelTest.php.

◆ TEST_STRING_3

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

Definition at line 21 of file CaseOfLabelTest.php.


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