Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
39497b9c
Commit
39497b9c
authored
May 11, 2015
by
Joas Schilling
Browse files
Add a test for parallel insert
parent
2916b0ba
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/lib/appconfig.php
View file @
39497b9c
...
@@ -113,11 +113,8 @@ class Test_Appconfig extends \Test\TestCase {
...
@@ -113,11 +113,8 @@ class Test_Appconfig extends \Test\TestCase {
* @param mixed $callable
* @param mixed $callable
*/
*/
public
function
testGetValue
(
$callable
)
{
public
function
testGetValue
(
$callable
)
{
$query
=
\
OC_DB
::
prepare
(
'SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?'
);
$result
=
$query
->
execute
(
array
(
'testapp'
,
'installed_version'
));
$expected
=
$result
->
fetchRow
();
$value
=
call_user_func
([
$callable
,
'getValue'
],
'testapp'
,
'installed_version'
);
$value
=
call_user_func
([
$callable
,
'getValue'
],
'testapp'
,
'installed_version'
);
$this
->
assert
Equals
(
$expected
[
'configvalue'
]
,
$value
);
$this
->
assert
ConfigKey
(
'testapp'
,
'installed_version'
,
$value
);
$value
=
call_user_func
([
$callable
,
'getValue'
],
'testapp'
,
'nonexistant'
);
$value
=
call_user_func
([
$callable
,
'getValue'
],
'testapp'
,
'nonexistant'
);
$this
->
assertNull
(
$value
);
$this
->
assertNull
(
$value
);
...
@@ -146,16 +143,10 @@ class Test_Appconfig extends \Test\TestCase {
...
@@ -146,16 +143,10 @@ class Test_Appconfig extends \Test\TestCase {
*/
*/
public
function
testSetValue
(
$callable
)
{
public
function
testSetValue
(
$callable
)
{
call_user_func
([
$callable
,
'setValue'
],
'testapp'
,
'installed_version'
,
'1.33.7'
);
call_user_func
([
$callable
,
'setValue'
],
'testapp'
,
'installed_version'
,
'1.33.7'
);
$query
=
\
OC_DB
::
prepare
(
'SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?'
);
$this
->
assertConfigKey
(
'testapp'
,
'installed_version'
,
'1.33.7'
);
$result
=
$query
->
execute
(
array
(
'testapp'
,
'installed_version'
));
$value
=
$result
->
fetchRow
();
$this
->
assertEquals
(
'1.33.7'
,
$value
[
'configvalue'
]);
call_user_func
([
$callable
,
'setValue'
],
'someapp'
,
'somekey'
,
'somevalue'
);
call_user_func
([
$callable
,
'setValue'
],
'someapp'
,
'somekey'
,
'somevalue'
);
$query
=
\
OC_DB
::
prepare
(
'SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?'
);
$this
->
assertConfigKey
(
'someapp'
,
'somekey'
,
'somevalue'
);
$result
=
$query
->
execute
(
array
(
'someapp'
,
'somekey'
));
$value
=
$result
->
fetchRow
();
$this
->
assertEquals
(
'somevalue'
,
$value
[
'configvalue'
]);
}
}
/**
/**
...
@@ -276,4 +267,30 @@ class Test_Appconfig extends \Test\TestCase {
...
@@ -276,4 +267,30 @@ class Test_Appconfig extends \Test\TestCase {
$appconfig
->
setValue
(
'bar'
,
'foo'
,
'v2'
);
$appconfig
->
setValue
(
'bar'
,
'foo'
,
'v2'
);
$appconfig
->
setValue
(
'bar'
,
'foo'
,
'v2'
);
$appconfig
->
setValue
(
'bar'
,
'foo'
,
'v2'
);
}
}
public
function
testSettingConfigParallel
()
{
$appConfig1
=
new
OC\AppConfig
(
\
OC
::
$server
->
getDatabaseConnection
());
$appConfig2
=
new
OC\AppConfig
(
\
OC
::
$server
->
getDatabaseConnection
());
$appConfig1
->
getValue
(
'testapp'
,
'foo'
,
'v1'
);
$appConfig2
->
getValue
(
'testapp'
,
'foo'
,
'v1'
);
$appConfig1
->
setValue
(
'testapp'
,
'foo'
,
'v1'
);
$this
->
assertConfigKey
(
'testapp'
,
'foo'
,
'v1'
);
$appConfig2
->
setValue
(
'testapp'
,
'foo'
,
'v2'
);
$this
->
assertConfigKey
(
'testapp'
,
'foo'
,
'v2'
);
}
/**
* @param string $app
* @param string $key
* @param string $expected
* @throws \OC\DatabaseException
*/
protected
function
assertConfigKey
(
$app
,
$key
,
$expected
)
{
$query
=
\
OC_DB
::
prepare
(
'SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?'
);
$result
=
$query
->
execute
([
$app
,
$key
]);
$actual
=
$result
->
fetchRow
();
$this
->
assertEquals
(
$expected
,
$actual
[
'configvalue'
]);
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment