ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
UploadPolicyResolverTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
26class UploadPolicyResolverTest extends TestCase
27{
28 public function testLimitedPolicy(): void
29 {
30 $rbac_mock = $this->createMock(\ilRbacReview::class);
31 $user_mock = $this->createMock(\ilObjUser::class);
32
33 $general_policy = new \UploadPolicy(
34 1,
35 'General',
36 10,
37 [],
40 true,
41 null,
42 null,
43 6,
44 new \DateTimeImmutable(),
45 new \DateTimeImmutable()
46 );
47
48 $specifiy_policy = new \UploadPolicy(
49 1,
50 'Specific',
51 1000,
52 [],
55 true,
56 new \DateTimeImmutable('today midnight'),
57 new \DateTimeImmutable('tomorrow midnight'),
58 6,
59 new \DateTimeImmutable(),
60 new \DateTimeImmutable()
61 );
62
63 $resolver = new \UploadPolicyResolver(
64 $rbac_mock,
65 $user_mock,
66 [$general_policy, $specifiy_policy]
67 );
68
69 $this->assertSame(1000, $resolver->getUserUploadSizeLimitInBytes() / 1000 / 1000);
70
71 $specifiy_policy_expired = new \UploadPolicy(
72 1,
73 'Specific Expired',
74 1000,
75 [],
78 true,
79 null,
80 new \DateTimeImmutable('yesterday midnight'),
81 6,
82 new \DateTimeImmutable(),
83 new \DateTimeImmutable()
84 );
85
86 $resolver = new \UploadPolicyResolver(
87 $rbac_mock,
88 $user_mock,
89 [$general_policy, $specifiy_policy_expired]
90 );
91
92 $this->assertSame(10, $resolver->getUserUploadSizeLimitInBytes() / 1000 / 1000);
93 }
94}
foreach($components as $component) $resolver
const SCOPE_DEFINITION_GLOBAL
const AUDIENCE_TYPE_ALL_USERS