本文整理汇总了PHP中Indexer::_build_document方法的典型用法代码示例。如果您正苦于以下问题:PHP Indexer::_build_document方法的具体用法?PHP Indexer::_build_document怎么用?PHP Indexer::_build_document使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Indexer
的用法示例。
在下文中一共展示了Indexer::_build_document方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBuildDocument
public function testBuildDocument()
{
update_option('fields', array('field1' => 1, 'post_date' => 1));
register_post_type('post');
register_taxonomy('tax1', 'post');
register_taxonomy('tax2', 'post');
wp_insert_term('Term 1', 'tax1', array('slug' => 'term1'));
wp_insert_term('Term 2', 'tax1', array('slug' => 'term2', 'parent' => 1));
wp_insert_term('Term 3', 'tax1', array('slug' => 'term3', 'parent' => 2));
wp_insert_term('Term 4', 'tax2', array('slug' => 'term4'));
wp_insert_term('Term 5', 'tax2', array('slug' => 'term5'));
wp_insert_term('Term 6', 'tax2', array('slug' => 'term6', 'parent' => 1));
wp_set_object_terms(2, array(3), 'tax1');
wp_set_object_terms(2, array(2, 3), 'tax2');
$post = (object) array('field1' => 'value1', 'ID' => 2, 'post_date' => '10/24/1988 00:00:00 CST', 'post_type' => 'post');
$tz = date_default_timezone_get();
date_default_timezone_set('America/Chicago');
$document = Indexer::_build_document($post);
date_default_timezone_set($tz);
$this->assertEquals(array('field1' => 'value1', 'post_date' => '1988-10-24T01:00:00-05:00', 'tax1' => array('term3', 'term2', 'term1'), 'tax2' => array('term5', 'term6', 'term4'), 'tax1_name' => array('Term 3', 'Term 2', 'Term 1'), 'tax2_name' => array('Term 5', 'Term 6', 'Term 4'), 'blog_id' => 1), $document);
}
示例2: testBuildDocumentOmitsEmptyCustomFields
public function testBuildDocumentOmitsEmptyCustomFields()
{
update_option('fields', array());
update_option('meta_fields', array('name' => 1, 'empty_field' => 1));
register_post_type('post');
$post = (object) array('ID' => 2, 'post_type' => 'post');
add_post_meta($post->ID, 'name', 'RubyOnRails');
$document = Indexer::_build_document($post);
$this->assertEquals(array('name' => 'RubyOnRails', 'blog_id' => 1), $document);
}