19declare(strict_types=1);
24use PHPUnit\Framework\TestCase;
33 protected function setUp(): void
35 $language = $this->createMock(
ILIAS\Language\Language::class);
36 $this->f =
new Refinery(
new DataFactory(), $language);
38 $this->
custom = $this->f->custom()->transformation(
40 if (!is_string($value)) {
41 throw new InvalidArgumentException(
"'" . gettype($value) .
"' is not a string.");
56 $result = $this->
custom->transform(self::TEST_STRING);
57 $this->assertEquals(self::TEST_STRING, $result);
64 $lower_string = $this->
custom->transform([]);
65 }
catch (InvalidArgumentException
$e) {
66 $this->assertEquals(
"'array' is not a string.",
$e->getMessage());
69 $this->assertTrue($raised);
73 $lower_string = $this->
custom->transform(12345);
74 }
catch (InvalidArgumentException
$e) {
75 $this->assertEquals(
"'integer' is not a string.",
$e->getMessage());
78 $this->assertTrue($raised);
82 $std_class =
new stdClass();
83 $lower_string = $this->
custom->transform($std_class);
84 }
catch (InvalidArgumentException
$e) {
85 $this->assertEquals(
"'object' is not a string.",
$e->getMessage());
88 $this->assertTrue($raised);
93 $custom = $this->f->custom()->transformation(
95 if (!is_string($value)) {
96 throw new InvalidArgumentException(
"'" . gettype($value) .
"' is not a string.");
102 $result =
$custom(self::TEST_STRING);
103 $this->assertEquals(self::TEST_STRING, $result);
108 $custom = $this->f->custom()->transformation(
110 if (!is_string($value)) {
111 throw new InvalidArgumentException(
"'" . gettype($value) .
"' is not a string.");
120 }
catch (InvalidArgumentException
$e) {
121 $this->assertEquals(
"'array' is not a string.",
$e->getMessage());
124 $this->assertTrue($raised);
128 $lower_string =
$custom(12345);
129 }
catch (InvalidArgumentException
$e) {
130 $this->assertEquals(
"'integer' is not a string.",
$e->getMessage());
133 $this->assertTrue($raised);
137 $std_class =
new stdClass();
138 $lower_string =
$custom($std_class);
139 }
catch (InvalidArgumentException
$e) {
140 $this->assertEquals(
"'object' is not a string.",
$e->getMessage());
143 $this->assertTrue($raised);
148 $factory =
new DataFactory();
149 $valueObject = $factory->ok(self::TEST_STRING);
151 $resultObject = $this->
custom->applyTo($valueObject);
153 $this->assertEquals(self::TEST_STRING, $resultObject->value());
154 $this->assertFalse($resultObject->isError());
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.