ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
StakeholderRepositoryTests.php
Go to the documentation of this file.
1 <?php
2 
20 
21 require_once(__DIR__ . "/../AbstractTestBase.php");
22 
27 
33 {
34  protected \ILIAS\ResourceStorage\Stakeholder\Repository\StakeholderDBRepository $stakeholder_repository;
35  protected \ILIAS\ResourceStorage\Identification\ResourceIdentification $identification;
36 
37  protected function setUp(): void
38  {
39  parent::setUp();
40  $this->stakeholder_repository = new StakeholderDBRepository($this->db_mock);
41  $this->identification = new ResourceIdentification('test_identification');
42  }
43 
44  public function testIdTooLong(): void
45  {
46  $this->expectException(\InvalidArgumentException::class);
47  $this->expectExceptionMessage('stakeholder ids MUST be shorter or equal to than 64 characters');
48  $stakeholder = $this->getResourceStakeholder(
49  str_repeat('A', 65)
50  );
51  $this->stakeholder_repository->register($this->identification, $stakeholder);
52  }
53 
54  public function testNameTooLong(): void
55  {
56  $this->expectException(\InvalidArgumentException::class);
57  $this->expectExceptionMessage('stakeholder classnames MUST be shorter or equal to than 250 characters');
58  $stakeholder = $this->getResourceStakeholder(
59  str_repeat('A', 64),
60  str_repeat('B', 251)
61  );
62  $this->stakeholder_repository->register($this->identification, $stakeholder);
63  }
64 
65  protected function getResourceStakeholder(
66  ?string $stakeholder_id = null,
67  ?string $stakeholder_classname = null
69  return new class ($stakeholder_id, $stakeholder_classname) implements ResourceStakeholder {
73  protected string $stakeholder_id = 'the_ludicrous_long_identification_string_of_a_resource_stakeholder';
77  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';
78 
79  public function __construct(?string $stakeholder_id = null, ?string $stakeholder_classname = null)
80  {
81  $this->stakeholder_id = $stakeholder_id ?? $this->stakeholder_id;
82  $this->stakeholder_classname = $stakeholder_classname ?? $this->stakeholder_classname;
83  }
84 
85  public function getId(): string
86  {
87  return $this->stakeholder_id;
88  }
89 
90  public function getConsumerNameForPresentation(): string
91  {
92  return 'VeryLong';
93  }
94 
95  public function getFullyQualifiedClassName(): string
96  {
97  return $this->stakeholder_classname;
98  }
99 
100  public function isResourceInUse(ResourceIdentification $identification): bool
101  {
102  return true;
103  }
104 
105  public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
106  {
107  return false;
108  }
109 
110  public function getOwnerOfResource(ResourceIdentification $identification): int
111  {
112  return 0;
113  }
114 
115  public function getOwnerOfNewResources(): int
116  {
117  return 0;
118  }
119  };
120  }
121 }
ILIAS ResourceStorage Stakeholder Repository StakeholderDBRepository $stakeholder_repository
__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...
ILIAS ResourceStorage Identification ResourceIdentification $identification