3 declare(strict_types=1);
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
40 $dataFactory =
new Data\Factory();
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);
104 $this->assertTrue($raised);
109 $next_str = $this->case_of_label_if_possible->transform($int);
113 $this->assertTrue($raised);
118 $next_str = $this->case_of_label_if_possible->transform($std_class);
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);
153 $this->assertTrue($raised);
162 $this->assertTrue($raised);
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);
219 $this->assertTrue($raised);
const EXPECTED_RESULT_TEST_STRING_2
testApplyToWithValidValueReturnsAnOkResult()
const EXPECTED_RESULT_TEST_STRING_3
const SENSELESS_LANGUAGE_KEY
$case_of_label_if_possible
testApplyToWithInvalidValueWillLeadToErrorResult()
const EXPECTED_RESULT_TEST_STRING_1