19declare(strict_types=1);
24use PHPUnit\Framework\TestCase;
30 private const TEST_STRING_1 =
"I am a test string for the title capitalization and I hope that works even if it is complicated :)";
40 protected function setUp(): void
42 $dataFactory =
new DataFactory();
44 $language = $this->createMock(
ILIAS\Language\Language::class);
46 $this->f =
new Refinery($dataFactory, $language);
47 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
53 $this->case_of_label_if_possible =
null;
58 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
60 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
65 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_2);
67 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_2, $str);
73 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_3);
75 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_3, $str);
83 $next_str = $this->case_of_label_if_possible->transform($arr);
84 }
catch (InvalidArgumentException
$e) {
87 $this->assertTrue($raised);
92 $next_str = $this->case_of_label_if_possible->transform($int);
93 }
catch (InvalidArgumentException
$e) {
96 $this->assertTrue($raised);
100 $std_class =
new stdClass();
101 $next_str = $this->case_of_label_if_possible->transform($std_class);
102 }
catch (InvalidArgumentException
$e) {
105 $this->assertTrue($raised);
110 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
114 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $str);
119 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::LANGUAGE_KEY);
125 }
catch (InvalidArgumentException
$e) {
128 $this->assertTrue($raised);
134 }
catch (InvalidArgumentException
$e) {
137 $this->assertTrue($raised);
141 $std_class =
new stdClass();
143 }
catch (InvalidArgumentException
$e) {
146 $this->assertTrue($raised);
151 $factory =
new DataFactory();
153 $valueObject = $factory->ok(self::TEST_STRING_1);
155 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
157 $this->assertEquals(self::EXPECTED_RESULT_TEST_STRING_1, $resultObject->value());
158 $this->assertFalse($resultObject->isError());
163 $factory =
new DataFactory();
165 $valueObject = $factory->ok(42);
167 $resultObject = $this->case_of_label_if_possible->applyTo($valueObject);
169 $this->assertTrue($resultObject->isError());
174 $this->case_of_label_if_possible = $this->f->string()->caseOfLabel(self::SENSELESS_LANGUAGE_KEY);
178 $str = $this->case_of_label_if_possible->transform(self::TEST_STRING_1);
179 }
catch (LogicException
$e) {
182 $this->assertTrue($raised);
const EXPECTED_RESULT_TEST_STRING_1
const EXPECTED_RESULT_TEST_STRING_2
const SENSELESS_LANGUAGE_KEY
testApplyToWithInvalidValueWillLeadToErrorResult()
const EXPECTED_RESULT_TEST_STRING_3
Transformation $case_of_label_if_possible
testApplyToWithValidValueReturnsAnOkResult()
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.