{?}', 'X2004'), new UFC_Promo('>', UserFilter::DISPLAY, 'X2004'), -1), array(self::buildProfileQuery('INNER JOIN profile_display AS pd ON (pd.pid = p.pid) WHERE pd.promo < {?}', 'X1900'), new UFC_Promo('<', UserFilter::DISPLAY, 'X1900'), 0), 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) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.entry_year = {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2004', 'Ing.'), new UFC_Promo('=', UserFilter::GRADE_ING, 2004), -1), 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) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.entry_year <= {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '1960', 'Ing.'), new UFC_Promo('<=', UserFilter::GRADE_ING, 1960), -1), 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) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.entry_year > {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2004', 'Ing.'), new UFC_Promo('>', UserFilter::GRADE_ING, 2004), -1), 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) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.entry_year < {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '1900', 'Ing.'), new UFC_Promo('<', UserFilter::GRADE_ING, 1900), 0), /* XXX : tests disabled until there are Masters and doctors in the DB array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year = {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2009', 'MSc'), new UFC_Promo('=', UserFilter::GRADE_MST, 2009), -1), array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year <= {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2009', 'MSc'), new UFC_Promo('<=', UserFilter::GRADE_MST, 2009), -1), array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year > {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2009', 'MSc'), new UFC_Promo('>', UserFilter::GRADE_MST, 2009), -1), array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year < {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '1980', 'MSc'), new UFC_Promo('<', UserFilter::GRADE_MST, 1980), 0), array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year = {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2009', 'PhD'), new UFC_Promo('=', UserFilter::GRADE_PHD, 2009), -1), array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year <= {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2009', 'PhD'), new UFC_Promo('<=', UserFilter::GRADE_PHD, 2009), -1), array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year > {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '2009', 'PhD'), new UFC_Promo('>', UserFilter::GRADE_PHD, 2009), -1), array(XDB::format('SELECT DISTINCT ap.uid FROM account_profiles AS ap INNER JOIN profile_education AS pe ON (pe.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) LEFT JOIN profile_education_enum AS pee ON (pe.eduid = pee.id) LEFT JOIN profile_education_degree_enum AS pede ON (pe.degreeid = pede.id) WHERE pe.grad_year < {?} AND pee.abbreviation = \'X\' AND pede.abbreviation = {?}', '1980', 'PhD'), new UFC_Promo('<', UserFilter::GRADE_PHD, 1980), 0), */ ); /* UFC_SchoolId */ $tests[] = 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), new UFC_SchoolId(UFC_SchoolId::AX, 20060062), 1), array(self::buildProfileQuery('WHERE p.xorg_id = {?}', 007), new UFC_SchoolId(UFC_SchoolId::Xorg, 007), 0), array(self::buildProfileQuery('WHERE p.ax_id = {?}', 007), new UFC_SchoolId(UFC_SchoolId::AX, 007), 0), /* FIXME: disabled until we have some examples of school_id array(self::buildProfileQuery('WHERE p.school_id = {?}', 12345678), new UFC_SchoolId(UFC_SchoolId::School, 12345678), 1), array(self::buildProfileQuery('WHERE p.school_id = {?}', 007), new UFC_SchoolId(UFC_SchoolId::School, 007), 0), */ ); /* UFC_EducationSchool */ $id_X = XDB::fetchOneCell('SELECT id FROM profile_education_enum WHERE abbreviation = {?}', 'X'); $id_HEC = XDB::fetchOneCell('SELECT id FROM profile_education_enum WHERE abbreviation = {?}', 'HEC'); $tests[] = 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'), new UFC_EducationSchool($id_X), -1), 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 IN {?}', array('X', 'HEC')), new UFC_EducationSchool($id_X, $id_HEC), -1), ); /* UFC_EducationDegree */ $id_DegreeIng = XDB::fetchOneCell('SELECT id FROM profile_education_degree_enum WHERE abbreviation = {?}', 'Ing.'); $id_DegreePhd = XDB::fetchOneCell('SELECT id FROM profile_education_degree_enum WHERE abbreviation = {?}', 'PhD'); $tests[] = 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.'), new UFC_EducationDegree($id_DegreeIng), -1), 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 IN {?}', array('Ing.', 'PhD')), new UFC_EducationDegree($id_DegreeIng, $id_DegreePhd), -1), ); /* UFC_EducationField */ $id_FieldInfo = XDB::fetchOneCell('SELECT id FROM profile_education_field_enum WHERE field = {?}', 'Informatique'); $id_FieldDroit = XDB::fetchOneCell('SELECT id 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( 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'), new UFC_EducationField($id_FieldInfo), 0), // FIXME: should be -1 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 IN {?}', array('Informatique', 'Droit')), new UFC_EducationField($id_FieldInfo, $id_FieldDroit), 0), // FIXME: should be -1 ); /* UFC_Name */ $id_Lastname = DirEnum::getID(DirEnum::NAMETYPES, Profile::LASTNAME); $id_Firstname = DirEnum::getID(DirEnum::NAMETYPES, Profile::FIRSTNAME); $id_Nickname = DirEnum::getID(DirEnum::NAMETYPES, Profile::NICKNAME); $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( // 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), new UFC_Name(Profile::LASTNAME, 'BARROIS', UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (pn.pid = p.pid) WHERE pn.name LIKE \'BARR%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'BARR', UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (pn.pid = p.pid) WHERE pn.name LIKE \'%OIS\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'OIS', UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%ARRO%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'ARRO', UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%ZZZZZZ%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'ZZZZZZ', UFC_Name::CONTAINS), 0), // Firstname array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE {?} AND pn.typeid = {?}', 'Raphaël', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'Raphaël', UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'Raph%\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'Raph', UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%aël\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'aël', UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%apha%\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'apha', UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%zzzzzz%\' AND pn.typeid = {?}', $id_Firstname), new UFC_Name(Profile::FIRSTNAME, 'zzzzzz', UFC_Name::CONTAINS), 0), // Nickname array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE {?} AND pn.typeid = {?}', 'Xelnor', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'Xelnor', UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'Xel%\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'Xel', UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%nor\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'nor', UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%lno%\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'lno', UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE \'%zzzzzz%\' AND pn.typeid = {?}', $id_Nickname), new UFC_Name(Profile::NICKNAME, 'zzzzzz', UFC_Name::CONTAINS), 0), // Lastname + particle array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE CONCAT(pn.particle, \' \', pn.name) LIKE {?} AND pn.typeid = {?}', 'DE SINGLY', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'DE SINGLY', UFC_Name::PARTICLE | UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE CONCAT(pn.particle, \' \', pn.name) LIKE \'DE SI%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'DE SI', UFC_Name::PARTICLE | UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE CONCAT(pn.particle, \' \', pn.name) LIKE \'%GLY\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'GLY', UFC_NAME::PARTICLE | UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE CONCAT(pn.particle, \' \', pn.name) LIKE \'%E SIN%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'E SIN', UFC_Name::PARTICLE | UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE CONCAT(pn.particle, \' \', pn.name) LIKE \'%ZZZZZZ%\' AND pn.typeid = {?}', $id_Lastname), new UFC_Name(Profile::LASTNAME, 'ZZZZZZ', UFC_Name::PARTICLE | UFC_Name::CONTAINS), 0), // Lastname_ordinary array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE {?} AND pn.typeid IN {?}', 'ALBIZZATI', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ALBIZZATI', UFC_Name::VARIANTS | UFC_Name::EXACT), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE {?} AND pn.typeid IN {?}', 'ALBIZ%', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ALBIZ', UFC_Name::VARIANTS | UFC_Name::PREFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE {?} AND pn.typeid IN {?}', '%ZATI', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ZATI', UFC_NAME::VARIANTS | UFC_Name::SUFFIX), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE {?} AND pn.typeid IN {?}', '%BIZZ%', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'BIZZ', UFC_Name::VARIANTS | UFC_Name::CONTAINS), -1), array(self::buildProfileQuery('LEFT JOIN profile_name AS pn ON (p.pid = pn.pid) WHERE pn.name LIKE {?} AND pn.typeid IN {?}', '%ZZZZZZ%', array($id_Lastname, $id_Lastname_Marital, $id_Lastname_Ordinary)), new UFC_Name(Profile::LASTNAME, 'ZZZZZZ', UFC_Name::VARIANTS | UFC_Name::CONTAINS), 0), ); /* UFC_NameTokens */ $tests[] = array( // !soundex, !exact array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token LIKE \'xelnor%\''), new UFC_NameTokens('xelnor'), 1), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token LIKE \'xe%\''), new UFC_NameTokens('xe'), -1), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token LIKE \'xe%\' OR sn.token LIKE \'barr%\''), new UFC_NameTokens(array('xe', 'barr')), -1), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token LIKE \'zzzzzzzz%\''), new UFC_NameTokens('zzzzzzzz'), 0), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token LIKE \'barr%\' AND FIND_IN_SET(\'public\', sn.flags)'), new UFC_NameTokens('barr', UFC_NameTokens::FLAG_PUBLIC), -1), // !soundex, exact array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token = \'xelnor\''), new UFC_NameTokens('xelnor', array(), false, true), 1), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token IN (\'xelnor\', \'barrois\')'), new UFC_NameTokens(array('xelnor', 'barrois'), array(), false, true), -1), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token = \'zzzzzzzz\''), new UFC_NameTokens('zzzzzzzz', array(), false, true), 0), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token IN (\'zzzzzzzz\', \'yyyyyyyy\')'), new UFC_NameTokens(array('zzzzzzzz', 'yyyyyyyy'), array(), false, true), 0), array(self::buildProfileQuery('LEFT JOIN search_name AS sn ON (p.pid = sn.pid) WHERE sn.token = \'barrois\' AND FIND_IN_SET(\'public\', sn.flags)'), new UFC_NameTokens('barrois', UFC_NameTokens::FLAG_PUBLIC, false, true), -1), // 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), 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), 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), ); $testcases = array(); foreach ($tests as $t) { $testcases = array_merge($testcases, $t); } return $testcases; } /** * @dataProvider simpleUserProvider */ public function testSimpleUser($query, $cond, $expcount = null) { /* * @param $query A pair MySQL query (one for user selector, one for profile selector) * @param $cond The UFC to test * @param $expcount The expected number of results (-1 if that number is unknown) */ $query = $query[0]; self::checkPlatal(); $query = XDB::query($query); $count = $query->numRows(); if (!is_null($expcount)) { if ($expcount < 0) { $this->assertNotEquals(0, $count); } else { $this->assertEquals($expcount, $count); } } $ids = $query->fetchColumn(); $this->assertEquals($count, count($ids)); sort($ids); $uf = new UserFilter($cond); $this->assertEquals($count, $uf->getTotalUserCount()); $got = $uf->getUIDs(); $this->assertEquals($count, count($got)); sort($got); $this->assertEquals($ids, $got); $uf = new UserFilter($cond); $got = $uf->getUIDs(); $this->assertEquals($count, count($got)); sort($got); $this->assertEquals($ids, $got); $this->assertEquals($count, $uf->getTotalUserCount()); } /** * @dataProvider simpleUserProvider */ public function testSimpleProfile($query, $cond, $expcount = null) { /* * @param $query A pair MySQL query (one for user selector, one for profile selector) * @param $cond The UFC to test * @param $expcount The expected number of results (-1 if that number is unknown) */ $query = $query[1]; self::checkPlatal(); $query = XDB::query($query); $count = $query->numRows(); if (!is_null($expcount)) { if ($expcount < 0) { $this->assertNotEquals(0, $count); } else { $this->assertEquals($expcount, $count); } } $ids = $query->fetchColumn(); $this->assertEquals($count, count($ids)); sort($ids); $uf = new UserFilter($cond); $this->assertEquals($count, $uf->getTotalProfileCount()); $got = $uf->getPIDs(); $this->assertEquals($count, count($got)); sort($got); $this->assertEquals($ids, $got); $uf = new UserFilter($cond); $got = $uf->getPIDs(); $this->assertEquals($count, count($got)); sort($got); $this->assertEquals($ids, $got); $this->assertEquals($count, $uf->getTotalProfileCount()); } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>