19declare(strict_types=1);
30use PHPUnit\Framework\TestCase;
31use PHPUnit\Framework\Attributes\DataProvider;
40 $this->v = $this->createMock(Description::class);
42 $this->createMock(\
ILIAS\
Data\
Text\SimpleDocumentMarkdown::class),
47 #[DataProvider('obviousNoMatchProvider')]
50 $res = $this->l->getPrimitiveRepresentation(
$data);
52 $this->assertInstanceOf(\Closure::class,
$res);
53 $errors = iterator_to_array(
$res());
54 $this->assertCount(1, $errors);
55 $this->assertTrue(is_string($errors[0]));
61 [1], [
"1"], [
null], [
true], [new \StdClass()], [new \DateTimeImmutable()]
67 $res = $this->l->getPrimitiveRepresentation([]);
69 $this->assertEquals([],
$res);
77 $this->v->expects($this->exactly(2))
78 ->method(
"getPrimitiveRepresentation")
79 ->willReturnCallback(
function (
$v) use (&$values) {
80 array_push($values,
$v);
81 return array_shift($values);
84 $expected = [
"c",
"d"];
86 $res = $this->l->getPrimitiveRepresentation(
$data);
88 $this->assertEquals($expected,
$res);
89 $this->assertEquals([
"a",
"b"], $values);
97 ->method(
"getPrimitiveRepresentation")
98 ->willReturn(fn() => yield
"FAILURE");
100 $res = $this->l->getPrimitiveRepresentation(
$data);
102 $this->assertInstanceOf(\Closure::class,
$res);
103 $errors = iterator_to_array(
$res());
104 $this->assertCount(1, $errors);
105 $this->assertTrue(is_string($errors[0]));
106 $this->assertTrue(str_contains($errors[0],
"FAILURE"));
111 $data = [2 =>
"a", 27 =>
"b"];
114 ->method(
"getPrimitiveRepresentation")
115 ->willReturnCallback(fn(
$v) =>
$v);
117 $res = $this->l->getPrimitiveRepresentation(
$data);
119 $expected = [
"a",
"b"];
121 $this->assertEquals($expected,
$res);
static obviousNoMatchProvider()
testObviouslyNotMatching($data)
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.