ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
WriterTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestCase;
30
31class WriterTest extends TestCase
32{
34 {
35 return new class () extends NullRepository {
36 public function getMD(int $obj_id, int $sub_id, string $type): SetInterface
37 {
38 $xml_elements = '<obj_id>' . $obj_id . '</obj_id>' .
39 '<sub_id>' . $sub_id . '</sub_id>' .
40 '<type>' . $type . '</type>';
41 return new class ($xml_elements) extends NullSet {
42 public function __construct(public string $xml_elements)
43 {
44 }
45 };
46 }
47 };
48 }
49
51 {
52 return new class () extends NullSimpleDC {
53 public function write(SetInterface $set, int $object_ref_id): \SimpleXMLElement
54 {
55 return new \SimpleXMLElement(
56 '<xml>' . $set->xml_elements . '<ref_id>' . $object_ref_id . '</ref_id>' . '</xml>'
57 );
58 }
59 };
60 }
61
62 public function testWriteSimpleDCMetaData(): void
63 {
64 $writer = new Writer(
65 $this->getLOMRepository(),
66 $this->getSimpleDCWriter()
67 );
68
69 $expected_xml = '<xml><obj_id>' . 21 . '</obj_id>' .
70 '<sub_id>' . 21 . '</sub_id>' .
71 '<type>' . 'some type' . '</type>' .
72 '<ref_id>' . 67 . '</ref_id></xml>';
73
74 $xml = $writer->writeSimpleDCMetaData(21, 67, 'some type');
75
76 $this->assertXmlStringEqualsXmlString(
77 $expected_xml,
78 $xml->saveXML()
79 );
80 }
81}
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76