19declare(strict_types=1);
30use PHPUnit\Framework\TestCase;
39 $this->v = $this->createMock(Description::class);
41 $this->createMock(\
ILIAS\
Data\
Text\SimpleDocumentMarkdown::class),
51 $res = $this->l->getPrimitiveRepresentation(
$data);
53 $this->assertInstanceOf(\Closure::class,
$res);
54 $errors = iterator_to_array(
$res());
55 $this->assertCount(1, $errors);
56 $this->assertTrue(is_string($errors[0]));
62 [1], [
"1"], [
null], [
true], [new \StdClass()], [new \DateTimeImmutable()]
68 $res = $this->l->getPrimitiveRepresentation([]);
70 $this->assertEquals([],
$res);
78 $this->v->expects($this->exactly(2))
79 ->method(
"getPrimitiveRepresentation")
80 ->willReturnCallback(
function (
$v) use (&$values) {
81 array_push($values,
$v);
82 return array_shift($values);
85 $expected = [
"c",
"d"];
87 $res = $this->l->getPrimitiveRepresentation(
$data);
89 $this->assertEquals($expected,
$res);
90 $this->assertEquals([
"a",
"b"], $values);
98 ->method(
"getPrimitiveRepresentation")
99 ->willReturn(fn() => yield
"FAILURE");
101 $res = $this->l->getPrimitiveRepresentation(
$data);
103 $this->assertInstanceOf(\Closure::class,
$res);
104 $errors = iterator_to_array(
$res());
105 $this->assertCount(1, $errors);
106 $this->assertTrue(is_string($errors[0]));
107 $this->assertTrue(str_contains($errors[0],
"FAILURE"));
112 $data = [2 =>
"a", 27 =>
"b"];
115 ->method(
"getPrimitiveRepresentation")
116 ->will($this->returnCallback(fn(
$v) =>
$v));
118 $res = $this->l->getPrimitiveRepresentation(
$data);
120 $expected = [
"a",
"b"];
122 $this->assertEquals($expected,
$res);
static obviousNoMatchProvider()
testObviouslyNotMatching($data)
@dataProvider obviousNoMatchProvider
testFailsOnValueFailure()
testForwardsToSubDescription()
This describes some datastructure in terms of standard data structures such as primitives,...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.