public function getTestUser() { if (self::$user instanceof User) { return self::$user; } return self::$user = User::find(1); }
public static function setUpBeforeClass() { $adminUsername = getenv('jasmin_admin_username') ?: 'jcliadmin'; $adminPassword = getenv('jasmin_admin_password') ?: 'jclipwd'; $adminHost = getenv('jasmin_admin_host') ?: '127.0.0.1'; $adminPort = getenv('jasmin_admin_port') ?: 8990; self::$telnetConnector = JasminConnector::init($adminUsername, $adminPassword, $adminHost, $adminPort); $groupManager = new \JasminWeb\Jasmin\Group(self::$telnetConnector); $groupManager->setId('test_new_one'); $groupManager->delete(); $groupManager->setId('test_exist'); $groupManager->save(); $userManager = new \JasminWeb\Jasmin\User(self::$telnetConnector); $userManager->setId('test_not_exist'); $userManager->delete(); $userManager->setId('test_new_one'); $userManager->delete(); $userManager->setId('test_exist'); $userManager->delete(); $userManager->setId('test_exist'); $userManager->attributes['username'] = '******'; $userManager->attributes['password'] = '******'; $userManager->attributes['gid'] = 'test_exist'; $userManager->add(); }
public static function setUpBeforeClass() { // Comment the next lines out to test the connect/close methods $db_params = get_db_params_from_config(); self::$conn = new DBConnection($db_params); self::$conn->connect(); }
public static function setUpBeforeClass() { if (file_exists(__DIR__ . "/../.env")) { $dotenv = new Dotenv\Dotenv(__DIR__ . "/../"); $dotenv->load(); } self::$instagram = new \marvinosswald\Instagram\Instagram(['accessToken' => getenv('INSTAGRAM_ACCESS_TOKEN')]); }
/** * 1. create user A then create group A * 3. create user B, join the group, user A quit the group * 4. delete group & created users */ public function testChatroom() { $userTest = new UserTest(); $userOne = $userTest->createUser(); $group = $this->createGroup($userOne, Group::TYPE_CHATROOM); $this->listGroups($group, $userOne, GroupUser::STATUS_AGREE); $this->listUsers($group->id, null, $userOne); $group = $this->updateGroup($userOne, $group); $userTwo = $userTest->createUser(); $this->joinGroup($userTwo, $group); $this->listGroups($group, $userTwo, GroupUser::STATUS_AGREE); $this->listUsers($group->id, null, $userTwo); $this->quitGroup($userTwo, $group); $this->quitGroup($userOne, $group); $userTest->deleteUser($userOne); $userTest->deleteUser($userTwo); }
/** * 1. create two user * 2. a user ask for b to make friend * 3. b user agree this ask * 4. get friends for a, check whether there is b;get friends for b, check whether there is a * 5. a create group named 'a new group', then move b to this group, and update group name, then delete this group * 6. delete two user and there relations */ public function testRoster() { // 1 $userTest = new UserTest(); $userOne = $userTest->createUser(); $userTwo = $userTest->createUser(); // 2 $rosterA = $this->requestForFriend($userOne, $userTwo); //3 $this->receiveRequest($userTwo, $userOne); // 4 $resp = $this->request('/api/roster/list', ['uid' => $userOne->id, 'token' => $userOne->token, 'status' => Roster::STATUS_AGREE]); $this->assertResponseNotEmptyList($resp); $rosters = $this->getResponseBody($resp); $found = false; foreach ($rosters as $r) { if ($r['target_id'] == $userTwo->id) { $found = true; break; } } self::assertTrue($found); // 5 $resp = $this->request('/api/roster/create_group', ['uid' => $userOne->id, 'token' => $userOne->token, 'name' => 'a new group', 'rank' => 1], true); $this->assertRequestSuccess($resp); $groupRoster = ConvertUtil::arrayToObject($this->getResponseBody($resp), new RosterGroup(), ['group_id' => 'id', 'name', 'uid', 'rank']); RosterManager::getInstance()->getRoster($rosterA); $resp = $this->request('/api/roster/update', ['uid' => $userOne->id, 'token' => $userOne->token, 'target_id' => $userTwo->id, 'status' => $rosterA->status, 'remark' => 'updated remark', 'group_id' => $groupRoster->id, 'rank' => 0], true); $this->assertRequestSuccess($resp); $resp = $this->request('/api/roster/update_group', ['uid' => $userOne->id, 'token' => $userOne->token, 'group_id' => $groupRoster->id, 'name' => 'a updated name', 'rank' => 2], true); $this->assertRequestSuccess($resp); $this->assertRequestSuccess($this->request('/api/roster/delete_group', ['uid' => $userOne->id, 'token' => $userOne->token, 'group_id' => $groupRoster->id], true)); // 6 $userTest->deleteUser($userOne); $userTest->deleteUser($userTwo); RosterManager::getInstance()->deleteRoster($rosterA); }
public function testRegisterUser() { self::$user = User::registerUser(['user_email' => '*****@*****.**', 'username' => 'testexample', 'user_password' => ['testpassword', 'testpassword'], 'ip' => '127.0.0.1', 'fb_posts' => 10]); $this->assertInstanceOf('app\\users\\models\\User', self::$user); $this->assertGreaterThan(0, self::$user->id()); }
public static function tearDownAfterClass() { self::$user = null; }
public static function setUpBeforeClass() { self::$master = DirectAdmin::connectAdmin(DIRECTADMIN_URL, MASTER_ADMIN_USERNAME, MASTER_ADMIN_PASSWORD); $ips = self::$master->getIPs(); self::$user = self::$master->createUser(USER_USERNAME, USER_PASSWORD, TEST_EMAIL, TEST_USER_DOMAIN, $ips[0]); }
/** * Returns the static model of the specified AR class. * Please note that you should have this exact method in all your CActiveRecord descendants! * @param string $className active record class name. * @return WUserTest the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if ($_GET['group_id'] == 1) { //check exist course and test created by a trainer if (Course::model()->checkCourse($id) && Test::model()->checkTest($id)) { Yii::app()->user->setFlash('unsuccess', ' Can not delete a trainer.'); $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin', 'group_id' => $_GET['group_id'])); } // delete trainer $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { Yii::app()->user->setFlash('success', 'You did delete a trainer when: <br>- Not exist course created by trainer.<br>- Not exist test created by trainer.'); $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin', 'group_id' => $_GET['group_id'])); } } elseif ($_GET['group_id'] == 2) { //Delete course trainee CourseTrainee::model()->deleteCourseTrainee($id); //Delete user test UserTest::model()->deleteUserTest($id); //Delete training log and training random question TrainingLog::model()->deleteTrainingLog($id); TrainingRandomquestion::model()->deleteTrainingRadomQuestion($id); //delete trainee $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser Yii::app()->user->setFlash('success', 'You did delete a trainee: <br>- Delete course trainee.<br>- Delete Training log and training random question.<br>- Delete user test and user answers.'); if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin', 'group_id' => $_GET['group_id'])); } } elseif ($_GET['group_id'] == 3) { // delete training manager $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser Yii::app()->user->setFlash('success', 'You did delete a training manager.'); if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin', 'group_id' => $_GET['group_id'])); } } elseif ($_GET['group_id'] == 4) { // delete team leader ATrainingTeam::deleteTeamleader($id); $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser Yii::app()->user->setFlash('success', 'You did delete a team leader.'); if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin', 'group_id' => $_GET['group_id'])); } } }
<?php require_once '../de/appwerk/radio/Session.php'; require_once '../de/appwerk/radio/RoleUtils.php'; require_once '../de/appwerk/radio/test/UserTest.php'; require_once '../de/appwerk/radio/test/RootDBUtilsTest.php'; require_once '../de/appwerk/radio/test/WebDBUtilsTest.php'; require_once '../de/appwerk/radio/test/RoleUtilsTest.php'; require_once '../de/appwerk/radio/test/AdsUtilsTest.php'; $ut = new UserTest(); $at = new AdsUtilsTest(); $session = Session::getInstance(); $l = readline('Are you sure you want to reset the DB?' . PHP_EOL); $l = readline('Reset the DB?' . PHP_EOL); if ('yyy' != $l) { print 'Never reset the DB.' . PHP_EOL; exit(1); } $rootDBUtilsTest = new RootDBUtilsTest(); $rootDBUtilsTest->setupWebDBUser(); $rootDBUtilsTest->setupUserDB(); $rootDBUtilsTest->setupPlaylistDB(); $rootDBUtilsTest->setupStreamDB(); $rootDBUtilsTest->setupWebDBUserRights(); $roleUtilsTest = new RoleUtilsTest(); $roleUtilsTest->addRoles(); RoleUtils::getInstance()->load(); $webDBUtilsTest = new WebDBUtilsTest(); $webDBUtilsTest->addMockUser('*****@*****.**', 'admin'); $webDBUtilsTest->linkMockUser('*****@*****.**', RoleUtils::ADMIN); $webDBUtilsTest->linkMockUser('*****@*****.**', RoleUtils::TENANT);
} catch (Exception $e) { return array('Exception!! ' => $e->getMessage()); } } function LoadUser($data, $fields) { try { $User = new Users(); $result = $User->load($fields['USR_UID']); return $result; } catch (Exception $e) { return array('Exception!! ' => $e->getMessage()); } } function RemoveUser($data, $fields) { try { $User = new Users(); $result = $User->remove($fields['USR_UID']); return $result; } catch (Exception $e) { return array('Exception!! ' => $e->getMessage()); } } } $test = new UserTest('user.yml', $t); $test->domain->addDomain('CREATED'); $test->load('CreateTestUsers'); $test->runAll(); $test->load('UserUnitTest'); $test->runAll();
public function testGetPrimaryKey() { $this->assertEquals('uuid', UserTest::getPrimaryKey()); }
<?php require_once '../de/appwerk/radio/test/UserTest.php'; $ut = new UserTest(); $ut->addFacebookID(); $ut->setFacebookID(); $ut->getUserByFacebookID(); $ut->httpAuth(); $ut->auth(); $ut->getBucket(); $ut->registerStream(); $ut->getStream(); $ut->linkRoleTenant('*****@*****.**'); $ut->linkRoleIds(); $ut->loadRoles(); $ut->can(); $ut->getProfileImgPath(); $ut->getOauthURL(); exit(1);
{ $query = $this->db->prepare("UPDATE {$this->table} SET name =:name, email=:email WHERE user_id=:user_id"); $query->bindParam(':name', $name); $query->bindParam(':email', $email); $query->bindParam(':user_id', $user_id); $query->execute(); } function delete($email, $user_id) { $query = $this->db->prepare("DELETE FROM {$this->table} WHERE email=:email AND user_id=:user_id"); $query->bindParam(':email', $email); $query->bindParam(':user_id', $user_id); $query->execute(); } function createUserDir($email) { $query = $this->db->prepare("SELECT user_id FROM {$this->table} WHERE email=:email"); $query->bindParam(':email', $email); $query->execute(); $result = $query->fetch(PDO::FETCH_ASSOC); $path = "testuser/" . $result['user_id'] . "/img"; if (!file_exists($path)) { mkdir($path, 0777, true); echo "dir created"; } else { echo "error "; } } } $user = new UserTest(); $user->createUserDir('*****@*****.**');
public static function setUpBeforeClass() { self::$userTest = "test-smsapi-client"; }
public function test_add_to_group() { $this->mark_test_incomplete(); } public function test_remove_from_group() { $this->mark_test_incomplete(); } public function test_get_info() { $this->mark_test_incomplete(); } public function test_get_url_args() { $this->mark_test_incomplete(); } public function teardown() { $this->user->delete(); } } UserTest::run_one('UserTest'); ?>
public function testRegisterUser() { self::$user = User::registerUser(['first_name' => 'Bob', 'last_name' => 'Loblaw', 'user_email' => '*****@*****.**', 'user_password' => ['testpassword', 'testpassword'], 'ip' => '127.0.0.1']); $this->assertInstanceOf('\\app\\users\\models\\User', self::$user); $this->assertGreaterThan(0, self::$user->id()); }