aboutsummaryrefslogtreecommitdiff
path: root/tests/TestBase.php
diff options
context:
space:
mode:
authorYalçın Can <ylcncn@gmail.com>2011-07-27 14:23:37 +0300
committerYalçın Can <ylcncn@gmail.com>2011-07-27 14:23:37 +0300
commitefd842174fdd37f8eb2c460c7adb21954bcfbe9d (patch)
treea2ab3cc25db92b901b69ce1bc0ad1dedb5d498ef /tests/TestBase.php
parent8cd40b3d76e191b2fbe95b044f69aed07cc27664 (diff)
parent81aa17b8523d95310c90366d9af09767db0c84f2 (diff)
downloadsemanticscuttle-efd842174fdd37f8eb2c460c7adb21954bcfbe9d.tar.gz
semanticscuttle-efd842174fdd37f8eb2c460c7adb21954bcfbe9d.tar.bz2
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'tests/TestBase.php')
-rw-r--r--tests/TestBase.php34
1 files changed, 21 insertions, 13 deletions
diff --git a/tests/TestBase.php b/tests/TestBase.php
index 095f32d..2914749 100644
--- a/tests/TestBase.php
+++ b/tests/TestBase.php
@@ -76,16 +76,18 @@ class TestBase extends PHPUnit_Framework_TestCase
/**
* Creates a new user in the database.
*
- * @param string $username Username
- * @param string $password Password
+ * @param string $username Username, may be null
+ * @param string $password Password, may be null
+ * @param mixed $privateKey String private key or boolean true to generate one
*
* @return integer ID of user
*
* @uses addUserData()
*/
- protected function addUser($username = null, $password = null)
- {
- return reset($this->addUserData($username, $password));
+ protected function addUser(
+ $username = null, $password = null, $privateKey = null
+ ) {
+ return reset($this->addUserData($username, $password, $privateKey));
}
@@ -93,13 +95,15 @@ class TestBase extends PHPUnit_Framework_TestCase
/**
* Creates a new user in the database and returns id, username and password.
*
- * @param string $username Username
- * @param string $password Password
+ * @param string $username Username, may be null
+ * @param string $password Password, may be null
+ * @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)
- {
+ protected function addUserData(
+ $username = null, $password = null, $privateKey = null
+ ) {
$us = SemanticScuttle_Service_Factory::get('User');
$rand = rand();
@@ -109,13 +113,17 @@ class TestBase extends PHPUnit_Framework_TestCase
if ($password === null) {
$password = $rand;
}
+ if ($privateKey === true) {
+ $privateKey = $this->us->getNewPrivateKey();
+ }
$uid = $us->addUser(
$username,
$password,
- 'unittest-' . $rand . '@example.org'
+ 'unittest-' . $rand . '@example.org',
+ $privateKey
);
- return array($uid, $username, $password);
+ return array($uid, $username, $password, $privateKey);
}
@@ -148,4 +156,4 @@ class TestBase extends PHPUnit_Framework_TestCase
}
}
-?> \ No newline at end of file
+?>