Tests: Adding users + fixing fill_all.php

skala
Julio Montoya 16 years ago
parent de0d2ae6f7
commit e46110cb39
  1. 110
      tests/datafiller/data_users.php
  2. 13
      tests/datafiller/fill_all.php
  3. 8
      tests/datafiller/fill_users.php

@ -43,8 +43,116 @@ $users[] = array(
'email' => 'michel.lanoix@testdokeos.com',
'status' => 1,
'creator_id' => 1,
'active' => 1,
'active' => 1
);
$users[] = array(
'username' => 'jmontoya',
'pass' => 'jmontoya',
'firstname' => 'Julio',
'lastname' => 'Montoya',
'status' => 1,
'auth_source' => 'platform',
'email' => 'julio.montoya@beeznest.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array(
'username' => 'agarcia',
'pass' => 'agarcia',
'firstname' => 'Alan',
'lastname' => 'Garcia',
'status' => 1,
'auth_source' => 'platform',
'email' => 'agarcia@example.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array(
'username' => 'pperez',
'pass' => 'pperez',
'firstname' => 'Pedro',
'lastname' => 'Perez',
'status' => 5,
'auth_source' => 'platform',
'email' => 'pperez@example.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array(
'username' => 'ggomez',
'pass' => 'ggomez',
'firstname' => 'Gabriela',
'lastname' => 'Gomez',
'status' => 5,
'auth_source' => 'platform',
'email' => 'ggomez@example.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array(
'username' => 'norizales',
'pass' => 'norizales',
'firstname' => 'Noa',
'lastname' => 'Orizales',
'status' => 5,
'auth_source' => 'platform',
'email' => 'norizales@example.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array(
'username' => 'jbrion',
'pass' => 'jbrion',
'firstname' => 'Jon',
'lastname' => 'Brion',
'status' => 5,
'auth_source' => 'platform',
'email' => 'jbrion@example.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array(
'username' => 'fapple',
'pass' => 'fapple',
'firstname' => 'Fiona',
'lastname' => 'Apple Maggart',
'status' => 5,
'auth_source' => 'platform',
'email' => 'fapple@example.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array(
'username' => 'acalabaza',
'pass' => 'acalabaza',
'firstname' => 'Aldo',
'lastname' => 'Calabaza',
'status' => 5,
'auth_source' => 'platform',
'email' => 'acalabaza@example.com',
'creator_id' => 1,
'active' => 1
);
$users[] = array('username' => 'mhalles','pass' => 'mhalles','firstname' => 'Maria','lastname' => 'Halles','status' => 5,'auth_source' => 'platform','email' => 'mhalles@example.com','creator_id' => 1,'active' => 1);
$users[] = array('username' => 'adaniel','pass' => 'adaniel','firstname' => 'Annaa','lastname' => 'Daniel','status' => 5,'auth_source' => 'platform','email' => 'adaniel@example.com','creator_id' => 1,'active' => 1);
$users[] = array('username' => 'ppiedra','pass' => 'ppiedra','firstname' => 'Pirot','lastname' => 'Piedra','status' => 5,'auth_source' => 'platform','email' => 'ppiedra@example.com','creator_id' => 1,'active' => 1);
$users[] = array('username' => 'amartin','pass' => 'amartin','firstname' => 'Angel','lastname' => 'Martin','status' => 5,'auth_source' => 'platform','email' => 'amartin@example.com','creator_id' => 1,'active' => 1);
$users[] = array('username' => 'mhingis','pass' => 'mhingis','firstname' => 'Marsi','lastname' => 'Hingis','status' => 5,'auth_source' => 'platform','email' => 'mhingis@example.com','creator_id' => 1,'active' => 1);
$users[] = array('username' => 'jlennon','pass' => 'jlennon','firstname' => 'Johny','lastname' => 'Lennon','status' => 5,'auth_source' => 'platform','email' => 'jlennon@example.com','creator_id' => 1,'active' => 1);
$users[] = array('username' => 'pchavez','pass' => 'pchavez','firstname' => 'Parol','lastname' => 'Chavez','status' => 5,'auth_source' => 'platform','email' => 'pchavez@example.com','creator_id' => 1,'active' => 1);
/*
$users[] = array(
'username' => '',

@ -8,10 +8,13 @@
* on your system and t launch this script manually using: php5 fill_all.php
* @author Yannick Warnier <yannick.warnier@dokeos.com>
*/
/**
* Initialisation section
*/
require_once '../../main/inc/global.inc.php';
$incdir = dirname(__FILE__).'/../../main/inc/';
require $incdir.'global.inc.php';
/**
* Code logic
*/
@ -19,18 +22,18 @@ require_once '../../main/inc/global.inc.php';
if (PHP_SAPI != 'cli') { die('This demo-data filling script can only be run from the command line. Please launch it from the command line using: php5 fill_all.php. To enable it from your browser (very highly dangerous), remove the first line of code from the "logic" section of this file.'); }
$eol = PHP_EOL;
$output = '';
$files = scandir('.');
$files = scandir(dirname(__FILE__));
foreach ($files as $file) {
if (substr($file,0,1) == '.' or substr($file,0,5) != 'fill_') { ; } //skip
else {
if ($file == basename(__FILE__)) {
; //skip, this is the current file
//skip, this is the current file
} else {
$output .= $file.$eol;
$output .= $eol.'Reading file: '.$file.$eol;
require_once $file;
$function = basename($file,'.php');
if (function_exists($function)) {
$output .= 'Executing function '.$function.$eol;
$output .= $eol.'Executing function '.$function.$eol;
$function();
} else {
//function not found

@ -7,20 +7,22 @@
/**
* Initialisation section
*/
require_once '../../main/inc/global.inc.php';
require_once '../../main/inc/lib/usermanager.lib.php';
//require_once '../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
/**
* Loads the data and injects it into the Dokeos database, using the Dokeos
* internal functions.
* @return array List of user IDs for the users that have just been inserted
*/
function fill_users() {
global $eol;
$users = array(); //declare only to avoid parsing notice
require_once 'data_users.php'; //fill the $users array
$output = array();
echo $eol.'Users created:'.$eol.$eol;
foreach ($users as $i => $user) {
//first check that the first item doesn't exist already
echo $user['firstname'];
echo $user['firstname'].$eol;
$output[] = UserManager::create_user($user['firstname'],$user['lastname'],$user['status'],$user['email'],$user['username'],$user['pass'],null,null,null,null,$user['auth_source'],null,$user['active']);
}
return $output;

Loading…
Cancel
Save