19declare(strict_types=1);
23use PHPUnit\Framework\TestCase;
31 protected static array
$result = [
"I am",
"a test string",
"for split"];
36 protected function setUp(): void
38 $dataFactory =
new DataFactory();
39 $language = $this->createMock(
ILIAS\Language\Language::class);
40 $this->f =
new Refinery($dataFactory, $language);
41 $this->split_string = $this->f->string()->splitString(
"#");
47 $this->split_string =
null;
52 $arr = $this->split_string->transform(self::STRING_TO_SPLIT);
53 $this->assertEquals(static::$result, $arr);
61 $next_arr = $this->split_string->transform($arr);
62 }
catch (InvalidArgumentException
$e) {
65 $this->assertTrue($raised);
70 $with = $this->split_string->transform($without);
71 }
catch (InvalidArgumentException
$e) {
74 $this->assertTrue($raised);
78 $std_class =
new stdClass();
79 $with = $this->split_string->transform($std_class);
80 }
catch (InvalidArgumentException
$e) {
83 $this->assertTrue($raised);
90 $this->assertEquals(static::$result, $arr);
101 }
catch (InvalidArgumentException
$e) {
104 $this->assertTrue($raised);
110 }
catch (InvalidArgumentException
$e) {
113 $this->assertTrue($raised);
117 $std_class =
new stdClass();
119 }
catch (InvalidArgumentException
$e) {
122 $this->assertTrue($raised);
127 $factory =
new DataFactory();
128 $valueObject = $factory->ok(self::STRING_TO_SPLIT);
130 $resultObject = $this->split_string->applyTo($valueObject);
132 $this->assertEquals(self::$result, $resultObject->value());
133 $this->assertFalse($resultObject->isError());
138 $factory =
new DataFactory();
139 $valueObject = $factory->ok(42);
141 $resultObject = $this->split_string->applyTo($valueObject);
143 $this->assertTrue($resultObject->isError());
testApplyToWithValidValueReturnsAnOkResult()
Transformation $split_string
testApplyToWithInvalidValueWillLeadToErrorResult()
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.