Changeset c644bf6
- Timestamp:
- 08/25/10 15:52:31 (21 months ago)
- Branches:
- ('master', '8434b8322dd6f8ff37c17bd45b94e7a826f86b53')('vitrine', 'afe109c61a407808bd54d88bcccb1cde726a010a')
- Children:
- 7329a7409a9b5dbfd010361d0df93b771d1fecd3
- Parents:
- 1e8249e179fe3552436080fbd1e78d29c96cf6d4
- git-author:
- Benoit Grégoire <benoitg@coeus.ca>2010-08-25 15:52:31-04:00
- git-committer:
- Benoit Grégoire <benoitg@coeus.ca>2010-08-25 15:52:31-04:00
- File:
-
- 1 edited
-
html/tests/VocabRelationshipNavigationTest.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
html/tests/VocabRelationshipNavigationTest.php
r1e8249e rc644bf6 8 8 class VocabRelationshipImportTest extends PHPUnit_Framework_TestCase 9 9 { 10 private $fixTurePersistent = false; 10 11 protected function setUp() 11 12 { 13 $this->pivotVocIdStr='pivotVoc'; 14 $this->rVoc1IdStr='rVoc1'; 15 $this->rVoc2IdStr='rVoc2'; 16 try { 17 $voc = Vocabulary::getObject($this->pivotVocIdStr); 18 } 19 catch (Exception $e) { 20 $voc = null; 21 } 22 if($this->fixTurePersistent==false||$voc==null) { 23 /* Otherwise everytime the test crashes the teardown won't be done properly */ 24 try { 25 $voc = new Vocabulary('pivotVoc'); 26 $voc->delete(); 27 } 28 catch (Exception $e) { 29 } 30 try { 31 $voc = new Vocabulary('rVoc1'); 32 $voc->delete(); 33 } 34 catch (Exception $e) { 35 } 36 try { 37 $voc = new Vocabulary('rVoc2'); 38 $voc->delete(); 39 } 40 catch (Exception $e) { 41 } 42 43 $this->pivotVoc = new Vocabulary('NEW'); 44 $vocXml = file_get_contents(dirname(__FILE__) . '/testVocs/pivotVoc.xml'); 45 $this->pivotVoc->import(DOMDocument :: loadXML($vocXml), 'VDEX'); 12 46 13 47 14 /* Otherwise everytime the test crashes the teardown won't be done properly */ 15 try { 16 $voc = new Vocabulary('pivotVoc'); 17 $voc->delete(); 48 $this->rVoc1 = new Vocabulary('NEW'); 49 $vocXml = file_get_contents(dirname(__FILE__) . '/testVocs/rVoc1.xml'); 50 $this->rVoc1->import(DOMDocument :: loadXML($vocXml), 'VDEX'); 51 52 53 $this->rVoc2 = new Vocabulary('NEW'); 54 $vocXml = file_get_contents(dirname(__FILE__) . '/testVocs/rVoc2.xml'); 55 $this->rVoc2->import(DOMDocument :: loadXML($vocXml), 'VDEX'); 56 /* Link Learning objects to the vocabulary terms */ 57 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r1', array('rVoc1T1', 'rVoc1')); 58 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r2', array('rVoc1T2', 'rVoc1')); 59 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r3', array('pivotVocT1', 'pivotVoc')); 60 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r4', array('pivotVocT2', 'pivotVoc')); 61 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r5', array('pivotVocT3', 'pivotVoc')); 62 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r6', array('rVoc2T1', 'rVoc2')); 63 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r7', array('rVoc2T2', 'rVoc2')); 64 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r8', array('rVoc2T3', 'rVoc2')); 65 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r9', array('rVoc2T4', 'rVoc2')); 66 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r10', array('rVoc2T5', 'rVoc2')); 67 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r11', array('rVoc2T6', 'rVoc2')); 68 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r12', array('rVoc2T7', 'rVoc2')); 18 69 } 19 catch (Exception $e) { 70 else { 71 $this->pivotVoc = Vocabulary::getObject($this->pivotVocIdStr); 72 $this->rVoc1 = Vocabulary::getObject($this->rVoc1IdStr); 73 $this->rVoc2 = Vocabulary::getObject($this->rVoc2IdStr); 74 20 75 } 21 try {22 $voc = new Vocabulary('rVoc1');23 $voc->delete();24 }25 catch (Exception $e) {26 }27 try {28 $voc = new Vocabulary('rVoc2');29 $voc->delete();30 }31 catch (Exception $e) {32 }33 $this->pivotVocIdStr='pivotVoc';34 $this->pivotVoc = new Vocabulary('NEW');35 $vocXml = file_get_contents(dirname(__FILE__) . '/testVocs/pivotVoc.xml');36 $this->pivotVoc->import(DOMDocument :: loadXML($vocXml), 'VDEX');37 38 $this->rVoc1IdStr='rVoc1';39 $this->rVoc1 = new Vocabulary('NEW');40 $vocXml = file_get_contents(dirname(__FILE__) . '/testVocs/rVoc1.xml');41 $this->rVoc1->import(DOMDocument :: loadXML($vocXml), 'VDEX');42 43 $this->rVoc2IdStr='rVoc2';44 $this->rVoc2 = new Vocabulary('NEW');45 $vocXml = file_get_contents(dirname(__FILE__) . '/testVocs/rVoc2.xml');46 $this->rVoc2->import(DOMDocument :: loadXML($vocXml), 'VDEX');47 /* Link Learning objects to the vocabulary terms */48 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r1', array('rVoc1T1', 'rVoc1'));49 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r2', array('rVoc1T2', 'rVoc1'));50 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r3', array('pivotVocT1', 'pivotVoc'));51 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r4', array('pivotVocT2', 'pivotVoc'));52 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r5', array('pivotVocT3', 'pivotVoc'));53 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r6', array('rVoc2T1', 'rVoc2'));54 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r7', array('rVoc2T2', 'rVoc2'));55 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r8', array('rVoc2T3', 'rVoc2'));56 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r9', array('rVoc2T4', 'rVoc2'));57 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r10', array('rVoc2T5', 'rVoc2'));58 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r11', array('rVoc2T6', 'rVoc2'));59 $this->los[] = $this->addLo('oai:eureka.coeus.ca:r12', array('rVoc2T7', 'rVoc2'));60 76 } 61 77 /** … … 64 80 */ 65 81 private function addLo($oaiId, $termId) { 66 $db = AbstractDb::getObject(); 67 global $bypassAccessControl; 68 $bypassAccessControl = true; 69 $rootTheme = Theme::getObject(array(EUREKA_THEME_ROOT_ID, VOC_EUREKA_THEME)); 70 $lo = new Lom('NEW', $rootTheme, null,$oaiId); 71 $theme_taxon_path = new LomTaxonPath('NEW'); 72 $theme_taxon_path->setPathFromVocabularyTerm(Theme::getObject($termId)); 73 $theme_classification = new LomClassification('NEW'); 74 $theme_classification->AddTaxonPath($theme_taxon_path); 75 $sql = "INSERT INTO lom_has_lom_9_classification (lom_id, lom_9_classification_id) VALUES (".$lo->getId()."," . $theme_classification->getId() . "); \n"; 76 $db->execSqlUpdate($sql, false); 82 if($lo=Lom::getLomByOaiId($oaiId)==null) { 83 $db = AbstractDb::getObject(); 84 global $bypassAccessControl; 85 $bypassAccessControl = true; 86 $rootTheme = Theme::getObject(array(EUREKA_THEME_ROOT_ID, VOC_EUREKA_THEME)); 87 $lo = new Lom('NEW', $rootTheme, null,$oaiId); 88 $theme_taxon_path = new LomTaxonPath('NEW'); 89 $theme_taxon_path->setPathFromVocabularyTerm(Theme::getObject($termId)); 90 $theme_classification = new LomClassification('NEW'); 91 $theme_classification->AddTaxonPath($theme_taxon_path); 92 $sql = "INSERT INTO lom_has_lom_9_classification (lom_id, lom_9_classification_id) VALUES (".$lo->getId()."," . $theme_classification->getId() . "); \n"; 93 $db->execSqlUpdate($sql, false); 94 } 77 95 return $lo; 78 96 } … … 87 105 $fiches_array = $searchEngine->getResultLOs(); 88 106 foreach($fiches_array as $lo) { 89 $retval[]=$lo->getOaiId()->getEntry();107 $retval[]=$lo->getOaiId()->getEntry(); 90 108 } 91 109 sort($retval); … … 94 112 protected function tearDown() 95 113 { 96 foreach($this->los as $lo) { 97 $lo->delete(); 114 if($this->fixTurePersistent==false) { 115 foreach($this->los as $lo) { 116 $lo->delete(); 117 } 118 $this->rVoc2->delete(); 119 $this->rVoc1->delete(); 120 $this->pivotVoc->delete(); 98 121 } 99 $this->rVoc2->delete();100 $this->rVoc1->delete();101 $this->pivotVoc->delete();102 122 } 103 123 /** Normally i'd do more than one test, but the fixtures are unbearably slow */
Note: See TracChangeset
for help on using the changeset viewer.
