ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
ILIAS\MetaData\Services\Reader\ReaderTest Class Reference
+ Inheritance diagram for ILIAS\MetaData\Services\Reader\ReaderTest:
+ Collaboration diagram for ILIAS\MetaData\Services\Reader\ReaderTest:

Public Member Functions

 testAllData ()
 
 testFirstData ()
 

Protected Member Functions

 getPath (int $number_of_data)
 
 getReader ()
 

Detailed Description

Definition at line 36 of file ReaderTest.php.

Member Function Documentation

◆ getPath()

ILIAS\MetaData\Services\Reader\ReaderTest::getPath ( int  $number_of_data)
protected

Definition at line 38 of file ReaderTest.php.

References ILIAS\MetaData\Services\Reader\Reader\__construct().

Referenced by ILIAS\MetaData\Services\Reader\ReaderTest\testFirstData().

38  : PathInterface
39  {
40  return new class ($number_of_data) extends NullPath {
41  public function __construct(public int $number_of_data)
42  {
43  }
44  };
45  }
__construct(NavigatorFactoryInterface $navigator_factory, SetInterface $set)
Definition: Reader.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getReader()

ILIAS\MetaData\Services\Reader\ReaderTest::getReader ( )
protected

Definition at line 47 of file ReaderTest.php.

References $path, and ILIAS\MetaData\Services\Reader\Reader\__construct().

Referenced by ILIAS\MetaData\Services\Reader\ReaderTest\testAllData(), and ILIAS\MetaData\Services\Reader\ReaderTest\testFirstData().

47  : Reader
48  {
49  $nav = new class () extends NullNavigatorFactory {
50  public function navigator(
51  PathInterface $path,
52  ElementInterface $start_element
53  ): NavigatorInterface {
54  return new class ($path->number_of_data) extends NullNavigator {
55  public function __construct(protected int $number_of_data)
56  {
57  }
58 
59  protected function getElement(string $value): ElementInterface
60  {
61  return new class ($value) extends NullElement {
62  public function __construct(protected string $value)
63  {
64  }
65 
66  public function getData(): DataInterface
67  {
68  return new class ($this->value) extends NullData {
69  public function __construct(protected string $value)
70  {
71  }
72 
73  public function value(): string
74  {
75  return $this->value;
76  }
77  };
78  }
79  };
80  }
81 
82  public function elementsAtFinalStep(): \Generator
83  {
84  for ($i = 0; $i < $this->number_of_data; $i++) {
85  yield $this->getElement((string) $i);
86  }
87  }
88  };
89  }
90  };
91 
92  return new Reader($nav, new NullSet());
93  }
__construct(NavigatorFactoryInterface $navigator_factory, SetInterface $set)
Definition: Reader.php:34
$path
Definition: ltiservices.php:29
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testAllData()

ILIAS\MetaData\Services\Reader\ReaderTest::testAllData ( )

Definition at line 95 of file ReaderTest.php.

References ILIAS\MetaData\Services\Reader\ReaderTest\getReader().

95  : void
96  {
97  $reader = $this->getReader();
98 
99  $this->assertSame(
100  3,
101  count(iterator_to_array($reader->allData($this->getPath(3))))
102  );
103  $this->assertNull($reader->allData($this->getPath(0))->current());
104  }
+ Here is the call graph for this function:

◆ testFirstData()

ILIAS\MetaData\Services\Reader\ReaderTest::testFirstData ( )

Definition at line 106 of file ReaderTest.php.

References ILIAS\MetaData\Services\Reader\ReaderTest\getPath(), ILIAS\MetaData\Services\Reader\ReaderTest\getReader(), and ILIAS\Data\Description\NULL.

106  : void
107  {
108  $reader = $this->getReader();
109 
110  $this->assertSame(
111  '0',
112  $reader->firstData($this->getPath(1))->value()
113  );
114  $this->assertSame(
115  '0',
116  $reader->firstData($this->getPath(3))->value()
117  );
118 
119  $null_data = $reader->firstData($this->getPath(0));
120  $this->assertSame(
121  '',
122  $null_data->value()
123  );
124  $this->assertSame(
125  Type::NULL,
126  $null_data->type()
127  );
128  }
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: