<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
private static function buildAccountQuery()
{
$args = func_get_args();
- $joinsAndWhere = XDB::_prepare($args);
+ $joinsAndWhere = XDB::prepare($args);
return array('SELECT DISTINCT a.uid
FROM accounts AS a
' . $joinsAndWhere,
private static function buildProfileQuery()
{
$args = func_get_args();
- $joinsAndWhere = XDB::_prepare($args);
+ $joinsAndWhere = XDB::prepare($args);
return array('SELECT DISTINCT a.uid
FROM accounts AS a
INNER JOIN account_profiles AS ap ON (ap.uid = a.uid AND FIND_IN_SET(\'owner\', perms))
self::checkPlatal();
$tests = array();
- $tests[] = array(
+ $tests['id'] = array(
/* UFC_Hrpid
*/
array(self::buildAccountQuery('INNER JOIN account_profiles AS ap2 ON (ap2.uid = a.uid)
/* UFC_Promo
*/
- $tests[] = array(
+ $tests['promo'] = array(
array(self::buildProfileQuery('INNER JOIN profile_display AS pd ON (pd.pid = p.pid)
WHERE pd.promo = {?}', 'X2004'),
new UFC_Promo('=', UserFilter::DISPLAY, 'X2004'), -1),
/* UFC_SchoolId
*/
- $tests[] = array(
+ $tests['schoolid'] = array(
array(self::buildProfileQuery('WHERE p.xorg_id = {?}', 20060076),
new UFC_SchoolId(UFC_SchoolId::Xorg, 20060076), 1),
array(self::buildProfileQuery('WHERE p.ax_id = {?}', 20060062),
$id_HEC = XDB::fetchOneCell('SELECT id
FROM profile_education_enum
WHERE abbreviation = {?}', 'HEC');
- $tests[] = array(
+ $tests['school'] = array(
array(self::buildProfileQuery('INNER JOIN profile_education AS pe ON (pe.pid = p.pid)
LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id)
WHERE pee.abbreviation = {?}', 'X'),
$id_DegreePhd = XDB::fetchOneCell('SELECT id
FROM profile_education_degree_enum
WHERE abbreviation = {?}', 'PhD');
- $tests[] = array(
+ $tests['degree'] = array(
array(self::buildProfileQuery('INNER JOIN profile_education AS pe ON (pe.pid = p.pid)
LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id)
WHERE pede.abbreviation = {?}', 'Ing.'),
FROM profile_education_field_enum
WHERE field = {?}', 'Droit');
// FIXME: Replace 0 by -1 in following queries when profile_education will be filled with fieldids
- $tests[] = array(
+ $tests['edufield'] = array(
array(self::buildProfileQuery('INNER JOIN profile_education AS pe ON (pe.pid = p.pid)
LEFT JOIN profile_education_field_enum AS pefe ON (pe.fieldid = pefe.id)
WHERE pefe.field = {?}', 'Informatique'),
$id_Lastname_Marital = DirEnum::getID(DirEnum::NAMETYPES, Profile::LASTNAME . '_' . Profile::VN_MARITAL);
$id_Lastname_Ordinary = DirEnum::getID(DirEnum::NAMETYPES, Profile::LASTNAME . '_' . Profile::VN_ORDINARY);
- $tests[] = array(
+ $tests['name'] = array(
// Lastname
array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (pn.pid = p.pid)
WHERE pn.name LIKE {?} AND pn.typeid = {?}', 'BARROIS', $id_Lastname),
/* UFC_NameTokens
*/
- $tests[] = array(
+ $tests['nametoken'] = array(
// !soundex, !exact
array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid)
WHERE sn.token LIKE \'xelnor%\''),
// soundex, !exact
array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid)
WHERE sn.soundex = \'XLNO\''),
- new UFC_NameTokens('XLNO', array(), true), -1),
+ new UFC_NameTokens('xelnor', array(), true), -1),
array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid)
WHERE sn.soundex IN (\'XLNO\', \'BROS\')'),
- new UFC_NameTokens(array('XLNO', 'BROS'), array(), true), -1),
- array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid)
- WHERE sn.soundex = \'ZZZZZZ\''),
- new UFC_NameTokens('ZZZZZZ', array(), true), 0),
+ new UFC_NameTokens(array('xelnor', 'barrois'), array(), true), -1),
array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid)
WHERE sn.soundex = \'BROS\' AND FIND_IN_SET(\'public\', sn.flags)'),
- new UFC_NameTokens('BROS', UFC_NameTokens::FLAG_PUBLIC, true), -1),
+ new UFC_NameTokens('barrois', UFC_NameTokens::FLAG_PUBLIC, true), -1),
);
/* UFC_Nationality
*/
- $tests[] = array(
+ $tests['nationality'] = array(
array(self::buildProfileQuery('WHERE p.nationality1 IN {?} OR p.nationality2 IN {?} OR p.nationality3 IN {?}', array('BR'), array('BR'), array('BR')),
new UFC_Nationality('BR'), -1),
array(self::buildProfileQuery('WHERE p.nationality1 IN {?} OR p.nationality2 IN {?} OR p.nationality3 IN {?}', array('BR', 'US'), array('BR', 'US'), array('BR', 'US')),
/* UFC_Dead
*/
- $tests[] = array(
+ $tests['dead'] = array(
array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL'),
new UFC_Dead(), -1),
array(self::buildProfileQuery('WHERE p.deathdate IS NOT NULL AND p.deathdate > {?}', '2008-01-01'),
/* UFC_Registered
*/
- $tests[] = array(
+ $tests['register'] = array(
array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state = \'active\''),
new UFC_Registered(true), -1),
array(self::buildAccountQuery('WHERE a.uid IS NOT NULL AND a.state != \'pending\''),
);
$testcases = array();
- foreach ($tests as $t) {
- $testcases = array_merge($testcases, $t);
+ foreach ($tests as $name => $t) {
+ foreach ($t as $id => $case) {
+ $testcases[$name . '-' . $id] = $case;
+ }
}
return $testcases;
}