ILIAS  release_7 Revision v7.30-3-g800a261c036
StakeholderRepositoryTests.php
Go to the documentation of this file.
1<?php
2
4
9
15{
16
24 protected $identification;
25
26 protected function setUp() : void
27 {
28 parent::setUp();
29 $this->stakeholder_repository = new StakeholderDBRepository($this->db_mock);
30 $this->identification = new ResourceIdentification('test_identification');
31 }
32
33 public function testIdTooLong()
34 {
35 $this->expectException(\InvalidArgumentException::class);
36 $this->expectExceptionMessage('stakeholder ids MUST be shorter or equal to than 64 characters');
37 $stakeholder = $this->getResourceStakeholder(
38 str_repeat('A', 65)
39 );
40 $this->stakeholder_repository->register($this->identification, $stakeholder);
41 }
42
43 public function testNameTooLong()
44 {
45 $this->expectException(\InvalidArgumentException::class);
46 $this->expectExceptionMessage('stakeholder classnames MUST be shorter or equal to than 250 characters');
47 $stakeholder = $this->getResourceStakeholder(
48 str_repeat('A', 64),
49 str_repeat('B', 251)
50 );
51 $this->stakeholder_repository->register($this->identification, $stakeholder);
52 }
53
57 protected function getResourceStakeholder(?string $stakeholder_id = null, ?string $stakeholder_classname = null)
58 {
59 return new class($stakeholder_id, $stakeholder_classname) implements ResourceStakeholder {
60
61 protected $stakeholder_id = 'the_ludicrous_long_identification_string_of_a_resource_stakeholder';
62 protected $stakeholder_classname = 'This\Is\A\Very\Long\Class\Name\Which\Can\Not\Be\Handled\As\A\Propper\Stakeholder\In\The\ILIAS\Resource\Storage\Service';
63
64 public function __construct(?string $stakeholder_id = null, ?string $stakeholder_classname = null)
65 {
66 $this->stakeholder_id = $stakeholder_id ?? $this->stakeholder_id;
67 $this->stakeholder_classname = $stakeholder_classname ?? $this->stakeholder_classname;
68 }
69
70 public function getId() : string
71 {
72 return $this->stakeholder_id;
73 }
74
75 public function getConsumerNameForPresentation() : string
76 {
77 return 'VeryLong';
78 }
79
80 public function getFullyQualifiedClassName() : string
81 {
82 return $this->stakeholder_classname;
83 }
84
85 public function isResourceInUse(ResourceIdentification $identification) : bool
86 {
87 return true;
88 }
89
90 public function resourceHasBeenDeleted(ResourceIdentification $identification) : bool
91 {
92 return false;
93 }
94
95 public function getOwnerOfResource(ResourceIdentification $identification) : int
96 {
97 return 0;
98 }
99
100 public function getOwnerOfNewResources() : int
101 {
102 return 0;
103 }
104
105 };
106 }
107}
108
An exception for terminatinating execution or to throw for unit testing.
getResourceStakeholder(?string $stakeholder_id=null, ?string $stakeholder_classname=null)
__construct($a_client_id=0)
Constructor setup ILIAS global object @access public.