3declare(strict_types=1);
8use PHPUnit\Framework\TestCase;
19 const TEST_STRING_1 =
"I am a test string for the title capitalization and I hope that works even if it is complicated :)";
38 protected function setUp() : void
42 $language = $this->createMock(
'\\' . ilLanguage::class);
44 $this->f =
new Refinery\Factory($dataFactory, $language);
45 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
55 $this->case_of_label_if_possible =
null;
64 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
66 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
75 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_2);
77 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_2, $str);
86 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_3);
88 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_3, $str);
100 $next_str = $this->case_of_label_if_possible->transform($arr);
101 }
catch (InvalidArgumentException
$e) {
104 $this->assertTrue($raised);
109 $next_str = $this->case_of_label_if_possible->transform($int);
110 }
catch (InvalidArgumentException
$e) {
113 $this->assertTrue($raised);
117 $std_class =
new stdClass();
118 $next_str = $this->case_of_label_if_possible->transform($std_class);
119 }
catch (InvalidArgumentException
$e) {
122 $this->assertTrue($raised);
131 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
135 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
144 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
150 }
catch (InvalidArgumentException
$e) {
153 $this->assertTrue($raised);
159 }
catch (InvalidArgumentException
$e) {
162 $this->assertTrue($raised);
166 $std_class =
new stdClass();
168 }
catch (InvalidArgumentException
$e) {
171 $this->assertTrue($raised);
182 $valueObject =
$factory->ok(self::TEST_STRING_1);
184 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
186 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $resultObject->value());
187 $this->assertFalse($resultObject->isError());
200 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
202 $this->assertTrue($resultObject->isError());
211 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::SENSELESS_LANGUAGE_KEY);
215 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
216 }
catch (LogicException
$e) {
219 $this->assertTrue($raised);
An exception for terminatinating execution or to throw for unit testing.
const EXPECTED_RESULT_TEST_STRING_1
const EXPECTED_RESULT_TEST_STRING_2
const SENSELESS_LANGUAGE_KEY
testApplyToWithInvalidValueWillLeadToErrorResult()
const EXPECTED_RESULT_TEST_STRING_3
$case_of_label_if_possible
testApplyToWithValidValueReturnsAnOkResult()