ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StakeholderRepositoryTests.php
Go to the documentation of this file.
1<?php
2
20
21require_once(__DIR__ . "/../AbstractTestBase.php");
22
27
33{
34 public function __construct()
35 {
36 parent::__construct(static::class);
37 }
40
41 #[\Override]
42 protected function setUp(): void
43 {
44 parent::setUp();
45 $this->stakeholder_repository = new StakeholderDBRepository($this->db_mock);
46 $this->identification = new ResourceIdentification('test_identification');
47 }
48
49 public function testIdTooLong(): void
50 {
51 $this->expectException(\InvalidArgumentException::class);
52 $this->expectExceptionMessage('stakeholder ids MUST be shorter or equal to than 64 characters');
53 $stakeholder = $this->getResourceStakeholder(
54 str_repeat('A', 65)
55 );
56 $this->stakeholder_repository->register($this->identification, $stakeholder);
57 }
58
59 public function testNameTooLong(): void
60 {
61 $this->expectException(\InvalidArgumentException::class);
62 $this->expectExceptionMessage('stakeholder classnames MUST be shorter or equal to than 250 characters');
63 $stakeholder = $this->getResourceStakeholder(
64 str_repeat('A', 64),
65 str_repeat('B', 251)
66 );
67 $this->stakeholder_repository->register($this->identification, $stakeholder);
68 }
69
70 protected function getResourceStakeholder(
71 ?string $stakeholder_id = null,
72 ?string $stakeholder_classname = null
74 return new class ($stakeholder_id, $stakeholder_classname) implements ResourceStakeholder {
78 protected string $stakeholder_id = 'the_ludicrous_long_identification_string_of_a_resource_stakeholder';
82 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';
83
84 public function __construct(?string $stakeholder_id = null, ?string $stakeholder_classname = null)
85 {
86 $this->stakeholder_id = $stakeholder_id ?? $this->stakeholder_id;
87 $this->stakeholder_classname = $stakeholder_classname ?? $this->stakeholder_classname;
88 }
89
90 public function getId(): string
91 {
92 return $this->stakeholder_id;
93 }
94
95 public function getConsumerNameForPresentation(): string
96 {
97 return 'VeryLong';
98 }
99
100 public function getFullyQualifiedClassName(): string
101 {
102 return $this->stakeholder_classname;
103 }
104
105 public function isResourceInUse(ResourceIdentification $identification): bool
106 {
107 return true;
108 }
109
110 public function resourceHasBeenDeleted(ResourceIdentification $identification): bool
111 {
112 return false;
113 }
114
115 public function getOwnerOfResource(ResourceIdentification $identification): int
116 {
117 return 0;
118 }
119
120 public function getOwnerOfNewResources(): int
121 {
122 return 0;
123 }
124 };
125 }
126}
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...