move private key generation to adduser
This commit is contained in:
parent
9eab02af5f
commit
d2aecd8a76
1 changed files with 19 additions and 14 deletions
|
@ -76,17 +76,18 @@ class TestBase extends PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* Creates a new user in the database.
|
* Creates a new user in the database.
|
||||||
*
|
*
|
||||||
* @param string $username Username
|
* @param string $username Username
|
||||||
* @param string $password Password
|
* @param string $password Password
|
||||||
* @param string $pkey Private Key
|
* @param mixed $privateKey String private key or boolean true to generate one
|
||||||
*
|
*
|
||||||
* @return integer ID of user
|
* @return integer ID of user
|
||||||
*
|
*
|
||||||
* @uses addUserData()
|
* @uses addUserData()
|
||||||
*/
|
*/
|
||||||
protected function addUser($username = null, $password = null, $pkey = null)
|
protected function addUser(
|
||||||
{
|
$username = null, $password = null, $privateKey = null
|
||||||
return reset($this->addUserData($username, $password, $pkey));
|
) {
|
||||||
|
return reset($this->addUserData($username, $password, $privateKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -94,14 +95,15 @@ class TestBase extends PHPUnit_Framework_TestCase
|
||||||
/**
|
/**
|
||||||
* Creates a new user in the database and returns id, username and password.
|
* Creates a new user in the database and returns id, username and password.
|
||||||
*
|
*
|
||||||
* @param string $username Username
|
* @param string $username Username
|
||||||
* @param string $password Password
|
* @param string $password Password
|
||||||
* @param string $pkey Private Key
|
* @param mixed $privateKey String private key or boolean true to generate one
|
||||||
*
|
*
|
||||||
* @return array ID of user, Name of user, password of user
|
* @return array ID of user, Name of user, password of user, privatekey
|
||||||
*/
|
*/
|
||||||
protected function addUserData($username = null, $password = null, $pkey = null)
|
protected function addUserData(
|
||||||
{
|
$username = null, $password = null, $privateKey = null
|
||||||
|
) {
|
||||||
$us = SemanticScuttle_Service_Factory::get('User');
|
$us = SemanticScuttle_Service_Factory::get('User');
|
||||||
$rand = rand();
|
$rand = rand();
|
||||||
|
|
||||||
|
@ -111,14 +113,17 @@ class TestBase extends PHPUnit_Framework_TestCase
|
||||||
if ($password === null) {
|
if ($password === null) {
|
||||||
$password = $rand;
|
$password = $rand;
|
||||||
}
|
}
|
||||||
|
if ($privateKey === true) {
|
||||||
|
$privateKey = $this->us->getNewPrivateKey();
|
||||||
|
}
|
||||||
|
|
||||||
$uid = $us->addUser(
|
$uid = $us->addUser(
|
||||||
$username,
|
$username,
|
||||||
$password,
|
$password,
|
||||||
'unittest-' . $rand . '@example.org',
|
'unittest-' . $rand . '@example.org',
|
||||||
$pkey
|
$privateKey
|
||||||
);
|
);
|
||||||
return array($uid, $username, $password);
|
return array($uid, $username, $password, $privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue