ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
StakeholderRepositoryTests.php
Go to the documentation of this file.
1 <?php
2 
20 
21 require_once(__DIR__ . "/../AbstractTestBase.php");
22 
27 
33 {
36 
37  #[\Override]
38  protected function setUp(): void
39  {
40  parent::setUp();
41  $this->stakeholder_repository = new StakeholderDBRepository($this->db_mock);
42  $this->identification = new ResourceIdentification('test_identification');
43  }
44 
45  public function testIdTooLong(): void
46  {
47  $this->expectException(\InvalidArgumentException::class);
48  $this->expectExceptionMessage('stakeholder ids MUST be shorter or equal to than 64 characters');
49  $stakeholder = $this->getResourceStakeholder(
50  str_repeat('A', 65)
51  );
52  $this->stakeholder_repository->register($this->identification, $stakeholder);
53  }
54 
55  public function testNameTooLong(): void
56  {
57  $this->expectException(\InvalidArgumentException::class);
58  $this->expectExceptionMessage('stakeholder classnames MUST be shorter or equal to than 250 characters');
59  $stakeholder = $this->getResourceStakeholder(
60  str_repeat('A', 64),
61  str_repeat('B', 251)
62  );
63  $this->stakeholder_repository->register($this->identification, $stakeholder);
64  }
65 
66  protected function getResourceStakeholder(
67  ?string $stakeholder_id = null,
68  ?string $stakeholder_classname = null
70  return new class ($stakeholder_id, $stakeholder_classname) implements ResourceStakeholder {
74  protected string $stakeholder_id = 'the_ludicrous_long_identification_string_of_a_resource_stakeholder';
78  protected string $stakeholder_classname = 'This\Is\A\Very\Long\Class\Name\Which\Can\Not\Be\Handled\As\A\Propper\Stakeholder\In\The\ILIAS\Resource\Storage\Service';
79 
80  public function __construct(?string $stakeholder_id = null, ?string $stakeholder_classname = null)
81  {
82  $this->stakeholder_id = $stakeholder_id ?? $this->stakeholder_id;
83  $this->stakeholder_classname = $stakeholder_classname ?? $this->stakeholder_classname;
84  }
85 
86  public function getId(): string
87  {
88  return $this->stakeholder_id;
89  }
90 
91  public function getConsumerNameForPresentation(): string
92  {
93  return 'VeryLong';
94  }
95 
96  public function getFullyQualifiedClassName(): string
97  {
98  return $this->stakeholder_classname;
99  }
100 
101  public function isResourceInUse(ResourceIdentification $identification): bool
102  {
103  return true;
104  }
105 
106  public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
107  {
108  return false;
109  }
110 
111  public function getOwnerOfResource(ResourceIdentification $identification): int
112  {
113  return 0;
114  }
115 
116  public function getOwnerOfNewResources(): int
117  {
118  return 0;
119  }
120  };
121  }
122 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...