Exemplo n.º 1
0
 public function testGets()
 {
     $vm_ret = $this->opt_object->get('ca_entities', array('delimiter' => '; '));
     $this->assertEquals('Homer J. Simpson; Bart Simpson; ACME Inc.', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities.preferred_labels', array('delimiter' => '; '));
     $this->assertEquals('Homer J. Simpson; Bart Simpson; ACME Inc.', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities.nonpreferred_labels');
     $this->assertEquals('Max Power', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('returnWithStructure' => true));
     $vm_ret2 = $this->opt_object->getRelatedItems('ca_entities');
     $this->assertSame($vm_ret, $vm_ret2);
     $vm_ret = $this->opt_object->get('ca_entities', array('restrictToRelationshipTypes' => array('creator')));
     $this->assertEquals('Homer J. Simpson', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('restrictToRelationshipTypes' => array('publisher')));
     $this->assertEquals('Bart Simpson', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('delimiter' => '; ', 'restrictToTypes' => array('ind')));
     $this->assertEquals('Homer J. Simpson; Bart Simpson', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('delimiter' => '; ', 'restrictToTypes' => array('org')));
     $this->assertEquals('ACME Inc.', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('delimiter' => '; ', 'restrictToTypes' => array('ind', 'org')));
     $this->assertEquals('Homer J. Simpson; Bart Simpson; ACME Inc.', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('delimiter' => '; ', 'excludeRelationshipTypes' => array('creator', 'publisher')));
     $this->assertEquals('ACME Inc.', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('delimiter' => '; ', 'excludeTypes' => array('ind')));
     $this->assertEquals('ACME Inc.', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects_x_entities.source_info', array('delimiter' => '; '));
     $this->assertEquals('Me; Homer; Bart', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects_x_entities.effective_date', array('delimiter' => '; '));
     $this->assertEquals('2015; 2014 - 2015; 2013', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities.internal_notes');
     $this->assertEquals('Test notes', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.related.preferred_labels');
     $this->assertEquals('My test dataset', $vm_ret);
     // <unit> with relativeTo to repeat template once per entity (this is different from the old pre-1.6 template behavior)
     $vm_ret = $this->opt_object->get('ca_entities', array('template' => '<unit relativeTo="ca_entities">^ca_entities.preferred_labels.displayname (^ca_entities.internal_notes)</unit>', 'delimiter' => '; '));
     $this->assertEquals('Homer J. Simpson (); Bart Simpson (); ACME Inc. (Test notes)', $vm_ret);
     // Pre-1.6 test without units returns straight text get() output for each tag (this used to return the output in the previous test)
     $vm_ret = $this->opt_object->get('ca_entities', array('template' => '^ca_entities.preferred_labels.displayname (^ca_entities.internal_notes)', 'delimiter' => '; '));
     $this->assertEquals('Homer J. Simpson; Bart Simpson; ACME Inc. (Test notes)', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_entities', array('template' => '^ca_entities.preferred_labels', 'delimiter' => '; ', 'returnAsLink' => true));
     $this->assertRegExp("/\\<a href=[\"\\'](.)+[\"\\']>Homer J. Simpson\\<\\/a\\>/", $vm_ret);
     $this->assertRegExp("/\\<a href=[\"\\'](.)+[\"\\']>Bart Simpson\\<\\/a\\>/", $vm_ret);
     $this->assertRegExp("/\\<a href=[\"\\'](.)+[\"\\']>ACME Inc.\\<\\/a\\>/", $vm_ret);
     $va_entity_relationships = $this->opt_object->get('ca_objects_x_entities.relation_id', array('returnAsArray' => true));
     $qr_entity_relationships = caMakeSearchResult('ca_objects_x_entities', $va_entity_relationships);
     $this->assertEquals(3, $qr_entity_relationships->numHits());
     while ($qr_entity_relationships->nextHit()) {
         $this->assertEquals('0', $qr_entity_relationships->get('ca_objects.deleted'));
         $this->assertEquals('0', $qr_entity_relationships->get('ca_entities.deleted'));
     }
     // there are no related list items
     $vm_ret = $this->opt_object->get('ca_list_items', array('returnAsArray' => true));
     $this->assertEmpty($vm_ret);
 }
Exemplo n.º 2
0
 public function testGets()
 {
     $vm_ret = $this->opt_loan_in->get('ca_loans.related');
     $this->assertEquals('New Loan Out', $vm_ret);
     $va_items = $this->opt_loan_in->getRelatedItems('ca_loans');
     $vn_relation_id = array_shift(caExtractArrayValuesFromArrayOfArrays($va_items, 'relation_id'));
     // The relationship we created is Loan Out <-> Loan In, so evaluating with loan in as primary ID should give us the loan out
     $va_opts = array('resolveLinksUsing' => 'ca_loans', 'primaryIDs' => array('ca_loans' => array($this->opt_loan_in->getPrimaryKey())));
     $vm_ret = caProcessTemplateForIDs("^ca_loans.preferred_labels", 'ca_loans_x_loans', array($vn_relation_id), $va_opts);
     $this->assertEquals('New Loan Out', $vm_ret);
     // Now for the other side ...
     $va_opts = array('resolveLinksUsing' => 'ca_loans', 'primaryIDs' => array('ca_loans' => array($this->opt_loan_out->getPrimaryKey())));
     $vm_ret = caProcessTemplateForIDs("^ca_loans.preferred_labels", 'ca_loans_x_loans', array($vn_relation_id), $va_opts);
     $this->assertEquals('New Loan In', $vm_ret);
 }