/** * Get Distincts Sub Type of properties * filter by type if one given * @param string $type a type * @return array an Array of sub-types in keys/values */ public function getDistinctSubType($type = null) { if ($type == "author") { return CataloguePeople::getAuthorTypes(); } $q = $this->createDistinct('CataloguePeople INDEXBY sub_type', 'people_sub_type', 'sub_type', ''); if (!is_null($type)) { $q->addWhere('people_type = ?', $type); } $results = $q->fetchArray(); if (count($results)) { $results = array_combine(array_keys($results), array_keys($results)); } return $results; }
<?php include dirname(__FILE__) . '/../../bootstrap/Doctrine.php'; $t = new lime_test(3, new lime_output_color()); $t->info('getAuthorTypes test'); $catPeo = new CataloguePeople(); $types = $catPeo->getAuthorTypes(); $t->is(count($types), 6, 'There are "6" differents types'); $t->is($types['Main Author'], 'Main Author', 'First type is well "Main Author"'); $t->is($types['Related'], 'Related', 'Last type is well "Related"');