ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BaseSetTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestCase;
27
28class BaseSetTest extends TestCase
29{
30 protected function getBaseSet(
32 ): BaseSet {
33 return new class ($root) extends BaseSet {
34 public function __construct(
36 ) {
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 @access public.
Definition: class.ilias.php:76
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc