$author->setOrderBy(1);
$author->save();
$t->info('ML Duchesne as Author associated');
$catpeo = Doctrine::getTable('CataloguePeople')->findForTableByType('taxonomy', $taxon->getId());
$t->is(count($catpeo['author']), 2, 'With author key: "2" record.');
$t->is($catpeo['author'][0]->getPeople()->getGivenName(), 'Poilux', 'Type author and first person well associated to "Poilux"');
$t->is($catpeo['author'][1]->getPeople()->getGivenName(), 'ML', 'Type author and second person well associated to "ML"');
$t->info('Interverting order of "Poilux Duchesne" and "ML Duchesne"');
$catpeo = Doctrine_Query::create()->from('CataloguePeople c')->orderBy('referenced_relation ASC, order_by ASC, id ASC')->execute();
Doctrine::getTable('CataloguePeople')->changeOrder($catpeo[1]->getReferencedRelation(), $catpeo[1]->getRecordId(), 'author', array($catpeo[3]->getId(), $catpeo[1]->getId()));
$catpeo = Doctrine::getTable('CataloguePeople')->findForTableByType('taxonomy', $taxon->getId());
$t->is($catpeo['author'][0]->getPeople()->getGivenName(), 'ML', 'Type author and first person well associated to "ML"');
$t->is($catpeo['author'][1]->getPeople()->getGivenName(), 'Poilux', 'Type author and second person well associated to "Poilux"');
$t->info('Testing the getPeopleRelated method');
$specimen = Doctrine::getTable('Specimens')->findOneByTaxonRef($taxon->getId());
$identification = new Identifications();
$identification->setReferencedRelation('specimens');
$identification->setRecordId($specimen->getId());
$identification->setNotionConcerned('taxonomy');
$identification->setValueDefined('Joli Test');
$identification->save();
$identifier = new CataloguePeople();
$identifier->setReferencedRelation('identifications');
$identifier->setRecordId($identification->getId());
$identifier->setPeopleRef($person1->getId());
$identifier->setPeopleType('identifier');
$identifier->save();
$identifiers = Doctrine::getTable('CataloguePeople')->getPeopleRelated('identifications', 'identifier', $identification->getId());
$t->is($identifiers->count(), 1, '"One" identifier effectively created');
$t->is($identifiers[0]->getPeopleType(), 'identifier', 'New person created in catalogue people is well "identifier"');
$t->is($identifiers[0]->getPeople()->getGivenName(), 'Poilux', '"Poilux" is well the identifier created');
 /**
  * This function create and save all Identifications found
  * $identifiers contains all referenced people is an identification, these identifier are saved in the determination_status field
  * if $comments is an array, I put the tag concerned just before notion concerned
  */
 public function processWithIdentificationsNode($xml_node, $id)
 {
     $node = $xml_node->getElementsByTagName("identification");
     foreach ($node as $identifications) {
         $as_identifier = false;
         $identification = new Identifications();
         $identification['record_id'] = $id;
         $identification['referenced_relation'] = 'staging';
         foreach ($identifications->childNodes as $identification_info) {
             if ($identification_info->nodeName == "#text") {
                 continue;
             }
             if ($identification_info->nodeName == 'notion_concerned') {
                 $identification['notion_concerned'] = $identification_info->nodeValue;
             } elseif ($identification_info->nodeName == 'value') {
                 $identification['value_defined'] = $identification_info->nodeValue;
             } elseif ($identification_info->nodeName == 'identifiers') {
                 $identifier_to_save = $identification_info;
                 $as_identifier = true;
             } elseif ($identification_info->nodeName == 'comments') {
                 $this->complex_nodes['comments']['node'] = $identification_info;
                 $this->complex_nodes['comments']['notion_concerned'] = 'identifications';
             } elseif ($identification_info->nodeName == 'properties') {
                 $this->complex_nodes['properties']['node'] = $identification_info;
                 $this->complex_nodes['properties']['notion_concerned'] = 'identifications';
             }
         }
         $identification->save();
         if ($as_identifier) {
             $identifier = $identifier_to_save->getElementsByTagName("identifier");
             $order_by = 0;
             foreach ($identifier as $ident_tag) {
                 $people = new stagingPeople();
                 $people->fromArray(array('people_type' => 'identifier', 'record_id' => $identification->getId(), 'referenced_relation' => 'identifications', 'order_by' => $order_by++));
                 $people['formated_name'] = $ident_tag->getElementsByTagName("formated_name")->item(0)->nodeValue;
                 $people->save();
             }
         }
     }
 }