|
|
|
|
@ -3,8 +3,9 @@ |
|
|
|
|
/** |
|
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2013-01-07 at 09:32:19. |
|
|
|
|
*/ |
|
|
|
|
class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
class UserManagerTest extends BaseWebTestCase |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @var UserManager |
|
|
|
|
*/ |
|
|
|
|
@ -14,22 +15,26 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
|
|
|
* This method is called before a test is executed. |
|
|
|
|
*/ |
|
|
|
|
protected function setUp() |
|
|
|
|
public function setUp() |
|
|
|
|
{ |
|
|
|
|
require_once dirname(__FILE__).'/../../../main/inc/global.inc.php'; |
|
|
|
|
$this->object = new UserManager; |
|
|
|
|
parent::setUp(); |
|
|
|
|
$this->obj = $this->app['usermanager']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
|
|
|
* This method is called after a test is executed. |
|
|
|
|
*/ |
|
|
|
|
protected function tearDown() |
|
|
|
|
public function tearDown() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function customUser() { |
|
|
|
|
/** |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function customUser() |
|
|
|
|
{ |
|
|
|
|
$unique_id = uniqid(); |
|
|
|
|
return array( |
|
|
|
|
array('julio', 'montoya', 5, 'julio@example.com', 'jmontoya1_'.$unique_id, 'jmontoya1_'.$unique_id), |
|
|
|
|
@ -38,67 +43,63 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('Sam','Gamegie',5,'sam@example.com','jo','jo') > 1. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
* @depends testIsUsernameAvailableFlow |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user() |
|
|
|
|
public function testCreateUser() |
|
|
|
|
{ |
|
|
|
|
$user_id = UserManager::create_user('julio', 'montoya', 5, 'julio@example.com', 'jmontoya666', 'jmontoya666'); |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, |
|
|
|
|
UserManager::create_user('Sam','Gamgee',5,'sam@example.com','jo','jo') |
|
|
|
|
$user_id |
|
|
|
|
); |
|
|
|
|
return $user_id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('Pippin','Took',null,null,'jo','jo') === false. |
|
|
|
|
* |
|
|
|
|
* @dataProvider customUser |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user2() |
|
|
|
|
public function testCreateUser2($firstname, $lastname, $status, $email, $username, $password) |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::create_user('Pippin','Brandybuck',null,null,'jo','jo') |
|
|
|
|
|
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, |
|
|
|
|
$this->obj->create_user($firstname, $lastname, $status, $email, $username, $password) |
|
|
|
|
); |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Test multiple URL case with users hosting limit |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user3() |
|
|
|
|
public function testIsUsernameAvailableFlow() |
|
|
|
|
{ |
|
|
|
|
global $_configuration; |
|
|
|
|
$_configuration[1]['hosting_limit_users'] = 50; |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::create_user('Merry','Brandybuck',null,null,'jo','jo') |
|
|
|
|
true, |
|
|
|
|
UserManager::is_username_available('jmontoya666') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::is_username_available |
|
|
|
|
* Test multiple URL case with users hosting limit |
|
|
|
|
*/ |
|
|
|
|
public function testIs_username_available() |
|
|
|
|
public function testCreateUser3() |
|
|
|
|
{ |
|
|
|
|
$this->app['configuration'][1]['hosting_limit_users'] = 50; |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::is_username_available('') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$unique_id = uniqid(); |
|
|
|
|
$this->assertSame( |
|
|
|
|
true, UserManager::is_username_available($unique_id) |
|
|
|
|
false, |
|
|
|
|
UserManager::create_user('Merry', 'Brandybuck', null, null, 'jo', 'jo') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Test teachers hosting limit |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user4() |
|
|
|
|
public function testCreateUser4() |
|
|
|
|
{ |
|
|
|
|
global $_configuration; |
|
|
|
|
$_configuration[1]['hosting_limit_teachers'] = 50; |
|
|
|
|
$this->app['configuration'][1]['hosting_limit_teachers'] = 50; |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::create_user('Pippin', 'Took', 1, null, 'jo', 'jo') |
|
|
|
|
@ -108,9 +109,8 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
/** |
|
|
|
|
* Test language non-existence |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user5() |
|
|
|
|
public function testCreateUser5() |
|
|
|
|
{ |
|
|
|
|
global $_configuration; |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::create_user('Pippin', 'Tooky', null, null, 'jo', 'jo', null, 'spaniard') |
|
|
|
|
@ -118,54 +118,37 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testIs_username_available |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::is_username_available |
|
|
|
|
*/ |
|
|
|
|
public function testIs_username_available2() |
|
|
|
|
public function testIsUsernameAvailable() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
true, UserManager::is_username_available('jmontoya666') |
|
|
|
|
false, |
|
|
|
|
UserManager::is_username_available('') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
* @depends testIs_username_available2 |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user() |
|
|
|
|
{ |
|
|
|
|
$user_id = UserManager::create_user('julio', 'montoya', 5, 'julio@example.com', 'jmontoya666', 'jmontoya666'); |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, $user_id |
|
|
|
|
$unique_id = uniqid(); |
|
|
|
|
$this->assertSame( |
|
|
|
|
true, |
|
|
|
|
UserManager::is_username_available($unique_id) |
|
|
|
|
); |
|
|
|
|
return $user_id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @covers UserManager::get_user_info_by_id |
|
|
|
|
* @depends testCreate_user |
|
|
|
|
* @depends testCreateUser |
|
|
|
|
*/ |
|
|
|
|
public function testGet_user_info_by_id($user_id) |
|
|
|
|
{ |
|
|
|
|
$user_info = UserManager::get_user_info_by_id($user_id); |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, $user_info['user_id'] |
|
|
|
|
); |
|
|
|
|
$this->assertGreaterThan(1, $user_info['user_id']); |
|
|
|
|
return $user_info; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @dataProvider customUser |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user2($firstname, $lastname, $status, $email, $username, $password) |
|
|
|
|
{ |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, UserManager::create_user($firstname, $lastname, $status, $email, $username, $password) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @covers UserManager::get_user_info |
|
|
|
|
@ -175,7 +158,8 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
{ |
|
|
|
|
$user_info = UserManager::get_user_info($user_info['username']); |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, $user_info['user_id'] |
|
|
|
|
1, |
|
|
|
|
$user_info['user_id'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -185,34 +169,40 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testDelete_user() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_user(null) |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_user(null) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_user('abc') |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_user('abc') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_users(-1) |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_users(-1) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_users(array(-1)) |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_users(array(-1)) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_users(null) |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_users(null) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @depends testCreate_user |
|
|
|
|
* @depends testCreateUser |
|
|
|
|
*/ |
|
|
|
|
public function testDelete_user2() |
|
|
|
|
{ |
|
|
|
|
$user_info = UserManager::get_user_info('jmontoya666'); |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_user($user_info['user_id']) |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_user($user_info['user_id']) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -341,9 +331,24 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
*/ |
|
|
|
|
public function testUpdate_user() |
|
|
|
|
{ |
|
|
|
|
var_dump($this->app);exit; |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::update_user(false,false,false,false,false,false,false,false,false,false,false,false,false) |
|
|
|
|
UserManager::update_user( |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false, |
|
|
|
|
false |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -417,7 +422,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::create_username |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_username() |
|
|
|
|
public function testCreateUsername() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
@ -430,7 +435,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::create_username |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_username2() |
|
|
|
|
public function testCreateUsername2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
'ab', |
|
|
|
|
@ -546,30 +551,6 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @covers UserManager::get_user_info |
|
|
|
|
* @todo Implement testGet_user_info(). |
|
|
|
|
*/ |
|
|
|
|
public function testGet_user_info() |
|
|
|
|
{ |
|
|
|
|
// Remove the following lines when you implement this test. |
|
|
|
|
$this->markTestIncomplete( |
|
|
|
|
'This test has not been implemented yet.' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @covers UserManager::get_user_info_by_id |
|
|
|
|
* @todo Implement testGet_user_info_by_id(). |
|
|
|
|
*/ |
|
|
|
|
public function testGet_user_info_by_id() |
|
|
|
|
{ |
|
|
|
|
// Remove the following lines when you implement this test. |
|
|
|
|
$this->markTestIncomplete( |
|
|
|
|
'This test has not been implemented yet.' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @covers UserManager::get_teacher_list |
|
|
|
|
* @todo Implement testGet_teacher_list(). |
|
|
|
|
|