Bladeren bron

fix(config): Make sure user keys are strings

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
tags/v29.0.0beta5
Christoph Wurst 3 maanden geleden
bovenliggende
commit
b8868e2652
No account linked to committer's email address
2 gewijzigde bestanden met toevoegingen van 26 en 1 verwijderingen
  1. 1
    1
      lib/private/AllConfig.php
  2. 25
    0
      tests/lib/AllConfigTest.php

+ 1
- 1
lib/private/AllConfig.php Bestand weergeven

public function getUserKeys($userId, $appName) { public function getUserKeys($userId, $appName) {
$data = $this->getAllUserValues($userId); $data = $this->getAllUserValues($userId);
if (isset($data[$appName])) { if (isset($data[$appName])) {
return array_keys($data[$appName]);
return array_map('strval', array_keys($data[$appName]));
} else { } else {
return []; return [];
} }

+ 25
- 0
tests/lib/AllConfigTest.php Bestand weergeven

$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`'); $this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
} }


public function testGetUserKeysAllInts() {
$config = $this->getConfig();

// preparation - add something to the database
$data = [
['userFetch', 'appFetch1', '123', 'value'],
['userFetch', 'appFetch1', '456', 'value'],
];
foreach ($data as $entry) {
$this->connection->executeUpdate(
'INSERT INTO `*PREFIX*preferences` (`userid`, `appid`, ' .
'`configkey`, `configvalue`) VALUES (?, ?, ?, ?)',
$entry
);
}

$value = $config->getUserKeys('userFetch', 'appFetch1');
$this->assertEquals(['123', '456'], $value);
$this->assertIsString($value[0]);
$this->assertIsString($value[1]);

// cleanup
$this->connection->executeUpdate('DELETE FROM `*PREFIX*preferences`');
}

public function testGetUserValueDefault() { public function testGetUserValueDefault() {
$config = $this->getConfig(); $config = $this->getConfig();



Laden…
Annuleren
Opslaan