@@ -4,20 +4,20 @@ |
||
4 | 4 | * SPDX-License-Identifier: AGPL-3.0-or-later |
5 | 5 | */ |
6 | 6 | $CONFIG = [ |
7 | - 'memcache.local' => '\\OC\\Memcache\\Redis', |
|
8 | - 'memcache.distributed' => '\\OC\\Memcache\\Redis', |
|
9 | - 'memcache.locking' => '\\OC\\Memcache\\Redis', |
|
10 | - 'redis.cluster' => [ |
|
11 | - 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required |
|
12 | - 'cache-cluster:7000', |
|
13 | - 'cache-cluster:7001', |
|
14 | - 'cache-cluster:7002', |
|
15 | - 'cache-cluster:7003', |
|
16 | - 'cache-cluster:7004', |
|
17 | - 'cache-cluster:7005' |
|
18 | - ], |
|
19 | - 'timeout' => 0.0, |
|
20 | - 'read_timeout' => 0.0, |
|
21 | - 'failover_mode' => \RedisCluster::FAILOVER_ERROR |
|
22 | - ], |
|
7 | + 'memcache.local' => '\\OC\\Memcache\\Redis', |
|
8 | + 'memcache.distributed' => '\\OC\\Memcache\\Redis', |
|
9 | + 'memcache.locking' => '\\OC\\Memcache\\Redis', |
|
10 | + 'redis.cluster' => [ |
|
11 | + 'seeds' => [ // provide some/all of the cluster servers to bootstrap discovery, port required |
|
12 | + 'cache-cluster:7000', |
|
13 | + 'cache-cluster:7001', |
|
14 | + 'cache-cluster:7002', |
|
15 | + 'cache-cluster:7003', |
|
16 | + 'cache-cluster:7004', |
|
17 | + 'cache-cluster:7005' |
|
18 | + ], |
|
19 | + 'timeout' => 0.0, |
|
20 | + 'read_timeout' => 0.0, |
|
21 | + 'failover_mode' => \RedisCluster::FAILOVER_ERROR |
|
22 | + ], |
|
23 | 23 | ]; |
@@ -5,112 +5,112 @@ |
||
5 | 5 | * SPDX-License-Identifier: AGPL-3.0-only |
6 | 6 | */ |
7 | 7 | $CONFIG = [ |
8 | - 'appstoreenabled' => false, |
|
9 | - 'apps_paths' => [ |
|
10 | - [ |
|
11 | - 'path' => OC::$SERVERROOT . '/apps', |
|
12 | - 'url' => '/apps', |
|
13 | - 'writable' => true, |
|
14 | - ], |
|
15 | - ], |
|
8 | + 'appstoreenabled' => false, |
|
9 | + 'apps_paths' => [ |
|
10 | + [ |
|
11 | + 'path' => OC::$SERVERROOT . '/apps', |
|
12 | + 'url' => '/apps', |
|
13 | + 'writable' => true, |
|
14 | + ], |
|
15 | + ], |
|
16 | 16 | ]; |
17 | 17 | |
18 | 18 | if (is_dir(OC::$SERVERROOT . '/apps2')) { |
19 | - $CONFIG['apps_paths'][] = [ |
|
20 | - 'path' => OC::$SERVERROOT . '/apps2', |
|
21 | - 'url' => '/apps2', |
|
22 | - 'writable' => false, |
|
23 | - ]; |
|
19 | + $CONFIG['apps_paths'][] = [ |
|
20 | + 'path' => OC::$SERVERROOT . '/apps2', |
|
21 | + 'url' => '/apps2', |
|
22 | + 'writable' => false, |
|
23 | + ]; |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | if (getenv('OBJECT_STORE') === 's3') { |
27 | - $CONFIG['objectstore'] = [ |
|
28 | - 'class' => 'OC\\Files\\ObjectStore\\S3', |
|
29 | - 'arguments' => [ |
|
30 | - 'bucket' => 'nextcloud', |
|
31 | - 'autocreate' => true, |
|
32 | - 'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud', |
|
33 | - 'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud', |
|
34 | - 'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost', |
|
35 | - 'port' => 9000, |
|
36 | - 'use_ssl' => false, |
|
37 | - // required for some non amazon s3 implementations |
|
38 | - 'use_path_style' => true |
|
39 | - ] |
|
40 | - ]; |
|
27 | + $CONFIG['objectstore'] = [ |
|
28 | + 'class' => 'OC\\Files\\ObjectStore\\S3', |
|
29 | + 'arguments' => [ |
|
30 | + 'bucket' => 'nextcloud', |
|
31 | + 'autocreate' => true, |
|
32 | + 'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud', |
|
33 | + 'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud', |
|
34 | + 'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost', |
|
35 | + 'port' => 9000, |
|
36 | + 'use_ssl' => false, |
|
37 | + // required for some non amazon s3 implementations |
|
38 | + 'use_path_style' => true |
|
39 | + ] |
|
40 | + ]; |
|
41 | 41 | } elseif (getenv('OBJECT_STORE') === 's3-multibucket') { |
42 | - $CONFIG['objectstore_multibucket'] = [ |
|
43 | - 'class' => 'OC\\Files\\ObjectStore\\S3', |
|
44 | - 'arguments' => [ |
|
45 | - 'bucket' => 'nextcloud', |
|
46 | - 'autocreate' => true, |
|
47 | - 'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud', |
|
48 | - 'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud', |
|
49 | - 'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost', |
|
50 | - 'port' => 9000, |
|
51 | - 'use_ssl' => false, |
|
52 | - // required for some non amazon s3 implementations |
|
53 | - 'use_path_style' => true |
|
54 | - ] |
|
55 | - ]; |
|
42 | + $CONFIG['objectstore_multibucket'] = [ |
|
43 | + 'class' => 'OC\\Files\\ObjectStore\\S3', |
|
44 | + 'arguments' => [ |
|
45 | + 'bucket' => 'nextcloud', |
|
46 | + 'autocreate' => true, |
|
47 | + 'key' => getenv('OBJECT_STORE_KEY') ?: 'nextcloud', |
|
48 | + 'secret' => getenv('OBJECT_STORE_SECRET') ?: 'nextcloud', |
|
49 | + 'hostname' => getenv('OBJECT_STORE_HOST') ?: 'localhost', |
|
50 | + 'port' => 9000, |
|
51 | + 'use_ssl' => false, |
|
52 | + // required for some non amazon s3 implementations |
|
53 | + 'use_path_style' => true |
|
54 | + ] |
|
55 | + ]; |
|
56 | 56 | } elseif (getenv('OBJECT_STORE') === 'azure') { |
57 | - $CONFIG['objectstore'] = [ |
|
58 | - 'class' => 'OC\\Files\\ObjectStore\\Azure', |
|
59 | - 'arguments' => [ |
|
60 | - 'container' => 'test', |
|
61 | - 'account_name' => getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1', |
|
62 | - 'account_key' => getenv('OBJECT_STORE_SECRET') ?: 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==', |
|
63 | - 'endpoint' => 'http://' . (getenv('OBJECT_STORE_HOST') ?: 'localhost') . ':10000/' . (getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1'), |
|
64 | - 'autocreate' => true |
|
65 | - ] |
|
66 | - ]; |
|
57 | + $CONFIG['objectstore'] = [ |
|
58 | + 'class' => 'OC\\Files\\ObjectStore\\Azure', |
|
59 | + 'arguments' => [ |
|
60 | + 'container' => 'test', |
|
61 | + 'account_name' => getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1', |
|
62 | + 'account_key' => getenv('OBJECT_STORE_SECRET') ?: 'Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==', |
|
63 | + 'endpoint' => 'http://' . (getenv('OBJECT_STORE_HOST') ?: 'localhost') . ':10000/' . (getenv('OBJECT_STORE_KEY') ?: 'devstoreaccount1'), |
|
64 | + 'autocreate' => true |
|
65 | + ] |
|
66 | + ]; |
|
67 | 67 | } elseif (getenv('OBJECT_STORE') === 'swift') { |
68 | - $swiftHost = getenv('OBJECT_STORE_HOST') ?: 'localhost:5000'; |
|
68 | + $swiftHost = getenv('OBJECT_STORE_HOST') ?: 'localhost:5000'; |
|
69 | 69 | |
70 | - $CONFIG['objectstore'] = [ |
|
71 | - 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
72 | - 'arguments' => [ |
|
73 | - 'autocreate' => true, |
|
74 | - 'user' => [ |
|
75 | - 'name' => getenv('OBJECT_STORE_KEY') ?: 'swift', |
|
76 | - 'password' => getenv('OBJECT_STORE_SECRET') ?: 'swift', |
|
77 | - 'domain' => [ |
|
78 | - 'name' => 'Default', |
|
79 | - ], |
|
80 | - ], |
|
81 | - 'scope' => [ |
|
82 | - 'project' => [ |
|
83 | - 'name' => 'service', |
|
84 | - 'domain' => [ |
|
85 | - 'name' => 'Default', |
|
86 | - ], |
|
87 | - ], |
|
88 | - ], |
|
89 | - 'serviceName' => 'service', |
|
90 | - 'region' => 'RegionOne', |
|
91 | - 'url' => "http://$swiftHost/v3", |
|
92 | - 'bucket' => 'nextcloud', |
|
93 | - ] |
|
94 | - ]; |
|
70 | + $CONFIG['objectstore'] = [ |
|
71 | + 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
72 | + 'arguments' => [ |
|
73 | + 'autocreate' => true, |
|
74 | + 'user' => [ |
|
75 | + 'name' => getenv('OBJECT_STORE_KEY') ?: 'swift', |
|
76 | + 'password' => getenv('OBJECT_STORE_SECRET') ?: 'swift', |
|
77 | + 'domain' => [ |
|
78 | + 'name' => 'Default', |
|
79 | + ], |
|
80 | + ], |
|
81 | + 'scope' => [ |
|
82 | + 'project' => [ |
|
83 | + 'name' => 'service', |
|
84 | + 'domain' => [ |
|
85 | + 'name' => 'Default', |
|
86 | + ], |
|
87 | + ], |
|
88 | + ], |
|
89 | + 'serviceName' => 'service', |
|
90 | + 'region' => 'RegionOne', |
|
91 | + 'url' => "http://$swiftHost/v3", |
|
92 | + 'bucket' => 'nextcloud', |
|
93 | + ] |
|
94 | + ]; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | if (getenv('SHARDING') == '1') { |
98 | - $CONFIG['dbsharding'] = [ |
|
99 | - 'filecache' => [ |
|
100 | - 'shards' => [ |
|
101 | - [ |
|
102 | - 'port' => 5001, |
|
103 | - ], |
|
104 | - [ |
|
105 | - 'port' => 5002, |
|
106 | - ], |
|
107 | - [ |
|
108 | - 'port' => 5003, |
|
109 | - ], |
|
110 | - [ |
|
111 | - 'port' => 5004, |
|
112 | - ], |
|
113 | - ] |
|
114 | - ] |
|
115 | - ]; |
|
98 | + $CONFIG['dbsharding'] = [ |
|
99 | + 'filecache' => [ |
|
100 | + 'shards' => [ |
|
101 | + [ |
|
102 | + 'port' => 5001, |
|
103 | + ], |
|
104 | + [ |
|
105 | + 'port' => 5002, |
|
106 | + ], |
|
107 | + [ |
|
108 | + 'port' => 5003, |
|
109 | + ], |
|
110 | + [ |
|
111 | + 'port' => 5004, |
|
112 | + ], |
|
113 | + ] |
|
114 | + ] |
|
115 | + ]; |
|
116 | 116 | } |
@@ -17,176 +17,176 @@ |
||
17 | 17 | use Test\TestCase; |
18 | 18 | |
19 | 19 | class AccountPropertyCollectionTest extends TestCase { |
20 | - /** @var IAccountPropertyCollection */ |
|
21 | - protected $collection; |
|
22 | - |
|
23 | - protected const COLLECTION_NAME = 'my_multivalue_property'; |
|
24 | - |
|
25 | - public function setUp(): void { |
|
26 | - parent::setUp(); |
|
27 | - |
|
28 | - $this->collection = new AccountPropertyCollection(self::COLLECTION_NAME); |
|
29 | - } |
|
30 | - |
|
31 | - /** |
|
32 | - * @return IAccountProperty|MockObject |
|
33 | - */ |
|
34 | - protected function makePropertyMock(string $propertyName): MockObject { |
|
35 | - $mock = $this->createMock(IAccountProperty::class); |
|
36 | - $mock->expects($this->any()) |
|
37 | - ->method('getName') |
|
38 | - ->willReturn($propertyName); |
|
39 | - |
|
40 | - return $mock; |
|
41 | - } |
|
42 | - |
|
43 | - public function testSetAndGetProperties(): void { |
|
44 | - $propsBefore = $this->collection->getProperties(); |
|
45 | - $this->assertIsArray($propsBefore); |
|
46 | - $this->assertEmpty($propsBefore); |
|
47 | - |
|
48 | - $props = [ |
|
49 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
50 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
51 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
52 | - ]; |
|
53 | - |
|
54 | - $this->collection->setProperties($props); |
|
55 | - $propsAfter = $this->collection->getProperties(); |
|
56 | - $this->assertIsArray($propsAfter); |
|
57 | - $this->assertCount(count($props), $propsAfter); |
|
58 | - } |
|
59 | - |
|
60 | - public function testSetPropertiesMixedInvalid(): void { |
|
61 | - $props = [ |
|
62 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
63 | - $this->makePropertyMock('sneaky_property'), |
|
64 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
65 | - ]; |
|
66 | - |
|
67 | - $this->expectException(InvalidArgumentException::class); |
|
68 | - $this->collection->setProperties($props); |
|
69 | - } |
|
70 | - |
|
71 | - public function testAddProperty(): void { |
|
72 | - $props = [ |
|
73 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
74 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
75 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
76 | - ]; |
|
77 | - $this->collection->setProperties($props); |
|
78 | - |
|
79 | - $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
80 | - $this->collection->addProperty($additionalProperty); |
|
81 | - |
|
82 | - $propsAfter = $this->collection->getProperties(); |
|
83 | - $this->assertCount(count($props) + 1, $propsAfter); |
|
84 | - $this->assertNotFalse(array_search($additionalProperty, $propsAfter, true)); |
|
85 | - } |
|
86 | - |
|
87 | - public function testAddPropertyInvalid(): void { |
|
88 | - $props = [ |
|
89 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
90 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
91 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
92 | - ]; |
|
93 | - $this->collection->setProperties($props); |
|
94 | - |
|
95 | - $additionalProperty = $this->makePropertyMock('sneaky_property'); |
|
96 | - $exceptionThrown = false; |
|
97 | - try { |
|
98 | - $this->collection->addProperty($additionalProperty); |
|
99 | - } catch (\InvalidArgumentException $e) { |
|
100 | - $exceptionThrown = true; |
|
101 | - } finally { |
|
102 | - $propsAfter = $this->collection->getProperties(); |
|
103 | - $this->assertCount(count($props), $propsAfter); |
|
104 | - $this->assertFalse(array_search($additionalProperty, $propsAfter, true)); |
|
105 | - $this->assertTrue($exceptionThrown); |
|
106 | - } |
|
107 | - } |
|
108 | - |
|
109 | - public function testRemoveProperty(): void { |
|
110 | - $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
111 | - $props = [ |
|
112 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
113 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
114 | - $additionalProperty, |
|
115 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
116 | - ]; |
|
117 | - $this->collection->setProperties($props); |
|
118 | - |
|
119 | - $propsBefore = $this->collection->getProperties(); |
|
120 | - $this->collection->removeProperty($additionalProperty); |
|
121 | - $propsAfter = $this->collection->getProperties(); |
|
122 | - |
|
123 | - $this->assertTrue(count($propsBefore) > count($propsAfter)); |
|
124 | - $this->assertCount(count($propsBefore) - 1, $propsAfter); |
|
125 | - $this->assertFalse(array_search($additionalProperty, $propsAfter, true)); |
|
126 | - } |
|
127 | - |
|
128 | - public function testRemovePropertyNotFound(): void { |
|
129 | - $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
130 | - $props = [ |
|
131 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
132 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
133 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
134 | - ]; |
|
135 | - $this->collection->setProperties($props); |
|
136 | - |
|
137 | - $propsBefore = $this->collection->getProperties(); |
|
138 | - $this->collection->removeProperty($additionalProperty); |
|
139 | - $propsAfter = $this->collection->getProperties(); |
|
140 | - |
|
141 | - // no errors, gently |
|
142 | - $this->assertCount(count($propsBefore), $propsAfter); |
|
143 | - } |
|
144 | - |
|
145 | - public function testRemovePropertyByValue(): void { |
|
146 | - $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
147 | - $additionalProperty->expects($this->any()) |
|
148 | - ->method('getValue') |
|
149 | - ->willReturn('Lorem ipsum'); |
|
150 | - |
|
151 | - $additionalPropertyTwo = clone $additionalProperty; |
|
152 | - |
|
153 | - $props = [ |
|
154 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
155 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
156 | - $additionalProperty, |
|
157 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
158 | - $additionalPropertyTwo |
|
159 | - ]; |
|
160 | - $this->collection->setProperties($props); |
|
161 | - |
|
162 | - $propsBefore = $this->collection->getProperties(); |
|
163 | - $this->collection->removePropertyByValue('Lorem ipsum'); |
|
164 | - $propsAfter = $this->collection->getProperties(); |
|
165 | - |
|
166 | - $this->assertTrue(count($propsBefore) > count($propsAfter)); |
|
167 | - $this->assertCount(count($propsBefore) - 2, $propsAfter); |
|
168 | - $this->assertFalse(array_search($additionalProperty, $propsAfter, true)); |
|
169 | - $this->assertFalse(array_search($additionalPropertyTwo, $propsAfter, true)); |
|
170 | - } |
|
171 | - |
|
172 | - public function testRemovePropertyByValueNotFound(): void { |
|
173 | - $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
174 | - $additionalProperty->expects($this->any()) |
|
175 | - ->method('getValue') |
|
176 | - ->willReturn('Lorem ipsum'); |
|
177 | - |
|
178 | - $props = [ |
|
179 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
180 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
181 | - $this->makePropertyMock(self::COLLECTION_NAME), |
|
182 | - ]; |
|
183 | - $this->collection->setProperties($props); |
|
184 | - |
|
185 | - $propsBefore = $this->collection->getProperties(); |
|
186 | - $this->collection->removePropertyByValue('Lorem ipsum'); |
|
187 | - $propsAfter = $this->collection->getProperties(); |
|
188 | - |
|
189 | - // no errors, gently |
|
190 | - $this->assertCount(count($propsBefore), $propsAfter); |
|
191 | - } |
|
20 | + /** @var IAccountPropertyCollection */ |
|
21 | + protected $collection; |
|
22 | + |
|
23 | + protected const COLLECTION_NAME = 'my_multivalue_property'; |
|
24 | + |
|
25 | + public function setUp(): void { |
|
26 | + parent::setUp(); |
|
27 | + |
|
28 | + $this->collection = new AccountPropertyCollection(self::COLLECTION_NAME); |
|
29 | + } |
|
30 | + |
|
31 | + /** |
|
32 | + * @return IAccountProperty|MockObject |
|
33 | + */ |
|
34 | + protected function makePropertyMock(string $propertyName): MockObject { |
|
35 | + $mock = $this->createMock(IAccountProperty::class); |
|
36 | + $mock->expects($this->any()) |
|
37 | + ->method('getName') |
|
38 | + ->willReturn($propertyName); |
|
39 | + |
|
40 | + return $mock; |
|
41 | + } |
|
42 | + |
|
43 | + public function testSetAndGetProperties(): void { |
|
44 | + $propsBefore = $this->collection->getProperties(); |
|
45 | + $this->assertIsArray($propsBefore); |
|
46 | + $this->assertEmpty($propsBefore); |
|
47 | + |
|
48 | + $props = [ |
|
49 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
50 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
51 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
52 | + ]; |
|
53 | + |
|
54 | + $this->collection->setProperties($props); |
|
55 | + $propsAfter = $this->collection->getProperties(); |
|
56 | + $this->assertIsArray($propsAfter); |
|
57 | + $this->assertCount(count($props), $propsAfter); |
|
58 | + } |
|
59 | + |
|
60 | + public function testSetPropertiesMixedInvalid(): void { |
|
61 | + $props = [ |
|
62 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
63 | + $this->makePropertyMock('sneaky_property'), |
|
64 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
65 | + ]; |
|
66 | + |
|
67 | + $this->expectException(InvalidArgumentException::class); |
|
68 | + $this->collection->setProperties($props); |
|
69 | + } |
|
70 | + |
|
71 | + public function testAddProperty(): void { |
|
72 | + $props = [ |
|
73 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
74 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
75 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
76 | + ]; |
|
77 | + $this->collection->setProperties($props); |
|
78 | + |
|
79 | + $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
80 | + $this->collection->addProperty($additionalProperty); |
|
81 | + |
|
82 | + $propsAfter = $this->collection->getProperties(); |
|
83 | + $this->assertCount(count($props) + 1, $propsAfter); |
|
84 | + $this->assertNotFalse(array_search($additionalProperty, $propsAfter, true)); |
|
85 | + } |
|
86 | + |
|
87 | + public function testAddPropertyInvalid(): void { |
|
88 | + $props = [ |
|
89 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
90 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
91 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
92 | + ]; |
|
93 | + $this->collection->setProperties($props); |
|
94 | + |
|
95 | + $additionalProperty = $this->makePropertyMock('sneaky_property'); |
|
96 | + $exceptionThrown = false; |
|
97 | + try { |
|
98 | + $this->collection->addProperty($additionalProperty); |
|
99 | + } catch (\InvalidArgumentException $e) { |
|
100 | + $exceptionThrown = true; |
|
101 | + } finally { |
|
102 | + $propsAfter = $this->collection->getProperties(); |
|
103 | + $this->assertCount(count($props), $propsAfter); |
|
104 | + $this->assertFalse(array_search($additionalProperty, $propsAfter, true)); |
|
105 | + $this->assertTrue($exceptionThrown); |
|
106 | + } |
|
107 | + } |
|
108 | + |
|
109 | + public function testRemoveProperty(): void { |
|
110 | + $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
111 | + $props = [ |
|
112 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
113 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
114 | + $additionalProperty, |
|
115 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
116 | + ]; |
|
117 | + $this->collection->setProperties($props); |
|
118 | + |
|
119 | + $propsBefore = $this->collection->getProperties(); |
|
120 | + $this->collection->removeProperty($additionalProperty); |
|
121 | + $propsAfter = $this->collection->getProperties(); |
|
122 | + |
|
123 | + $this->assertTrue(count($propsBefore) > count($propsAfter)); |
|
124 | + $this->assertCount(count($propsBefore) - 1, $propsAfter); |
|
125 | + $this->assertFalse(array_search($additionalProperty, $propsAfter, true)); |
|
126 | + } |
|
127 | + |
|
128 | + public function testRemovePropertyNotFound(): void { |
|
129 | + $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
130 | + $props = [ |
|
131 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
132 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
133 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
134 | + ]; |
|
135 | + $this->collection->setProperties($props); |
|
136 | + |
|
137 | + $propsBefore = $this->collection->getProperties(); |
|
138 | + $this->collection->removeProperty($additionalProperty); |
|
139 | + $propsAfter = $this->collection->getProperties(); |
|
140 | + |
|
141 | + // no errors, gently |
|
142 | + $this->assertCount(count($propsBefore), $propsAfter); |
|
143 | + } |
|
144 | + |
|
145 | + public function testRemovePropertyByValue(): void { |
|
146 | + $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
147 | + $additionalProperty->expects($this->any()) |
|
148 | + ->method('getValue') |
|
149 | + ->willReturn('Lorem ipsum'); |
|
150 | + |
|
151 | + $additionalPropertyTwo = clone $additionalProperty; |
|
152 | + |
|
153 | + $props = [ |
|
154 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
155 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
156 | + $additionalProperty, |
|
157 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
158 | + $additionalPropertyTwo |
|
159 | + ]; |
|
160 | + $this->collection->setProperties($props); |
|
161 | + |
|
162 | + $propsBefore = $this->collection->getProperties(); |
|
163 | + $this->collection->removePropertyByValue('Lorem ipsum'); |
|
164 | + $propsAfter = $this->collection->getProperties(); |
|
165 | + |
|
166 | + $this->assertTrue(count($propsBefore) > count($propsAfter)); |
|
167 | + $this->assertCount(count($propsBefore) - 2, $propsAfter); |
|
168 | + $this->assertFalse(array_search($additionalProperty, $propsAfter, true)); |
|
169 | + $this->assertFalse(array_search($additionalPropertyTwo, $propsAfter, true)); |
|
170 | + } |
|
171 | + |
|
172 | + public function testRemovePropertyByValueNotFound(): void { |
|
173 | + $additionalProperty = $this->makePropertyMock(self::COLLECTION_NAME); |
|
174 | + $additionalProperty->expects($this->any()) |
|
175 | + ->method('getValue') |
|
176 | + ->willReturn('Lorem ipsum'); |
|
177 | + |
|
178 | + $props = [ |
|
179 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
180 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
181 | + $this->makePropertyMock(self::COLLECTION_NAME), |
|
182 | + ]; |
|
183 | + $this->collection->setProperties($props); |
|
184 | + |
|
185 | + $propsBefore = $this->collection->getProperties(); |
|
186 | + $this->collection->removePropertyByValue('Lorem ipsum'); |
|
187 | + $propsAfter = $this->collection->getProperties(); |
|
188 | + |
|
189 | + // no errors, gently |
|
190 | + $this->assertCount(count($propsBefore), $propsAfter); |
|
191 | + } |
|
192 | 192 | } |
@@ -12,29 +12,29 @@ |
||
12 | 12 | use OCP\Notification\INotification; |
13 | 13 | |
14 | 14 | class DummyApp implements IApp { |
15 | - /** |
|
16 | - * @param INotification $notification |
|
17 | - * @throws \InvalidArgumentException When the notification is not valid |
|
18 | - * @since 9.0.0 |
|
19 | - */ |
|
20 | - public function notify(INotification $notification): void { |
|
21 | - // TODO: Implement notify() method. |
|
22 | - } |
|
15 | + /** |
|
16 | + * @param INotification $notification |
|
17 | + * @throws \InvalidArgumentException When the notification is not valid |
|
18 | + * @since 9.0.0 |
|
19 | + */ |
|
20 | + public function notify(INotification $notification): void { |
|
21 | + // TODO: Implement notify() method. |
|
22 | + } |
|
23 | 23 | |
24 | - /** |
|
25 | - * @param INotification $notification |
|
26 | - * @since 9.0.0 |
|
27 | - */ |
|
28 | - public function markProcessed(INotification $notification): void { |
|
29 | - // TODO: Implement markProcessed() method. |
|
30 | - } |
|
24 | + /** |
|
25 | + * @param INotification $notification |
|
26 | + * @since 9.0.0 |
|
27 | + */ |
|
28 | + public function markProcessed(INotification $notification): void { |
|
29 | + // TODO: Implement markProcessed() method. |
|
30 | + } |
|
31 | 31 | |
32 | - /** |
|
33 | - * @param INotification $notification |
|
34 | - * @return int |
|
35 | - * @since 9.0.0 |
|
36 | - */ |
|
37 | - public function getCount(INotification $notification): int { |
|
38 | - // TODO: Implement getCount() method. |
|
39 | - } |
|
32 | + /** |
|
33 | + * @param INotification $notification |
|
34 | + * @return int |
|
35 | + * @since 9.0.0 |
|
36 | + */ |
|
37 | + public function getCount(INotification $notification): int { |
|
38 | + // TODO: Implement getCount() method. |
|
39 | + } |
|
40 | 40 | } |
@@ -13,35 +13,35 @@ |
||
13 | 13 | use OCP\Notification\INotifier; |
14 | 14 | |
15 | 15 | class DummyNotifier implements INotifier { |
16 | - /** |
|
17 | - * Identifier of the notifier, only use [a-z0-9_] |
|
18 | - * |
|
19 | - * @return string |
|
20 | - * @since 17.0.0 |
|
21 | - */ |
|
22 | - public function getID(): string { |
|
23 | - // TODO: Implement getID() method. |
|
24 | - } |
|
16 | + /** |
|
17 | + * Identifier of the notifier, only use [a-z0-9_] |
|
18 | + * |
|
19 | + * @return string |
|
20 | + * @since 17.0.0 |
|
21 | + */ |
|
22 | + public function getID(): string { |
|
23 | + // TODO: Implement getID() method. |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Human readable name describing the notifier |
|
28 | - * |
|
29 | - * @return string |
|
30 | - * @since 17.0.0 |
|
31 | - */ |
|
32 | - public function getName(): string { |
|
33 | - // TODO: Implement getName() method. |
|
34 | - } |
|
26 | + /** |
|
27 | + * Human readable name describing the notifier |
|
28 | + * |
|
29 | + * @return string |
|
30 | + * @since 17.0.0 |
|
31 | + */ |
|
32 | + public function getName(): string { |
|
33 | + // TODO: Implement getName() method. |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param INotification $notification |
|
38 | - * @param string $languageCode The code of the language that should be used to prepare the notification |
|
39 | - * @return INotification |
|
40 | - * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
41 | - * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted |
|
42 | - * @since 9.0.0 |
|
43 | - */ |
|
44 | - public function prepare(INotification $notification, string $languageCode): INotification { |
|
45 | - // TODO: Implement prepare() method. |
|
46 | - } |
|
36 | + /** |
|
37 | + * @param INotification $notification |
|
38 | + * @param string $languageCode The code of the language that should be used to prepare the notification |
|
39 | + * @return INotification |
|
40 | + * @throws \InvalidArgumentException When the notification was not prepared by a notifier |
|
41 | + * @throws AlreadyProcessedException When the notification is not needed anymore and should be deleted |
|
42 | + * @since 9.0.0 |
|
43 | + */ |
|
44 | + public function prepare(INotification $notification, string $languageCode): INotification { |
|
45 | + // TODO: Implement prepare() method. |
|
46 | + } |
|
47 | 47 | } |
@@ -13,34 +13,34 @@ |
||
13 | 13 | use Test\TestCase; |
14 | 14 | |
15 | 15 | class LockdownManagerTest extends TestCase { |
16 | - private $sessionCallback; |
|
17 | - |
|
18 | - protected function setUp(): void { |
|
19 | - parent::setUp(); |
|
20 | - |
|
21 | - $this->sessionCallback = function () { |
|
22 | - return $this->createMock(ISession::class); |
|
23 | - }; |
|
24 | - } |
|
25 | - |
|
26 | - public function testCanAccessFilesystemDisabled(): void { |
|
27 | - $manager = new LockdownManager($this->sessionCallback); |
|
28 | - $this->assertTrue($manager->canAccessFilesystem()); |
|
29 | - } |
|
30 | - |
|
31 | - public function testCanAccessFilesystemAllowed(): void { |
|
32 | - $token = new PublicKeyToken(); |
|
33 | - $token->setScope([IToken::SCOPE_FILESYSTEM => true]); |
|
34 | - $manager = new LockdownManager($this->sessionCallback); |
|
35 | - $manager->setToken($token); |
|
36 | - $this->assertTrue($manager->canAccessFilesystem()); |
|
37 | - } |
|
38 | - |
|
39 | - public function testCanAccessFilesystemNotAllowed(): void { |
|
40 | - $token = new PublicKeyToken(); |
|
41 | - $token->setScope([IToken::SCOPE_FILESYSTEM => false]); |
|
42 | - $manager = new LockdownManager($this->sessionCallback); |
|
43 | - $manager->setToken($token); |
|
44 | - $this->assertFalse($manager->canAccessFilesystem()); |
|
45 | - } |
|
16 | + private $sessionCallback; |
|
17 | + |
|
18 | + protected function setUp(): void { |
|
19 | + parent::setUp(); |
|
20 | + |
|
21 | + $this->sessionCallback = function () { |
|
22 | + return $this->createMock(ISession::class); |
|
23 | + }; |
|
24 | + } |
|
25 | + |
|
26 | + public function testCanAccessFilesystemDisabled(): void { |
|
27 | + $manager = new LockdownManager($this->sessionCallback); |
|
28 | + $this->assertTrue($manager->canAccessFilesystem()); |
|
29 | + } |
|
30 | + |
|
31 | + public function testCanAccessFilesystemAllowed(): void { |
|
32 | + $token = new PublicKeyToken(); |
|
33 | + $token->setScope([IToken::SCOPE_FILESYSTEM => true]); |
|
34 | + $manager = new LockdownManager($this->sessionCallback); |
|
35 | + $manager->setToken($token); |
|
36 | + $this->assertTrue($manager->canAccessFilesystem()); |
|
37 | + } |
|
38 | + |
|
39 | + public function testCanAccessFilesystemNotAllowed(): void { |
|
40 | + $token = new PublicKeyToken(); |
|
41 | + $token->setScope([IToken::SCOPE_FILESYSTEM => false]); |
|
42 | + $manager = new LockdownManager($this->sessionCallback); |
|
43 | + $manager->setToken($token); |
|
44 | + $this->assertFalse($manager->canAccessFilesystem()); |
|
45 | + } |
|
46 | 46 | } |
@@ -15,214 +15,214 @@ |
||
15 | 15 | use Test\TestCase; |
16 | 16 | |
17 | 17 | class NullStorageTest extends TestCase { |
18 | - /** @var NullStorage */ |
|
19 | - private $storage; |
|
18 | + /** @var NullStorage */ |
|
19 | + private $storage; |
|
20 | 20 | |
21 | - protected function setUp(): void { |
|
22 | - parent::setUp(); |
|
21 | + protected function setUp(): void { |
|
22 | + parent::setUp(); |
|
23 | 23 | |
24 | - $this->storage = new NullStorage([]); |
|
25 | - } |
|
24 | + $this->storage = new NullStorage([]); |
|
25 | + } |
|
26 | 26 | |
27 | - public function testGetId(): void { |
|
28 | - $this->assertSame('null', $this->storage->getId()); |
|
29 | - } |
|
27 | + public function testGetId(): void { |
|
28 | + $this->assertSame('null', $this->storage->getId()); |
|
29 | + } |
|
30 | 30 | |
31 | - public function testMkdir(): void { |
|
32 | - $this->expectException(ForbiddenException::class); |
|
33 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
31 | + public function testMkdir(): void { |
|
32 | + $this->expectException(ForbiddenException::class); |
|
33 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
34 | 34 | |
35 | - $this->storage->mkdir('foo'); |
|
36 | - } |
|
35 | + $this->storage->mkdir('foo'); |
|
36 | + } |
|
37 | 37 | |
38 | - public function testRmdir(): void { |
|
39 | - $this->expectException(ForbiddenException::class); |
|
40 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
38 | + public function testRmdir(): void { |
|
39 | + $this->expectException(ForbiddenException::class); |
|
40 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
41 | 41 | |
42 | - $this->storage->rmdir('foo'); |
|
43 | - } |
|
42 | + $this->storage->rmdir('foo'); |
|
43 | + } |
|
44 | 44 | |
45 | - public function testOpendir(): void { |
|
46 | - $this->assertInstanceOf(IteratorDirectory::class, $this->storage->opendir('foo')); |
|
47 | - } |
|
45 | + public function testOpendir(): void { |
|
46 | + $this->assertInstanceOf(IteratorDirectory::class, $this->storage->opendir('foo')); |
|
47 | + } |
|
48 | 48 | |
49 | - public function testIs_dir(): void { |
|
50 | - $this->assertTrue($this->storage->is_dir('')); |
|
51 | - $this->assertFalse($this->storage->is_dir('foo')); |
|
52 | - } |
|
49 | + public function testIs_dir(): void { |
|
50 | + $this->assertTrue($this->storage->is_dir('')); |
|
51 | + $this->assertFalse($this->storage->is_dir('foo')); |
|
52 | + } |
|
53 | 53 | |
54 | - public function testIs_file(): void { |
|
55 | - $this->assertFalse($this->storage->is_file('foo')); |
|
56 | - } |
|
54 | + public function testIs_file(): void { |
|
55 | + $this->assertFalse($this->storage->is_file('foo')); |
|
56 | + } |
|
57 | 57 | |
58 | - public function testStat(): void { |
|
59 | - $this->expectException(ForbiddenException::class); |
|
60 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
58 | + public function testStat(): void { |
|
59 | + $this->expectException(ForbiddenException::class); |
|
60 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
61 | 61 | |
62 | - $this->storage->stat('foo'); |
|
63 | - } |
|
62 | + $this->storage->stat('foo'); |
|
63 | + } |
|
64 | 64 | |
65 | - public function testFiletype(): void { |
|
66 | - $this->assertSame('dir', $this->storage->filetype('')); |
|
67 | - $this->assertFalse($this->storage->filetype('foo')); |
|
68 | - } |
|
65 | + public function testFiletype(): void { |
|
66 | + $this->assertSame('dir', $this->storage->filetype('')); |
|
67 | + $this->assertFalse($this->storage->filetype('foo')); |
|
68 | + } |
|
69 | 69 | |
70 | - public function testFilesize(): void { |
|
71 | - $this->expectException(ForbiddenException::class); |
|
72 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
70 | + public function testFilesize(): void { |
|
71 | + $this->expectException(ForbiddenException::class); |
|
72 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
73 | 73 | |
74 | - $this->storage->filesize('foo'); |
|
75 | - } |
|
74 | + $this->storage->filesize('foo'); |
|
75 | + } |
|
76 | 76 | |
77 | - public function testIsCreatable(): void { |
|
78 | - $this->assertFalse($this->storage->isCreatable('foo')); |
|
79 | - } |
|
77 | + public function testIsCreatable(): void { |
|
78 | + $this->assertFalse($this->storage->isCreatable('foo')); |
|
79 | + } |
|
80 | 80 | |
81 | - public function testIsReadable(): void { |
|
82 | - $this->assertTrue($this->storage->isReadable('')); |
|
83 | - $this->assertFalse($this->storage->isReadable('foo')); |
|
84 | - } |
|
81 | + public function testIsReadable(): void { |
|
82 | + $this->assertTrue($this->storage->isReadable('')); |
|
83 | + $this->assertFalse($this->storage->isReadable('foo')); |
|
84 | + } |
|
85 | 85 | |
86 | - public function testIsUpdatable(): void { |
|
87 | - $this->assertFalse($this->storage->isUpdatable('foo')); |
|
88 | - } |
|
86 | + public function testIsUpdatable(): void { |
|
87 | + $this->assertFalse($this->storage->isUpdatable('foo')); |
|
88 | + } |
|
89 | 89 | |
90 | - public function testIsDeletable(): void { |
|
91 | - $this->assertFalse($this->storage->isDeletable('foo')); |
|
92 | - } |
|
90 | + public function testIsDeletable(): void { |
|
91 | + $this->assertFalse($this->storage->isDeletable('foo')); |
|
92 | + } |
|
93 | 93 | |
94 | - public function testIsSharable(): void { |
|
95 | - $this->assertFalse($this->storage->isSharable('foo')); |
|
96 | - } |
|
94 | + public function testIsSharable(): void { |
|
95 | + $this->assertFalse($this->storage->isSharable('foo')); |
|
96 | + } |
|
97 | 97 | |
98 | - public function testGetPermissions(): void { |
|
99 | - $this->assertEquals(0, $this->storage->getPermissions('foo')); |
|
100 | - } |
|
98 | + public function testGetPermissions(): void { |
|
99 | + $this->assertEquals(0, $this->storage->getPermissions('foo')); |
|
100 | + } |
|
101 | 101 | |
102 | - public function testFile_exists(): void { |
|
103 | - $this->assertTrue($this->storage->file_exists('')); |
|
104 | - $this->assertFalse($this->storage->file_exists('foo')); |
|
105 | - } |
|
102 | + public function testFile_exists(): void { |
|
103 | + $this->assertTrue($this->storage->file_exists('')); |
|
104 | + $this->assertFalse($this->storage->file_exists('foo')); |
|
105 | + } |
|
106 | 106 | |
107 | - public function testFilemtime(): void { |
|
108 | - $this->assertFalse($this->storage->filemtime('foo')); |
|
109 | - } |
|
107 | + public function testFilemtime(): void { |
|
108 | + $this->assertFalse($this->storage->filemtime('foo')); |
|
109 | + } |
|
110 | 110 | |
111 | - public function testFile_get_contents(): void { |
|
112 | - $this->expectException(ForbiddenException::class); |
|
113 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
111 | + public function testFile_get_contents(): void { |
|
112 | + $this->expectException(ForbiddenException::class); |
|
113 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
114 | 114 | |
115 | - $this->storage->file_get_contents('foo'); |
|
116 | - } |
|
115 | + $this->storage->file_get_contents('foo'); |
|
116 | + } |
|
117 | 117 | |
118 | - public function testFile_put_contents(): void { |
|
119 | - $this->expectException(ForbiddenException::class); |
|
120 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
118 | + public function testFile_put_contents(): void { |
|
119 | + $this->expectException(ForbiddenException::class); |
|
120 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
121 | 121 | |
122 | - $this->storage->file_put_contents('foo', 'bar'); |
|
123 | - } |
|
122 | + $this->storage->file_put_contents('foo', 'bar'); |
|
123 | + } |
|
124 | 124 | |
125 | - public function testUnlink(): void { |
|
126 | - $this->expectException(ForbiddenException::class); |
|
127 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
125 | + public function testUnlink(): void { |
|
126 | + $this->expectException(ForbiddenException::class); |
|
127 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
128 | 128 | |
129 | - $this->storage->unlink('foo'); |
|
130 | - } |
|
129 | + $this->storage->unlink('foo'); |
|
130 | + } |
|
131 | 131 | |
132 | - public function testRename(): void { |
|
133 | - $this->expectException(ForbiddenException::class); |
|
134 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
132 | + public function testRename(): void { |
|
133 | + $this->expectException(ForbiddenException::class); |
|
134 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
135 | 135 | |
136 | - $this->storage->rename('foo', 'bar'); |
|
137 | - } |
|
136 | + $this->storage->rename('foo', 'bar'); |
|
137 | + } |
|
138 | 138 | |
139 | - public function testCopy(): void { |
|
140 | - $this->expectException(ForbiddenException::class); |
|
141 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
139 | + public function testCopy(): void { |
|
140 | + $this->expectException(ForbiddenException::class); |
|
141 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
142 | 142 | |
143 | - $this->storage->copy('foo', 'bar'); |
|
144 | - } |
|
143 | + $this->storage->copy('foo', 'bar'); |
|
144 | + } |
|
145 | 145 | |
146 | - public function testFopen(): void { |
|
147 | - $this->expectException(ForbiddenException::class); |
|
148 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
146 | + public function testFopen(): void { |
|
147 | + $this->expectException(ForbiddenException::class); |
|
148 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
149 | 149 | |
150 | - $this->storage->fopen('foo', 'R'); |
|
151 | - } |
|
150 | + $this->storage->fopen('foo', 'R'); |
|
151 | + } |
|
152 | 152 | |
153 | - public function testGetMimeType(): void { |
|
154 | - $this->expectException(ForbiddenException::class); |
|
155 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
153 | + public function testGetMimeType(): void { |
|
154 | + $this->expectException(ForbiddenException::class); |
|
155 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
156 | 156 | |
157 | - $this->storage->getMimeType('foo'); |
|
158 | - } |
|
157 | + $this->storage->getMimeType('foo'); |
|
158 | + } |
|
159 | 159 | |
160 | - public function testHash(): void { |
|
161 | - $this->expectException(ForbiddenException::class); |
|
162 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
160 | + public function testHash(): void { |
|
161 | + $this->expectException(ForbiddenException::class); |
|
162 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
163 | 163 | |
164 | - $this->storage->hash('md5', 'foo', true); |
|
165 | - } |
|
164 | + $this->storage->hash('md5', 'foo', true); |
|
165 | + } |
|
166 | 166 | |
167 | - public function testFree_space(): void { |
|
168 | - $this->assertSame(FileInfo::SPACE_UNKNOWN, $this->storage->free_space('foo')); |
|
169 | - } |
|
167 | + public function testFree_space(): void { |
|
168 | + $this->assertSame(FileInfo::SPACE_UNKNOWN, $this->storage->free_space('foo')); |
|
169 | + } |
|
170 | 170 | |
171 | - public function testTouch(): void { |
|
172 | - $this->expectException(ForbiddenException::class); |
|
173 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
171 | + public function testTouch(): void { |
|
172 | + $this->expectException(ForbiddenException::class); |
|
173 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
174 | 174 | |
175 | - $this->storage->touch('foo'); |
|
176 | - } |
|
175 | + $this->storage->touch('foo'); |
|
176 | + } |
|
177 | 177 | |
178 | - public function testGetLocalFile(): void { |
|
179 | - $this->assertFalse($this->storage->getLocalFile('foo')); |
|
180 | - } |
|
178 | + public function testGetLocalFile(): void { |
|
179 | + $this->assertFalse($this->storage->getLocalFile('foo')); |
|
180 | + } |
|
181 | 181 | |
182 | - public function testHasUpdated(): void { |
|
183 | - $this->assertFalse($this->storage->hasUpdated('foo', 42)); |
|
184 | - } |
|
182 | + public function testHasUpdated(): void { |
|
183 | + $this->assertFalse($this->storage->hasUpdated('foo', 42)); |
|
184 | + } |
|
185 | 185 | |
186 | - public function testGetETag(): void { |
|
187 | - $this->assertSame('', $this->storage->getETag('foo')); |
|
188 | - } |
|
186 | + public function testGetETag(): void { |
|
187 | + $this->assertSame('', $this->storage->getETag('foo')); |
|
188 | + } |
|
189 | 189 | |
190 | - public function testIsLocal(): void { |
|
191 | - $this->assertFalse($this->storage->isLocal()); |
|
192 | - } |
|
190 | + public function testIsLocal(): void { |
|
191 | + $this->assertFalse($this->storage->isLocal()); |
|
192 | + } |
|
193 | 193 | |
194 | - public function testGetDirectDownload(): void { |
|
195 | - $this->assertFalse($this->storage->getDirectDownload('foo')); |
|
196 | - } |
|
194 | + public function testGetDirectDownload(): void { |
|
195 | + $this->assertFalse($this->storage->getDirectDownload('foo')); |
|
196 | + } |
|
197 | 197 | |
198 | - public function testCopyFromStorage(): void { |
|
199 | - $sourceStorage = $this->createMock(IStorage::class); |
|
198 | + public function testCopyFromStorage(): void { |
|
199 | + $sourceStorage = $this->createMock(IStorage::class); |
|
200 | 200 | |
201 | - $this->expectException(ForbiddenException::class); |
|
202 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
201 | + $this->expectException(ForbiddenException::class); |
|
202 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
203 | 203 | |
204 | - $this->storage->copyFromStorage($sourceStorage, 'foo', 'bar'); |
|
205 | - } |
|
204 | + $this->storage->copyFromStorage($sourceStorage, 'foo', 'bar'); |
|
205 | + } |
|
206 | 206 | |
207 | - public function testMoveFromStorage(): void { |
|
208 | - $sourceStorage = $this->createMock(IStorage::class); |
|
207 | + public function testMoveFromStorage(): void { |
|
208 | + $sourceStorage = $this->createMock(IStorage::class); |
|
209 | 209 | |
210 | - $this->expectException(ForbiddenException::class); |
|
211 | - $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
210 | + $this->expectException(ForbiddenException::class); |
|
211 | + $this->expectExceptionMessage('This request is not allowed to access the filesystem'); |
|
212 | 212 | |
213 | - $this->storage->moveFromStorage($sourceStorage, 'foo', 'bar'); |
|
214 | - } |
|
213 | + $this->storage->moveFromStorage($sourceStorage, 'foo', 'bar'); |
|
214 | + } |
|
215 | 215 | |
216 | - public function testTest() { |
|
217 | - $this->assertTrue($this->storage->test()); |
|
218 | - return true; |
|
219 | - } |
|
216 | + public function testTest() { |
|
217 | + $this->assertTrue($this->storage->test()); |
|
218 | + return true; |
|
219 | + } |
|
220 | 220 | |
221 | - public function testGetOwner(): void { |
|
222 | - $this->assertFalse($this->storage->getOwner('foo')); |
|
223 | - } |
|
221 | + public function testGetOwner(): void { |
|
222 | + $this->assertFalse($this->storage->getOwner('foo')); |
|
223 | + } |
|
224 | 224 | |
225 | - public function testGetCache(): void { |
|
226 | - $this->assertInstanceOf(NullCache::class, $this->storage->getCache('foo')); |
|
227 | - } |
|
225 | + public function testGetCache(): void { |
|
226 | + $this->assertInstanceOf(NullCache::class, $this->storage->getCache('foo')); |
|
227 | + } |
|
228 | 228 | } |
@@ -18,106 +18,106 @@ |
||
18 | 18 | * @group DB |
19 | 19 | */ |
20 | 20 | class AppScriptSortTest extends \Test\TestCase { |
21 | - private $logger; |
|
22 | - |
|
23 | - protected function setUp(): void { |
|
24 | - $this->logger = $this->getMockBuilder(LoggerInterface::class) |
|
25 | - ->disableOriginalConstructor() |
|
26 | - ->getMock(); |
|
27 | - |
|
28 | - parent::setUp(); |
|
29 | - } |
|
30 | - |
|
31 | - public function testSort(): void { |
|
32 | - $scripts = [ |
|
33 | - 'first' => ['myFirstJSFile'], |
|
34 | - 'core' => [ |
|
35 | - 'core/js/myFancyJSFile1', |
|
36 | - 'core/js/myFancyJSFile4', |
|
37 | - 'core/js/myFancyJSFile5', |
|
38 | - 'core/js/myFancyJSFile1', |
|
39 | - ], |
|
40 | - 'files' => ['files/js/myFancyJSFile2'], |
|
41 | - 'myApp5' => ['myApp5/js/myApp5JSFile'], |
|
42 | - 'myApp' => ['myApp/js/myFancyJSFile3'], |
|
43 | - 'myApp4' => ['myApp4/js/myApp4JSFile'], |
|
44 | - 'myApp3' => ['myApp3/js/myApp3JSFile'], |
|
45 | - 'myApp2' => ['myApp2/js/myApp2JSFile'], |
|
46 | - ]; |
|
47 | - $scriptDeps = [ |
|
48 | - 'first' => new AppScriptDependency('first', ['core']), |
|
49 | - 'core' => new AppScriptDependency('core', ['core']), |
|
50 | - 'files' => new AppScriptDependency('files', ['core']), |
|
51 | - 'myApp5' => new AppScriptDependency('myApp5', ['myApp2']), |
|
52 | - 'myApp' => new AppScriptDependency('myApp', ['core']), |
|
53 | - 'myApp4' => new AppScriptDependency('myApp4', ['myApp3']), |
|
54 | - 'myApp3' => new AppScriptDependency('myApp3', ['myApp2']), |
|
55 | - 'myApp2' => new AppScriptDependency('myApp2', ['myApp']), |
|
56 | - ]; |
|
57 | - |
|
58 | - // No circular dependency is detected and logged as an error |
|
59 | - $this->logger->expects(self::never())->method('error'); |
|
60 | - |
|
61 | - $scriptSort = new AppScriptSort($this->logger); |
|
62 | - $sortedScripts = $scriptSort->sort($scripts, $scriptDeps); |
|
63 | - |
|
64 | - $sortedScriptKeys = array_keys($sortedScripts); |
|
65 | - |
|
66 | - // Core should appear first |
|
67 | - $this->assertEquals( |
|
68 | - 0, |
|
69 | - array_search('core', $sortedScriptKeys, true) |
|
70 | - ); |
|
71 | - |
|
72 | - // Dependencies should appear before their children |
|
73 | - $this->assertLessThan( |
|
74 | - array_search('files', $sortedScriptKeys, true), |
|
75 | - array_search('core', $sortedScriptKeys, true) |
|
76 | - ); |
|
77 | - $this->assertLessThan( |
|
78 | - array_search('myApp2', $sortedScriptKeys, true), |
|
79 | - array_search('myApp', $sortedScriptKeys, true) |
|
80 | - ); |
|
81 | - $this->assertLessThan( |
|
82 | - array_search('myApp3', $sortedScriptKeys, true), |
|
83 | - array_search('myApp2', $sortedScriptKeys, true) |
|
84 | - ); |
|
85 | - $this->assertLessThan( |
|
86 | - array_search('myApp4', $sortedScriptKeys, true), |
|
87 | - array_search('myApp3', $sortedScriptKeys, true) |
|
88 | - ); |
|
89 | - $this->assertLessThan( |
|
90 | - array_search('myApp5', $sortedScriptKeys, true), |
|
91 | - array_search('myApp2', $sortedScriptKeys, true) |
|
92 | - ); |
|
93 | - |
|
94 | - // All apps still there |
|
95 | - foreach ($scripts as $app => $_) { |
|
96 | - $this->assertContains($app, $sortedScriptKeys); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - public function testSortCircularDependency(): void { |
|
101 | - $scripts = [ |
|
102 | - 'circular' => ['circular/js/file1'], |
|
103 | - 'dependency' => ['dependency/js/file2'], |
|
104 | - ]; |
|
105 | - $scriptDeps = [ |
|
106 | - 'circular' => new AppScriptDependency('circular', ['dependency']), |
|
107 | - 'dependency' => new AppScriptDependency('dependency', ['circular']), |
|
108 | - ]; |
|
109 | - |
|
110 | - // A circular dependency is detected and logged as an error |
|
111 | - $this->logger->expects(self::once())->method('error'); |
|
112 | - |
|
113 | - $scriptSort = new AppScriptSort($this->logger); |
|
114 | - $sortedScripts = $scriptSort->sort($scripts, $scriptDeps); |
|
115 | - |
|
116 | - $sortedScriptKeys = array_keys($sortedScripts); |
|
117 | - |
|
118 | - // All apps still there |
|
119 | - foreach ($scripts as $app => $_) { |
|
120 | - $this->assertContains($app, $sortedScriptKeys); |
|
121 | - } |
|
122 | - } |
|
21 | + private $logger; |
|
22 | + |
|
23 | + protected function setUp(): void { |
|
24 | + $this->logger = $this->getMockBuilder(LoggerInterface::class) |
|
25 | + ->disableOriginalConstructor() |
|
26 | + ->getMock(); |
|
27 | + |
|
28 | + parent::setUp(); |
|
29 | + } |
|
30 | + |
|
31 | + public function testSort(): void { |
|
32 | + $scripts = [ |
|
33 | + 'first' => ['myFirstJSFile'], |
|
34 | + 'core' => [ |
|
35 | + 'core/js/myFancyJSFile1', |
|
36 | + 'core/js/myFancyJSFile4', |
|
37 | + 'core/js/myFancyJSFile5', |
|
38 | + 'core/js/myFancyJSFile1', |
|
39 | + ], |
|
40 | + 'files' => ['files/js/myFancyJSFile2'], |
|
41 | + 'myApp5' => ['myApp5/js/myApp5JSFile'], |
|
42 | + 'myApp' => ['myApp/js/myFancyJSFile3'], |
|
43 | + 'myApp4' => ['myApp4/js/myApp4JSFile'], |
|
44 | + 'myApp3' => ['myApp3/js/myApp3JSFile'], |
|
45 | + 'myApp2' => ['myApp2/js/myApp2JSFile'], |
|
46 | + ]; |
|
47 | + $scriptDeps = [ |
|
48 | + 'first' => new AppScriptDependency('first', ['core']), |
|
49 | + 'core' => new AppScriptDependency('core', ['core']), |
|
50 | + 'files' => new AppScriptDependency('files', ['core']), |
|
51 | + 'myApp5' => new AppScriptDependency('myApp5', ['myApp2']), |
|
52 | + 'myApp' => new AppScriptDependency('myApp', ['core']), |
|
53 | + 'myApp4' => new AppScriptDependency('myApp4', ['myApp3']), |
|
54 | + 'myApp3' => new AppScriptDependency('myApp3', ['myApp2']), |
|
55 | + 'myApp2' => new AppScriptDependency('myApp2', ['myApp']), |
|
56 | + ]; |
|
57 | + |
|
58 | + // No circular dependency is detected and logged as an error |
|
59 | + $this->logger->expects(self::never())->method('error'); |
|
60 | + |
|
61 | + $scriptSort = new AppScriptSort($this->logger); |
|
62 | + $sortedScripts = $scriptSort->sort($scripts, $scriptDeps); |
|
63 | + |
|
64 | + $sortedScriptKeys = array_keys($sortedScripts); |
|
65 | + |
|
66 | + // Core should appear first |
|
67 | + $this->assertEquals( |
|
68 | + 0, |
|
69 | + array_search('core', $sortedScriptKeys, true) |
|
70 | + ); |
|
71 | + |
|
72 | + // Dependencies should appear before their children |
|
73 | + $this->assertLessThan( |
|
74 | + array_search('files', $sortedScriptKeys, true), |
|
75 | + array_search('core', $sortedScriptKeys, true) |
|
76 | + ); |
|
77 | + $this->assertLessThan( |
|
78 | + array_search('myApp2', $sortedScriptKeys, true), |
|
79 | + array_search('myApp', $sortedScriptKeys, true) |
|
80 | + ); |
|
81 | + $this->assertLessThan( |
|
82 | + array_search('myApp3', $sortedScriptKeys, true), |
|
83 | + array_search('myApp2', $sortedScriptKeys, true) |
|
84 | + ); |
|
85 | + $this->assertLessThan( |
|
86 | + array_search('myApp4', $sortedScriptKeys, true), |
|
87 | + array_search('myApp3', $sortedScriptKeys, true) |
|
88 | + ); |
|
89 | + $this->assertLessThan( |
|
90 | + array_search('myApp5', $sortedScriptKeys, true), |
|
91 | + array_search('myApp2', $sortedScriptKeys, true) |
|
92 | + ); |
|
93 | + |
|
94 | + // All apps still there |
|
95 | + foreach ($scripts as $app => $_) { |
|
96 | + $this->assertContains($app, $sortedScriptKeys); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + public function testSortCircularDependency(): void { |
|
101 | + $scripts = [ |
|
102 | + 'circular' => ['circular/js/file1'], |
|
103 | + 'dependency' => ['dependency/js/file2'], |
|
104 | + ]; |
|
105 | + $scriptDeps = [ |
|
106 | + 'circular' => new AppScriptDependency('circular', ['dependency']), |
|
107 | + 'dependency' => new AppScriptDependency('dependency', ['circular']), |
|
108 | + ]; |
|
109 | + |
|
110 | + // A circular dependency is detected and logged as an error |
|
111 | + $this->logger->expects(self::once())->method('error'); |
|
112 | + |
|
113 | + $scriptSort = new AppScriptSort($this->logger); |
|
114 | + $sortedScripts = $scriptSort->sort($scripts, $scriptDeps); |
|
115 | + |
|
116 | + $sortedScriptKeys = array_keys($sortedScripts); |
|
117 | + |
|
118 | + // All apps still there |
|
119 | + foreach ($scripts as $app => $_) { |
|
120 | + $this->assertContains($app, $sortedScriptKeys); |
|
121 | + } |
|
122 | + } |
|
123 | 123 | } |
@@ -14,44 +14,44 @@ |
||
14 | 14 | use Test\TestCase; |
15 | 15 | |
16 | 16 | class EventLoggerTest extends TestCase { |
17 | - /** @var \OC\Diagnostics\EventLogger */ |
|
18 | - private $logger; |
|
19 | - |
|
20 | - protected function setUp(): void { |
|
21 | - parent::setUp(); |
|
22 | - |
|
23 | - $this->logger = new EventLogger( |
|
24 | - $this->createMock(SystemConfig::class), |
|
25 | - $this->createMock(LoggerInterface::class), |
|
26 | - $this->createMock(Log::class) |
|
27 | - ); |
|
28 | - } |
|
29 | - |
|
30 | - public function testQueryLogger(): void { |
|
31 | - // Module is not activated and this should not be logged |
|
32 | - $this->logger->start('test1', 'testevent1'); |
|
33 | - $this->logger->end('test1'); |
|
34 | - $this->logger->log('test2', 'testevent2', microtime(true), microtime(true)); |
|
35 | - $events = $this->logger->getEvents(); |
|
36 | - $this->assertSame(0, sizeof($events)); |
|
37 | - |
|
38 | - // Activate module and log some query |
|
39 | - $this->logger->activate(); |
|
40 | - |
|
41 | - // start one event |
|
42 | - $this->logger->start('test3', 'testevent3'); |
|
43 | - |
|
44 | - // force log of another event |
|
45 | - $this->logger->log('test4', 'testevent4', microtime(true), microtime(true)); |
|
46 | - |
|
47 | - // log started event |
|
48 | - $this->logger->end('test3'); |
|
49 | - |
|
50 | - $events = $this->logger->getEvents(); |
|
51 | - $this->assertSame('test4', $events['test4']->getId()); |
|
52 | - $this->assertSame('testevent4', $events['test4']->getDescription()); |
|
53 | - $this->assertSame('test3', $events['test3']->getId()); |
|
54 | - $this->assertSame('testevent3', $events['test3']->getDescription()); |
|
55 | - $this->assertSame(2, sizeof($events)); |
|
56 | - } |
|
17 | + /** @var \OC\Diagnostics\EventLogger */ |
|
18 | + private $logger; |
|
19 | + |
|
20 | + protected function setUp(): void { |
|
21 | + parent::setUp(); |
|
22 | + |
|
23 | + $this->logger = new EventLogger( |
|
24 | + $this->createMock(SystemConfig::class), |
|
25 | + $this->createMock(LoggerInterface::class), |
|
26 | + $this->createMock(Log::class) |
|
27 | + ); |
|
28 | + } |
|
29 | + |
|
30 | + public function testQueryLogger(): void { |
|
31 | + // Module is not activated and this should not be logged |
|
32 | + $this->logger->start('test1', 'testevent1'); |
|
33 | + $this->logger->end('test1'); |
|
34 | + $this->logger->log('test2', 'testevent2', microtime(true), microtime(true)); |
|
35 | + $events = $this->logger->getEvents(); |
|
36 | + $this->assertSame(0, sizeof($events)); |
|
37 | + |
|
38 | + // Activate module and log some query |
|
39 | + $this->logger->activate(); |
|
40 | + |
|
41 | + // start one event |
|
42 | + $this->logger->start('test3', 'testevent3'); |
|
43 | + |
|
44 | + // force log of another event |
|
45 | + $this->logger->log('test4', 'testevent4', microtime(true), microtime(true)); |
|
46 | + |
|
47 | + // log started event |
|
48 | + $this->logger->end('test3'); |
|
49 | + |
|
50 | + $events = $this->logger->getEvents(); |
|
51 | + $this->assertSame('test4', $events['test4']->getId()); |
|
52 | + $this->assertSame('testevent4', $events['test4']->getDescription()); |
|
53 | + $this->assertSame('test3', $events['test3']->getId()); |
|
54 | + $this->assertSame('testevent3', $events['test3']->getDescription()); |
|
55 | + $this->assertSame(2, sizeof($events)); |
|
56 | + } |
|
57 | 57 | } |