当前位置: 首页>>代码示例>>PHP>>正文


PHP ca_objects::getAttributesForDisplay方法代码示例

本文整理汇总了PHP中ca_objects::getAttributesForDisplay方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getAttributesForDisplay方法的具体用法?PHP ca_objects::getAttributesForDisplay怎么用?PHP ca_objects::getAttributesForDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_objects的用法示例。


在下文中一共展示了ca_objects::getAttributesForDisplay方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGets

 public function testGets()
 {
     $vm_ret = $this->opt_object->get('ca_objects.date.dc_dates_types', array('returnIdno' => true));
     $this->assertEquals('created', $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.type_id', array('convertCodesToDisplayText' => true));
     $this->assertEquals('Image', $vm_ret);
     // there are two internal notes but we assume that only the current UI locale is returned, unless we explicitly say otherwise
     $vm_ret = $this->opt_object->get('ca_objects.internal_notes');
     $this->assertEquals("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper sapien nec velit porta luctus.", $vm_ret);
     $vm_ret = $this->opt_object->get('internal_notes');
     $this->assertEquals("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque ullamcorper sapien nec velit porta luctus.", $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.external_link.url_source');
     $this->assertEquals("My URL source;Another URL source", $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.dimensions.dimensions_length');
     $this->assertEquals("10.0 in", $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.dimensions.dimensions_weight');
     $this->assertEquals("2.0000 lb", $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.integer_test', array('delimiter' => ' / '));
     $this->assertEquals("23 / 1984", $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.currency_test');
     $this->assertEquals("USD 100.00", $vm_ret);
     $vm_ret = $this->opt_object->get('ca_objects.georeference');
     $this->assertRegExp("/^1600 Amphitheatre Parkway, Mountain View, CA \\[[\\d\\.\\,\\-]+\\]/", $vm_ret);
     // This is how we fetch the bundle preview for containers:
     $vs_template = "<unit relativeTo='ca_objects.dimensions'><if rule='^measurement_notes =~ /foo/'>^ca_objects.dimensions.dimensions_length</if></unit>";
     $vm_ret = $this->opt_object->getAttributesForDisplay('dimensions', $vs_template);
     $this->assertEquals('10.0 in', $vm_ret);
     $vs_template = "<unit relativeTo='ca_objects.dimensions'><if rule='^measurement_notes =~ /foo/'>^dimensions_length</if></unit>";
     $vm_ret = $this->opt_object->getAttributesForDisplay('dimensions', $vs_template);
     $this->assertEquals('10.0 in', $vm_ret);
     // shouldn't return anything because the expression is false
     $vs_template = "<unit relativeTo='ca_objects.dimensions'><if rule='^measurement_notes =~ /bar/'>^ca_objects.dimensions.dimensions_length</if></unit>";
     $vm_ret = $this->opt_object->getAttributesForDisplay('dimensions', $vs_template);
     $this->assertEmpty($vm_ret);
     // 'flat' informationservice attribues
     $this->assertEquals('Coney Island', $this->opt_object->get('ca_objects.tgn'));
     $this->assertContains('Aaron Burr', $this->opt_object->get('ca_objects.wikipedia'));
     // subfield notation for "extra info"
     $this->assertContains('Burr killed his political rival Alexander Hamilton in a famous duel', $this->opt_object->get('ca_objects.wikipedia.abstract'));
     $this->assertEquals('40.5667', $this->opt_object->get('ca_objects.tgn.lat'));
     // informationservice attributes in container
     $this->assertEquals('[500024253] Haring, Keith (Persons, Artists) - American painter, muralist, and cartoonist, 1958-1990', $this->opt_object->get('ca_objects.informationservice.ulan_container'));
     $this->assertContains('Aaron Burr', $this->opt_object->get('ca_objects.informationservice.wiki'));
     $this->assertContains('Burr killed his political rival Alexander Hamilton in a famous duel', $this->opt_object->get('ca_objects.informationservice.wiki.abstract'));
 }
开发者ID:samrahman,项目名称:providence,代码行数:45,代码来源:AttributeGetTest.php

示例2: testInsertLoadAndDeleteCycleWithCaObjectsModel

 public function testInsertLoadAndDeleteCycleWithCaObjectsModel()
 {
     $t_list = new ca_lists();
     $va_object_types = $t_list->getItemsForList('object_types');
     $this->assertGreaterThan(0, sizeof($va_object_types), "No object types available");
     $va_object_types = caExtractValuesByUserLocale($va_object_types);
     $this->assertGreaterThan(0, sizeof($va_object_types), "No locale-filtered object types available");
     $vn_locale_id = 1;
     $t_object = new ca_objects();
     $t_object->setMode(ACCESS_WRITE);
     $vn_item_id = 0;
     foreach ($va_object_types as $va_object_type) {
         if (intval($va_object_type['is_enabled']) === 1) {
             $vn_item_id = $va_object_type['item_id'];
         }
     }
     $this->assertGreaterThan(0, $vn_item_id, 'No enabled object type found');
     $t_object->set('type_id', $vn_item_id);
     $t_object->set('locale_id', $vn_locale_id);
     $t_object->set('idno', time());
     $t_object->addAttribute(array('description' => 'Test description', 'locale_id' => $vn_locale_id), 'description');
     $vb_res = $t_object->insert();
     $this->assertTrue($vb_res !== false, 'Insert returned non-true value');
     // insert() returns false OR the primary key, therefore simply asserting $vb_res being true doesn't cut it
     $this->assertEquals($t_object->numErrors(), 0, "Errors on insert: " . join('; ', $t_object->getErrors()));
     $this->opa_test_record_ids['ca_objects'][] = $t_object->getPrimaryKey();
     $vb_res = $t_object->addLabel(array('name' => 'Unit test object'), $vn_locale_id, null, true);
     $this->assertGreaterThan(0, $vb_res, 'AddLabel returned zero value but should return non-zero label_id: ' . join('; ', $t_object->getErrors()));
     $t_object2 = new ca_objects();
     $vb_res = $t_object2->load($t_object->getPrimaryKey());
     $this->assertTrue($vb_res, 'Load of newly created record failed [record does not seem to exist or return row id was invalid?]');
     $this->assertEquals($t_object2->getLabelForDisplay(), 'Unit test object', 'Retrieved row label does not match');
     $this->assertEquals($t_object2->getAttributesForDisplay('description'), 'Test description', 'Retrieved value for attribute "description" does not match expected value');
     // try to search for it
     $o_search = new ObjectSearch();
     $qr_hits = $o_search->search("Unit test object");
     $this->assertGreaterThan(0, $qr_hits->numHits(), 'Search for ca_object by label found no results');
     $vb_found_object = false;
     while ($qr_hits->nextHit()) {
         if ($qr_hits->get('object_id') == $t_object->getPrimaryKey()) {
             $vb_found_object = true;
             break;
         }
     }
     $this->assertTrue($vb_found_object, 'ca_object was not in returned search results for ca_object by label');
     // try delete
     $t_object->delete(true, array('hard' => true));
     $this->assertEquals($t_object->numErrors(), 0, "Errors on delete: " . join('; ', $t_object->getErrors()));
 }
开发者ID:samrahman,项目名称:providence,代码行数:49,代码来源:BundlableLabelableBaseModelWithAttributesTest.php


注:本文中的ca_objects::getAttributesForDisplay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。