setUp() public method

public setUp ( )
 function setUp()
 {
     parent::setUp();
     $this->cpt_name = 'post_type_test';
     $this->cpt_args = array('public' => false, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 7, 'menu_icon' => 'cpt_icon.png', 'taxonomies' => array('category', 'post_tag'), 'hierarchical' => true);
     register_post_type($this->cpt_name, $this->cpt_args);
 }
Exemplo n.º 2
0
 function setUp()
 {
     parent::setUp();
     $this->post_date_ts = strtotime('+1 day');
     $this->post_data = array('post_type' => 'page', 'post_title' => rand_str(), 'post_content' => rand_str(2000), 'post_excerpt' => rand_str(100), 'post_author' => $this->make_user_by_role('author'), 'post_date' => strftime("%Y-%m-%d %H:%M:%S", $this->post_date_ts));
     $this->post_id = wp_insert_post($this->post_data);
 }
Exemplo n.º 3
0
 function setUp()
 {
     parent::setUp();
     $this->parent_term = wp_insert_term('parent' . rand_str(), 'category');
     $this->assertInternalType('array', $this->parent_term);
     $this->parent_term = $this->parent_term['term_id'];
 }
Exemplo n.º 4
0
 function setUp()
 {
     parent::setUp();
     // create a super-admin
     $this->administrator_id = $this->make_user_by_role('administrator');
     if (is_multisite()) {
         grant_super_admin($this->administrator_id);
     }
 }
Exemplo n.º 5
0
 function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create();
     $this->parent_comment_data = array('comment_post_ID' => $this->post_id, 'comment_author' => 'Test commenter', 'comment_author_url' => 'http://example.com/', 'comment_author_email' => '*****@*****.**', 'comment_content' => rand_str(100));
     $this->parent_comment_id = wp_insert_comment($this->parent_comment_data);
     $this->child_comment_data = array('comment_post_ID' => $this->post_id, 'comment_author' => 'Test commenter 2', 'comment_author_url' => 'http://example.org/', 'comment_author_email' => '*****@*****.**', 'comment_parent' => $this->parent_comment_id, 'comment_content' => rand_str(100));
     $this->child_comment_id = wp_insert_comment($this->child_comment_data);
 }
Exemplo n.º 6
0
 function setUp()
 {
     parent::setUp();
     $this->post_date_ts = strtotime('+1 day');
     $this->post_data = array('post_title' => rand_str(), 'post_content' => rand_str(2000), 'post_excerpt' => rand_str(100), 'post_author' => $this->make_user_by_role('author'), 'post_date' => strftime("%Y-%m-%d %H:%M:%S", $this->post_date_ts));
     $this->post_id = wp_insert_post($this->post_data);
     $this->post_custom_field = array('key' => 'test_custom_field', 'value' => 12345678);
     $this->post_custom_field['id'] = add_post_meta($this->post_id, $this->post_custom_field['key'], $this->post_custom_field['value']);
 }
 function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create(array('post_content' => 'edit1'));
     wp_insert_post(array('ID' => $this->post_id, 'post_content' => 'edit2'));
     $revisions = wp_get_post_revisions($this->post_id);
     $revision = array_shift($revisions);
     $this->revision_id = $revision->ID;
 }
Exemplo n.º 8
0
 function setUp()
 {
     parent::setUp();
     $this->parent_term = wp_insert_term('parent' . rand_str(), 'category');
     $this->assertInternalType('array', $this->parent_term);
     $this->child_term = wp_insert_term('child' . rand_str(), 'category');
     $this->assertInternalType('array', $this->child_term);
     $this->post_tag = wp_insert_term('test' . rand_str(), 'post_tag');
     $this->assertInternalType('array', $this->post_tag);
 }
 function setUp()
 {
     parent::setUp();
     add_theme_support('post-thumbnails');
     $filename = DIR_TESTDATA . '/images/waffles.jpg';
     $contents = file_get_contents($filename);
     $upload = wp_upload_bits(basename($filename), null, $contents);
     $this->attachment_id = $this->_make_attachment($upload, self::$post_id);
     $this->attachment_data = get_post($this->attachment_id, ARRAY_A);
     set_post_thumbnail(self::$post_id, $this->attachment_id);
 }
Exemplo n.º 10
0
 function setUp()
 {
     parent::setUp();
     add_theme_support('post-thumbnails');
     $this->post_id = wp_insert_post(array('post_title' => rand_str(), 'post_content' => rand_str(), 'post_status' => 'publish'));
     $filename = DIR_TESTDATA . '/images/waffles.jpg';
     $contents = file_get_contents($filename);
     $upload = wp_upload_bits(basename($filename), null, $contents);
     $this->attachment_id = $this->_make_attachment($upload, $this->post_id);
     $this->attachment_data = get_post($this->attachment_id, ARRAY_A);
     set_post_thumbnail($this->post_id, $this->attachment_id);
 }
Exemplo n.º 11
0
 function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create(array('post_content' => 'edit1'));
     // Not saved as a revision
     // First saved revision on update, see https://core.trac.wordpress.org/changeset/24650
     wp_insert_post(array('ID' => $this->post_id, 'post_content' => 'edit2'));
     $revisions = wp_get_post_revisions($this->post_id);
     //$revision = array_shift( $revisions ); // First revision is empty - https://core.trac.wordpress.org/changeset/23842
     // First revision is NOT empty, see https://core.trac.wordpress.org/changeset/24650
     $revision = array_shift($revisions);
     $this->revision_id = $revision->ID;
 }
Exemplo n.º 12
0
 function setUp()
 {
     parent::setUp();
     add_theme_support('post-thumbnails');
     $this->post_id = wp_insert_post(array('post_title' => rand_str(), 'post_content' => rand_str(), 'post_status' => 'publish'));
     $filename = DIR_TESTDATA . '/images/waffles.jpg';
     $contents = file_get_contents($filename);
     $upload = wp_upload_bits(basename($filename), null, $contents);
     $mime = wp_check_filetype($filename);
     $this->attachment_data = array('post_title' => basename($upload['file']), 'post_content' => '', 'post_type' => 'attachment', 'post_parent' => $this->post_id, 'post_mime_type' => $mime['type'], 'guid' => $upload['url']);
     $id = wp_insert_attachment($this->attachment_data, $upload['file'], $this->post_id);
     wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $upload['file']));
     $this->attachment_id = $id;
     set_post_thumbnail($this->post_id, $this->attachment_id);
 }
Exemplo n.º 13
0
 function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create();
     $this->factory->comment->create_post_comments($this->post_id, 15);
 }