Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: Fix tests/lib/Files
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed May 15, 2025
commit 9621e451ba24c287b4bab73d4376a6655f59cd7f
69 changes: 30 additions & 39 deletions tests/lib/Config/UserConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,7 @@ public function testGetKeys(): void {
);
}

/**
* @return array[]
*/
public function providerHasKey(): array {
public static function providerHasKey(): array {
return [
['user1', 'app1', 'key1', false, true],
['user0', 'app1', 'key1', false, false],
Expand All @@ -358,10 +355,7 @@ public function testHasKey(string $userId, string $appId, string $key, ?bool $la
$this->assertEquals($result, $userConfig->hasKey($userId, $appId, $key, $lazy));
}

/**
* @return array[]
*/
public function providerIsSensitive(): array {
public static function providerIsSensitive(): array {
return [
['user1', 'app1', 'key1', false, false, false],
['user0', 'app1', 'key1', false, false, true],
Expand Down Expand Up @@ -399,10 +393,7 @@ public function testIsSensitive(
$this->assertEquals($result, $userConfig->isSensitive($userId, $appId, $key, $lazy));
}

/**
* @return array[]
*/
public function providerIsLazy(): array {
public static function providerIsLazy(): array {
return [
['user1', 'app1', 'key1', false, false],
['user0', 'app1', 'key1', false, true],
Expand Down Expand Up @@ -432,7 +423,7 @@ public function testIsLazy(
$this->assertEquals($result, $userConfig->isLazy($userId, $appId, $key));
}

public function providerGetValues(): array {
public static function providerGetValues(): array {
return [
[
'user1', 'app1', '', true,
Expand Down Expand Up @@ -565,7 +556,7 @@ public function testGetValues(
);
}

public function providerGetAllValues(): array {
public static function providerGetAllValues(): array {
return [
[
'user2', false,
Expand Down Expand Up @@ -662,7 +653,7 @@ public function testGetAllValues(
$this->assertEqualsCanonicalizing($result, $userConfig->getAllValues($userId, $filtered));
}

public function providerSearchValuesByApps(): array {
public static function providerSearchValuesByApps(): array {
return [
[
'user1', 'key1', false, null,
Expand Down Expand Up @@ -708,7 +699,7 @@ public function testSearchValuesByApps(
$this->assertEquals($result, $userConfig->getValuesByApps($userId, $key, $lazy, $typedAs));
}

public function providerSearchValuesByUsers(): array {
public static function providerSearchValuesByUsers(): array {
return [
[
'app2', 'key2', null, null,
Expand Down Expand Up @@ -760,7 +751,7 @@ public function testSearchValuesByUsers(
);
}

public function providerSearchValuesByValueString(): array {
public static function providerSearchValuesByValueString(): array {
return [
['app2', 'key2', 'value2a', false, ['user1']],
['app2', 'key2', 'value2A', false, ['user4']],
Expand All @@ -782,7 +773,7 @@ public function testSearchUsersByValueString(
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueString($app, $key, $value, $ci)));
}

public function providerSearchValuesByValueInt(): array {
public static function providerSearchValuesByValueInt(): array {
return [
['app3', 'key8', 12, []], // sensitive value, cannot search
['app2', 'key8', 12, ['user2', 'user5']], // sensitive value, cannot search
Expand All @@ -803,7 +794,7 @@ public function testSearchUsersByValueInt(
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueInt($app, $key, $value)));
}

public function providerSearchValuesByValues(): array {
public static function providerSearchValuesByValues(): array {
return [
['app2', 'key2', ['value2a', 'value2b'], ['user1', 'user2']],
['app2', 'key2', ['value2a', 'value2c'], ['user1', 'user3']],
Expand All @@ -823,7 +814,7 @@ public function testSearchUsersByValues(
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValues($app, $key, $values)));
}

public function providerSearchValuesByValueBool(): array {
public static function providerSearchValuesByValueBool(): array {
return [
['app3', 'key10', true, ['user1', 'user4']],
['app3', 'key10', false, ['user2']],
Expand All @@ -843,7 +834,7 @@ public function testSearchUsersByValueBool(
$this->assertEqualsCanonicalizing($result, iterator_to_array($userConfig->searchUsersByValueBool($app, $key, $value)));
}

public function providerGetValueMixed(): array {
public static function providerGetValueMixed(): array {
return [
[
['user1'], 'user1', 'app1', 'key0', 'default_because_unknown_key', true,
Expand Down Expand Up @@ -943,7 +934,7 @@ public function testGetValueString(
$this->assertEquals($result, $userConfig->getValueString($userId, $app, $key, $default, $lazy));
}

public function providerGetValueInt(): array {
public static function providerGetValueInt(): array {
return [
[['user1'], 'user1', 'app1', 'key0', 54321, true, 54321],
[null, 'user1', 'app1', 'key0', 54321, true, 54321],
Expand Down Expand Up @@ -985,7 +976,7 @@ public function testGetValueInt(
$this->assertEquals($result, $userConfig->getValueInt($userId, $app, $key, $default, $lazy));
}

public function providerGetValueFloat(): array {
public static function providerGetValueFloat(): array {
return [
[['user1'], 'user1', 'app1', 'key0', 54.321, true, 54.321],
[null, 'user1', 'app1', 'key0', 54.321, true, 54.321],
Expand Down Expand Up @@ -1026,7 +1017,7 @@ public function testGetValueFloat(
$this->assertEquals($result, $userConfig->getValueFloat($userId, $app, $key, $default, $lazy));
}

public function providerGetValueBool(): array {
public static function providerGetValueBool(): array {
return [
[['user1'], 'user1', 'app1', 'key0', false, true, false],
[null, 'user1', 'app1', 'key0', false, true, false],
Expand Down Expand Up @@ -1087,7 +1078,7 @@ public function testGetValueBool(
$this->assertEquals($result, $userConfig->getValueBool($userId, $app, $key, $default, $lazy));
}

public function providerGetValueArray(): array {
public static function providerGetValueArray(): array {
return [
[
['user1'], 'user1', 'app1', 'key0', ['default_because_unknown_key'], true,
Expand Down Expand Up @@ -1126,7 +1117,7 @@ public function testGetValueArray(
);
}

public function providerGetValueType(): array {
public static function providerGetValueType(): array {
return [
[null, 'user1', 'app1', 'key1', false, ValueType::MIXED],
[null, 'user1', 'app1', 'key1', true, null, UnknownKeyException::class],
Expand Down Expand Up @@ -1187,7 +1178,7 @@ public function testGetValueType(
}
}

public function providerSetValueMixed(): array {
public static function providerSetValueMixed(): array {
return [
[null, 'user1', 'app1', 'key1', 'value', false, false, true],
[null, 'user1', 'app1', 'key1', '12345', true, false, true],
Expand Down Expand Up @@ -1250,7 +1241,7 @@ public function testSetValueMixed(
}


public function providerSetValueString(): array {
public static function providerSetValueString(): array {
return [
[null, 'user1', 'app1', 'key1', 'value', false, false, true],
[null, 'user1', 'app1', 'key1', '12345', true, false, true],
Expand Down Expand Up @@ -1325,7 +1316,7 @@ public function testSetValueString(
}
}

public function providerSetValueInt(): array {
public static function providerSetValueInt(): array {
return [
[null, 'user1', 'app1', 'key1', 12345, false, false, true],
[null, 'user1', 'app1', 'key1', 12345, true, false, true],
Expand Down Expand Up @@ -1389,7 +1380,7 @@ public function testSetValueInt(
}
}

public function providerSetValueFloat(): array {
public static function providerSetValueFloat(): array {
return [
[null, 'user1', 'app1', 'key1', 12.345, false, false, true],
[null, 'user1', 'app1', 'key1', 12.345, true, false, true],
Expand Down Expand Up @@ -1453,7 +1444,7 @@ public function testSetValueFloat(
}


public function providerSetValueArray(): array {
public static function providerSetValueArray(): array {
return [
[null, 'user1', 'app1', 'key1', [], false, false, true],
[null, 'user1', 'app1', 'key1', [], true, false, true],
Expand Down Expand Up @@ -1520,7 +1511,7 @@ public function testSetValueArray(
}
}

public function providerUpdateSensitive(): array {
public static function providerUpdateSensitive(): array {
return [
[null, 'user1', 'app1', 'key1', false, false],
[['user1'], 'user1', 'app1', 'key1', false, false],
Expand Down Expand Up @@ -1566,7 +1557,7 @@ public function testUpdateSensitive(
}
}

public function providerUpdateGlobalSensitive(): array {
public static function providerUpdateGlobalSensitive(): array {
return [[true], [false]];
}

Expand Down Expand Up @@ -1610,7 +1601,7 @@ public function testUpdateGlobalSensitive(bool $sensitive): void {
}
}

public function providerUpdateLazy(): array {
public static function providerUpdateLazy(): array {
return [
[null, 'user1', 'app1', 'key1', false, false],
[['user1'], 'user1', 'app1', 'key1', false, false],
Expand Down Expand Up @@ -1649,7 +1640,7 @@ public function testUpdateLazy(
}
}

public function providerUpdateGlobalLazy(): array {
public static function providerUpdateGlobalLazy(): array {
return [[true], [false]];
}

Expand Down Expand Up @@ -1679,7 +1670,7 @@ public function testUpdateGlobalLazy(bool $lazy): void {
}
}

public function providerGetDetails(): array {
public static function providerGetDetails(): array {
return [
[
'user3', 'app2', 'key2',
Expand Down Expand Up @@ -1732,7 +1723,7 @@ public function testGetDetails(string $userId, string $app, string $key, array $
}


public function providerDeletePreference(): array {
public static function providerDeletePreference(): array {
return [
[null, 'user1', 'app1', 'key22'],
[['user1'], 'user1', 'app1', 'fast_string_sensitive'],
Expand Down Expand Up @@ -1763,7 +1754,7 @@ public function testDeletePreference(
$this->assertEquals(false, $userConfig->hasKey($userId, $app, $key, $lazy));
}

public function providerDeleteKey(): array {
public static function providerDeleteKey(): array {
return [
[null, 'app2', 'key3'],
[['user1'], 'app2', 'key3'],
Expand Down Expand Up @@ -1832,7 +1823,7 @@ public function testClearCacheAll(): void {
'fastCache' => [],
'lazyLoaded' => [],
'lazyCache' => [],
'valueTypes' => [],
'valueDetails' => [],
],
$userConfig->statusCache()
);
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function setUp(): void {
* provide username, password combinations for testRemovePassword
* @return array
*/
public function passwordProvider() {
public static function passwordProvider(): array {
return [
['us:er', 'pass@word'],
['us:er', 'password'],
Expand Down
50 changes: 25 additions & 25 deletions tests/lib/Files/Cache/CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ class CacheTest extends \Test\TestCase {
*/
protected $cache2;

protected function setUp(): void {
parent::setUp();

$this->storage = new \OC\Files\Storage\Temporary([]);
$this->storage2 = new \OC\Files\Storage\Temporary([]);
$this->cache = new \OC\Files\Cache\Cache($this->storage);
$this->cache2 = new \OC\Files\Cache\Cache($this->storage2);
$this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
$this->cache2->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
}

protected function tearDown(): void {
if ($this->cache) {
$this->cache->clear();
}

parent::tearDown();
}

public function testGetNumericId(): void {
$this->assertNotNull($this->cache->getNumericStorageId());
}
Expand Down Expand Up @@ -208,7 +227,7 @@ public function testRemoveRecursive(): void {
}
}

public function folderDataProvider() {
public static function folderDataProvider(): array {
return [
['folder'],
// that was too easy, try something harder
Expand Down Expand Up @@ -301,7 +320,7 @@ public function testStatus(): void {
$this->assertEquals(\OC\Files\Cache\Cache::COMPLETE, $this->cache->getStatus('foo'));
}

public function putWithAllKindOfQuotesData() {
public static function putWithAllKindOfQuotesData(): array {
return [
['`backtick`'],
['´forward´'],
Expand Down Expand Up @@ -437,7 +456,7 @@ public function testSearchByQuery(): void {
new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN_EQUAL, 'size', 100), 10, 0, [], $user)));
}

public function movePathProvider() {
public static function movePathProvider(): array {
return [
['folder/foo', 'folder/foobar', ['1', '2']],
['folder/foo', 'foo', ['1', '2']],
Expand Down Expand Up @@ -575,7 +594,7 @@ public function testWithoutNormalizer(): void {
* @var \OC\Files\Cache\Cache | \PHPUnit\Framework\MockObject\MockObject $cacheMock
*/
$cacheMock = $this->getMockBuilder(Cache::class)
->setMethods(['normalize'])
->onlyMethods(['normalize'])
->setConstructorArgs([$this->storage])
->getMock();

Expand Down Expand Up @@ -646,7 +665,7 @@ public function testWithNormalizer(): void {
$this->assertEquals(1, count($this->cache->getFolderContents('folder')));
}

public function bogusPathNamesProvider() {
public static function bogusPathNamesProvider(): array {
return [
['/bogus.txt', 'bogus.txt'],
['//bogus.txt', 'bogus.txt'],
Expand Down Expand Up @@ -691,7 +710,7 @@ public function testNoReuseOfFileId(): void {
$this->assertNotEquals($fileId, $fileId2);
}

public function escapingProvider() {
public static function escapingProvider(): array {
return [
['foo'],
['o%'],
Expand Down Expand Up @@ -807,23 +826,4 @@ public function testExtended(): void {

$this->cache->remove('sub');
}

protected function tearDown(): void {
if ($this->cache) {
$this->cache->clear();
}

parent::tearDown();
}

protected function setUp(): void {
parent::setUp();

$this->storage = new \OC\Files\Storage\Temporary([]);
$this->storage2 = new \OC\Files\Storage\Temporary([]);
$this->cache = new \OC\Files\Cache\Cache($this->storage);
$this->cache2 = new \OC\Files\Cache\Cache($this->storage2);
$this->cache->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
$this->cache2->insert('', ['size' => 0, 'mtime' => 0, 'mimetype' => ICacheEntry::DIRECTORY_MIMETYPE]);
}
}
Loading