|
| testCapabilityPriority (bool $wopi_view, bool $wopi_edit, bool $infopage_first, array $user_permissions, Capabilities $expected_best) |
|
Definition at line 32 of file CapabilityTest.php.
◆ arrayToMarkdownTable()
static CapabilityTest::arrayToMarkdownTable |
( |
array |
$data | ) |
|
|
staticprivate |
Definition at line 315 of file CapabilityTest.php.
324 static fn($col_index):
int => max(
326 static fn($row):
int => isset($row[$col_index]) ? mb_strlen((
string) $row[$col_index]) : 0,
334 $pad_row =
static fn($row): array =>
array_map(static
function ($value, $index) use ($col_widths): string {
336 return str_pad($value, $col_widths[$index],
" ", STR_PAD_RIGHT);
337 }, $row, array_keys($col_widths));
340 $header = $pad_row(
$data[0]);
345 . implode(
" | ", $header)
348 . implode(
" | ",
array_map(
static fn($width):
string => str_repeat(
"-", $width), $col_widths))
350 $data_rows =
array_map(
static fn($row):
string =>
"| " . implode(
" | ", $row) .
" |", $rows);
353 return implode(
"\n", array_merge([$header_row, $sep_row], $data_rows));
◆ environmentProvider()
static CapabilityTest::environmentProvider |
( |
| ) |
|
|
static |
Definition at line 91 of file CapabilityTest.php.
100 Permissions::VISIBLE,
101 Permissions::EDIT_CONTENT,
102 Permissions::VIEW_CONTENT
104 Capabilities::FORCED_INFO_PAGE
113 Permissions::VISIBLE,
114 Permissions::EDIT_CONTENT,
115 Permissions::VIEW_CONTENT
117 Capabilities::VIEW_EXTERNAL
124 Permissions::EDIT_CONTENT,
125 Permissions::VIEW_CONTENT
127 Capabilities::VIEW_EXTERNAL
137 Capabilities::FORCED_INFO_PAGE
144 Permissions::EDIT_CONTENT,
146 Capabilities::EDIT_EXTERNAL
155 Capabilities::DOWNLOAD
165 Capabilities::DOWNLOAD
174 Capabilities::MANAGE_VERSIONS
181 Permissions::VISIBLE,
183 Capabilities::INFO_PAGE
193 Capabilities::FORCED_INFO_PAGE
204 yield
'docu_case' => [
210 Permissions::VISIBLE,
212 Capabilities::FORCED_INFO_PAGE
◆ setUp()
CapabilityTest::setUp |
( |
| ) |
|
|
protected |
Definition at line 48 of file CapabilityTest.php.
References $http, $static_url, and ILIAS\Repository\access().
50 if (!defined(
'ILIAS_HTTP_PATH')) {
51 define(
'ILIAS_HTTP_PATH',
'https://ilias.unit.test');
54 $this->file_info_repository = $this->createMock(\ilObjFileInfoRepository::class);
55 $this->
access = $this->createMock(\ilAccessHandler::class);
56 $ctrl = $this->createMock(\ilCtrlInterface::class);
57 $this->action_repository = $this->createMock(ActionRepository::class);
58 $http = $this->createMock(Services::class);
60 $this->type_resolver = $this->createMock(TypeResolver::class);
61 $this->workspace_access_handler = $this->createMock(ilWorkspaceAccessHandler::class);
63 $this->type_resolver->method(
'resolveTypeByObjectId')
68 $this->file_info_repository,
71 $this->action_repository,
75 $this->workspace_access_handler
◆ tearDown()
CapabilityTest::tearDown |
( |
| ) |
|
|
protected |
◆ tearDownAfterClass()
static CapabilityTest::tearDownAfterClass |
( |
| ) |
|
|
static |
◆ testCapabilityPriority()
CapabilityTest::testCapabilityPriority |
( |
bool |
$wopi_view, |
|
|
bool |
$wopi_edit, |
|
|
bool |
$infopage_first, |
|
|
array |
$user_permissions, |
|
|
Capabilities |
$expected_best |
|
) |
| |
Definition at line 217 of file CapabilityTest.php.
References $context, $id, and ILIAS\Repository\access().
225 $permissions = $user_permissions;
232 Context::CONTEXT_REPO
235 $this->
access->method(
'checkAccess')
236 ->willReturnCallback(
237 function (
string $permission) use ($permissions):
bool {
238 $checked_permissions = explode(
',', $permission);
239 $common_permissions = array_intersect(
243 return $common_permissions !== [];
247 $file_info = $this->createMock(\ilObjFileInfo::class);
248 $file_info->method(
'shouldDownloadDirectly')
249 ->willReturn(!$infopage_first);
251 $this->file_info_repository->method(
'getByObjectId')
253 ->willReturn($file_info);
255 $this->action_repository->method(
'hasEditActionForSuffix')
256 ->willReturn($wopi_edit);
258 $this->action_repository->method(
'hasViewActionForSuffix')
259 ->willReturn($wopi_view);
261 $capabilities = $this->capability_builder->get(
$context);
262 $best = $capabilities->getBest();
264 $this->assertEquals($expected_best, $best->getCapability());
266 self::$readme_infos[] = [
268 ($wopi_view ?
'Yes' :
'No'),
269 ($wopi_edit ?
'Yes' :
'No'),
270 ($infopage_first ?
'Info-Page' :
'Open'),
271 $best->getCapability()->name
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
◆ updateREADME()
static CapabilityTest::updateREADME |
( |
| ) |
|
|
staticprivate |
Definition at line 275 of file CapabilityTest.php.
References Vendor\Package\$a, and Vendor\Package\$b.
278 $readme_file = __DIR__ .
'/../../docs/README.md';
279 $readme_content = file_get_contents($readme_file);
283 'User\'s Permissions',
284 'WOPI View Action av.',
285 'WOPI Edit Action av.',
287 'Expected Capability' 293 $a_string = implode(
'', array_reverse(
$a));
294 $b_string = implode(
'', array_reverse(
$b));
296 return strcmp((
string) $a_string, (
string) $b_string);
302 $start_marker =
"<!-- START CAPABILITY_TABLE -->";
303 $end_marker =
"<!-- END CAPABILITY_TABLE -->";
306 $new_block = $start_marker .
"\n\n" . self::arrayToMarkdownTable($table) .
"\n\n" . $end_marker;
309 $pattern =
'/' . preg_quote($start_marker,
'/') .
'.*?' . preg_quote($end_marker,
'/') .
'/s';
310 $readme_content = preg_replace($pattern, $new_block, $readme_content);
312 file_put_contents($readme_file, $readme_content);
static array $readme_infos
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
◆ $access
◆ $action_repository
◆ $capability_builder
◆ $file_info_repository
◆ $readme_infos
array CapabilityTest::$readme_infos = [] |
|
staticprivate |
◆ $type_resolver
PHPUnit Framework MockObject MockObject TypeResolver CapabilityTest::$type_resolver |
◆ $update_readme
bool CapabilityTest::$update_readme = false |
|
staticprivate |
◆ $workspace_access_handler
PHPUnit Framework MockObject MockObject CapabilityTest::$workspace_access_handler |
The documentation for this class was generated from the following file: