ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
BaseSetTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
28 class BaseSetTest extends TestCase
29 {
30  protected function getBaseSet(
32  ): BaseSet {
33  return new class ($root) extends BaseSet {
34  public function __construct(
36  ) {
37  parent::__construct($root);
38  }
39  };
40  }
41 
42  protected function getRoot(): BaseElementInterface
43  {
44  return new class () extends NullBaseElement {
45  public function getMDID(): int|NoID
46  {
47  return NoID::ROOT;
48  }
49 
50  public function isRoot(): bool
51  {
52  return true;
53  }
54  };
55  }
56 
57  public function testGetRoot(): void
58  {
59  $root = $this->getRoot();
60  $set = $this->getBaseSet($root);
61 
62  $this->assertSame($root, $set->getRoot());
63  }
64 
65  public function testNotRootException(): void
66  {
67  $not_root = new NullBaseElement();
68 
69  $this->expectException(\ilMDElementsException::class);
70  $set = $this->getBaseSet($not_root);
71  }
72 
73  public function testClone(): void
74  {
75  $root = $this->getRoot();
76  $set = $this->getBaseSet($root);
77 
78  $cloned_set = clone $set;
79  $this->assertEquals($root, $cloned_set->getRoot());
80  $this->assertNotSame($root, $cloned_set->getRoot());
81  }
82 }
getBaseSet(BaseElementInterface $root)
Definition: BaseSetTest.php:30
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
__construct(Container $dic, ilPlugin $plugin)