|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2013-01-07 at 09:32:19. |
|
|
|
|
*/ |
|
|
|
@ -25,136 +26,156 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
*/ |
|
|
|
|
protected function tearDown() |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function customUser() { |
|
|
|
|
return array( |
|
|
|
|
array('julio', 'montoya', 5, 'julio@example.com', 'jmontoya666', 'jmontoya666'), |
|
|
|
|
array('julio', 'montoya', 5, 'julio@example.com', 'jmontoya777', 'jmontoya777') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('Sam','Gamegie',5,'sam@example.com','jo','jo') > 1. |
|
|
|
|
* Generated from @assert ('') === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
* @covers UserManager::is_username_available |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user() |
|
|
|
|
public function testIs_username_available() |
|
|
|
|
{ |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, |
|
|
|
|
UserManager::create_user('Sam','Gamegie',5,'sam@example.com','jo','jo') |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::is_username_available('') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$unique_id = uniqid(); |
|
|
|
|
$this->assertSame( |
|
|
|
|
true, UserManager::is_username_available($unique_id) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('Pippin','Took',null,null,'jo','jo') === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
* @depends testIs_username_available |
|
|
|
|
*/ |
|
|
|
|
public function testCreate_user2() |
|
|
|
|
public function testIs_username_available2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::create_user('Pippin','Took',null,null,'jo','jo') |
|
|
|
|
true, UserManager::is_username_available('jmontoya666') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert (null) === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::can_delete_user |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
* @depends testIs_username_available2 |
|
|
|
|
*/ |
|
|
|
|
/* |
|
|
|
|
public function testCan_delete_user() |
|
|
|
|
public function testCreate_user() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::can_delete_user(null) |
|
|
|
|
$user_id = UserManager::create_user('julio', 'montoya', 5, 'julio@example.com', 'jmontoya666', 'jmontoya666'); |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, $user_id |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert (-1) === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::can_delete_user |
|
|
|
|
* @dataProvider customUser |
|
|
|
|
* @covers UserManager::create_user |
|
|
|
|
*/ |
|
|
|
|
public function testCan_delete_user2() |
|
|
|
|
public function testCreate_user2($firstname, $lastname, $status, $email, $username, $password) |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::can_delete_user(-1) |
|
|
|
|
false, UserManager::create_user($firstname, $lastname, $status, $email, $username, $password) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('abc') === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::can_delete_user |
|
|
|
|
* @covers UserManager::get_user_info |
|
|
|
|
* @depends testCreate_user2 |
|
|
|
|
*/ |
|
|
|
|
public function testCan_delete_user3() |
|
|
|
|
public function testGet_user_info() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::can_delete_user('abc') |
|
|
|
|
$user_info = UserManager::get_user_info('jmontoya666'); |
|
|
|
|
$this->assertGreaterThan( |
|
|
|
|
1, $user_info['user_id'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert (null) === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::delete_user |
|
|
|
|
*/ |
|
|
|
|
public function testDelete_user() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_user(null) |
|
|
|
|
false, UserManager::delete_user(null) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_user('abc') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_users(-1) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_users(array(-1)) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$this->assertSame( |
|
|
|
|
false, UserManager::delete_users(null) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('abc') === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::delete_user |
|
|
|
|
* @depends testGet_user_info |
|
|
|
|
*/ |
|
|
|
|
public function testDelete_user2() |
|
|
|
|
{ |
|
|
|
|
$user_info = UserManager::get_user_info('jmontoya666'); |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_user('abc') |
|
|
|
|
false, UserManager::delete_user($user_info['user_id']) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert (null) === false. |
|
|
|
|
* Generated from @assert (-1) === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::delete_users |
|
|
|
|
* @covers UserManager::can_delete_user |
|
|
|
|
*/ |
|
|
|
|
public function testDelete_users() |
|
|
|
|
public function testCan_delete_user2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_users(null) |
|
|
|
|
false, UserManager::can_delete_user(-1) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert (-1) === false. |
|
|
|
|
* Generated from @assert ('abc') === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::delete_users |
|
|
|
|
* @covers UserManager::can_delete_user |
|
|
|
|
*/ |
|
|
|
|
public function testDelete_users2() |
|
|
|
|
public function testCan_delete_user3() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_users(-1) |
|
|
|
|
false, UserManager::can_delete_user('abc') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert (array(-1)) === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::delete_users |
|
|
|
|
* @depends testDelete_user |
|
|
|
|
*/ |
|
|
|
|
public function testDelete_users3() |
|
|
|
|
public function testDelete_users2() |
|
|
|
|
{ |
|
|
|
|
$new_user_id = UserManager::create_user('julio', 'montoya', STUDENT, 'julio@example.com', 'jmontoya666', 'jmontoya'); |
|
|
|
|
UserManager::delete_user($new_user_id); |
|
|
|
|
$user_info = api_get_user_info($new_user_id); |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::delete_users(array(-1)) |
|
|
|
|
false, $user_info |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -166,8 +187,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testDeactivate_users() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::deactivate_users(null) |
|
|
|
|
false, UserManager::deactivate_users(null) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -179,8 +199,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testDeactivate_users2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::deactivate_users(array(-1)) |
|
|
|
|
false, UserManager::deactivate_users(array(-1)) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -192,8 +211,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testActivate_users() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::activate_users(null) |
|
|
|
|
false, UserManager::activate_users(null) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -205,8 +223,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testActivate_users2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::activate_users(array(-1)) |
|
|
|
|
false, UserManager::activate_users(array(-1)) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -218,8 +235,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testUpdate_openid() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::update_openid(false,'') |
|
|
|
|
false, UserManager::update_openid(false, '') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -231,8 +247,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testUpdate_openid2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::update_openid(-1,'') |
|
|
|
|
false, UserManager::update_openid(-1, '') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -244,8 +259,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testUpdate_user() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::update_user(false) |
|
|
|
|
false, UserManager::update_user(false) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -257,8 +271,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testDisable() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::disable(0) |
|
|
|
|
false, UserManager::disable(0) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -270,8 +283,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testEnable() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::enable(0) |
|
|
|
|
false, UserManager::enable(0) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -283,36 +295,11 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testGet_user_id_from_original_id() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
0, |
|
|
|
|
UserManager::get_user_id_from_original_id('0','---') |
|
|
|
|
0, UserManager::get_user_id_from_original_id('0', '---') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('') === false. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::is_username_available |
|
|
|
|
*/ |
|
|
|
|
public function testIs_username_available() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::is_username_available('') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('xyzxyzxyz') === true. |
|
|
|
|
* |
|
|
|
|
* @covers UserManager::is_username_available |
|
|
|
|
*/ |
|
|
|
|
public function testIs_username_available2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
true, |
|
|
|
|
UserManager::is_username_available('xyzxyzxyz') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Generated from @assert ('','') === false. |
|
|
|
@ -322,8 +309,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testCreate_username() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
false, |
|
|
|
|
UserManager::create_username('','') |
|
|
|
|
'user', UserManager::create_username('', '') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -335,8 +321,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
public function testCreate_username2() |
|
|
|
|
{ |
|
|
|
|
$this->assertSame( |
|
|
|
|
'ab', |
|
|
|
|
UserManager::create_username('a','b') |
|
|
|
|
'ab', UserManager::create_username('a', 'b') |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -448,17 +433,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 |
|
|
|
@ -1148,7 +1122,7 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
* @covers UserManager::get_user_id_of_course_admin_or_session_admin |
|
|
|
|
* @todo Implement testGet_user_id_of_course_admin_or_session_admin(). |
|
|
|
|
*/ |
|
|
|
|
/* |
|
|
|
|
/* |
|
|
|
|
public function testGet_user_id_of_course_admin_or_session_admin() |
|
|
|
|
{ |
|
|
|
|
// Remove the following lines when you implement this test. |
|
|
|
@ -1156,7 +1130,8 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
'This test has not been implemented yet.' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @covers UserManager::is_user_certified |
|
|
|
|
* @todo Implement testIs_user_certified(). |
|
|
|
@ -1288,4 +1263,5 @@ class UserManagerTest extends PHPUnit_Framework_TestCase |
|
|
|
|
'This test has not been implemented yet.' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|