/**
  * Set up the test fixture
  */
 public function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create();
     $this->img_name = 'image.jpg';
     $this->attachment_id = $this->factory->attachment->create_object($this->img_name, $this->post_id, array('post_mime_type' => 'image/jpeg', 'post_type' => 'attachment'));
 }
Example #2
0
 /**
  * Set up the test fixture
  */
 public function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create();
     $this->field_args = array('name' => 'Name', 'id' => 'test_test', 'type' => 'text', 'attributes' => array('type' => 'number', 'disabled' => 'disabled', 'data-test' => 'data-value', 'data-test' => json_encode(array('name' => 'Name', 'id' => 'test_test', 'type' => 'text'))), 'before_field' => array($this, 'before_field_cb'), 'after_field' => 'after_field_static', 'row_classes' => array($this, 'row_classes_array_cb'), 'default' => array($this, 'cb_to_set_default'), 'render_row_cb' => array($this, 'render_row_cb_test'), 'label_cb' => array($this, 'label_cb_test'));
     $this->object_id = $this->post_id;
     $this->object_type = 'post';
     $this->group = false;
     $this->field = new CMB2_Field(array('object_id' => $this->object_id, 'object_type' => $this->object_type, 'group' => $this->group, 'field_args' => $this->field_args));
 }
Example #3
0
 /**
  * Set up the test fixture
  */
 public function setUp()
 {
     parent::setUp();
     $this->post_id = $this->factory->post->create();
     $this->img_name = 'test-image.jpg';
     $filename = CMB2_TESTDATA . '/images/test-image.jpg';
     $contents = file_get_contents($filename);
     $upload = wp_upload_bits(basename($filename), null, $contents);
     $this->attachment_id = $this->_make_attachment($upload, $this->post_id);
 }
Example #4
0
 /**
  * Set up the test fixture
  */
 public function setUp()
 {
     parent::setUp();
     $this->cmb_id = 'test';
     $this->metabox_array = array('id' => $this->cmb_id, 'fields' => array(array('name' => 'Name', 'description' => 'Description', 'id' => 'test_test', 'type' => 'text', 'before_row' => array($this, 'cmb_before_row'), 'before' => 'testing before', 'after' => array($this, 'cmb_after'), 'after_row' => 'testing after row')));
     $this->metabox_array2 = array('id' => 'test2', 'fields' => array(array('name' => 'Name', 'id' => 'test_test', 'type' => 'text')));
     $this->option_metabox_array = array('id' => 'options_page', 'title' => 'Theme Options Metabox', 'show_on' => array('options-page' => array('theme_options')), 'fields' => array(array('name' => 'Site Background Color', 'desc' => 'field description (optional)', 'id' => 'bg_color', 'type' => 'colorpicker', 'default' => '#ffffff')));
     $this->defaults = array('id' => $this->cmb_id, 'title' => '', 'type' => '', 'object_types' => array(), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'show_on' => array(), 'show_on_cb' => null, 'cmb_styles' => true, 'enqueue_js' => true, 'fields' => array(), 'hookup' => true, 'save_fields' => true, 'closed' => false, 'new_user_section' => 'add-new-user');
     $this->cmb = new CMB2($this->metabox_array);
     $this->options_cmb = new CMB2($this->option_metabox_array);
     $this->opt_set = array('bg_color' => '#ffffff', 'my_name' => 'Justin');
     add_option($this->options_cmb->cmb_id, $this->opt_set);
     $this->post_id = $this->factory->post->create();
 }
Example #5
0
 /**
  * Set up the test fixture
  */
 public function setUp()
 {
     parent::setUp();
     $this->cmb_id = 'test';
     $this->text_type_field = array('name' => 'Name', 'desc' => 'This is a description', 'id' => 'field_test_field', 'type' => 'text');
     $this->field_test = array('id' => 'field_test', 'fields' => array($this->text_type_field));
     $this->attributes_test = array('id' => 'attributes_test', 'fields' => array(array('name' => 'Name', 'desc' => 'This is a description', 'id' => 'attributes_test_field', 'type' => 'text', 'attributes' => array('type' => 'number', 'disabled' => 'disabled', 'id' => 'arbitrary-id', 'data-test' => json_encode(array('one' => 'One', 'two' => 'Two', 'true' => true, 'false' => false, 'array' => array('nested_data' => true)))))));
     $this->options_test = array('id' => 'options_test', 'fields' => array(array('name' => 'Name', 'description' => 'This is a description', 'id' => 'options_test_field', 'type' => 'select', 'options' => array('one' => 'One', 'two' => 'Two', 'true' => true, 'false' => false))));
     $this->options_cb_test = array('id' => 'options_cb_test', 'fields' => array(array('name' => 'Name', 'description' => 'This is a description', 'id' => 'options_cb_test_field', 'type' => 'select', 'options_cb' => array($this, 'options_cb'))));
     $this->options_cb_and_array_test = array('id' => 'options_cb_and_array_test', 'fields' => array(array('name' => 'Name', 'description' => 'This is a description', 'id' => 'options_cb_and_array_test_field', 'type' => 'select', 'options' => array('one' => 'One', 'two' => 'Two', 'true' => true, 'false' => false), 'options_cb' => array($this, 'options_cb'))));
     $this->post_id = $this->factory->post->create();
     $this->term = $this->factory->term->create(array('taxonomy' => 'category', 'name' => 'test_category'));
     $this->term2 = $this->factory->term->create(array('taxonomy' => 'category', 'name' => 'number_2'));
     wp_set_object_terms($this->post_id, 'test_category', 'category');
     $this->img_name = 'image.jpg';
     $this->attachment_id = $this->factory->attachment->create_object($this->img_name, $this->post_id, array('post_mime_type' => 'image/jpeg', 'post_type' => 'attachment'));
     $this->attachment_id2 = $this->factory->attachment->create_object('2nd-' . $this->img_name, $this->post_id, array('post_mime_type' => 'image/jpeg', 'post_type' => 'attachment'));
 }