コード例 #1
0
 function testSaveValuesOnRepeatable()
 {
     $field = new CMB_Text_Field('foo', 'Title', array(1, 2), array('repeatable' => true));
     $post = reset(get_posts('showposts=1'));
     if (!$post) {
         $this->markTestSkipped('Post not found');
     }
     $field->save($post->ID, array(1, 2));
     $meta = get_post_meta($post->ID, 'foo', false);
     delete_post_meta($post->ID, 'foo');
     // Order is not guerenteed
     sort($meta);
     $this->assertEquals($meta, array(1, 2));
 }
コード例 #2
0
ファイル: testField.php プロジェクト: jewel-theme/wp-radio
 function testNameAttrValue()
 {
     $field = new CMB_Text_Field('foo', 'Text', array(1, 2));
     // Standard use of ID attribute
     $id_attr = $field->get_the_name_attr();
     $this->assertEquals($id_attr, 'foo[cmb-field-0]');
     // Using append
     $id_attr = $field->get_the_name_attr('[bar]');
     $this->assertEquals($id_attr, 'foo[cmb-field-0][bar]');
     // Repeatable
     $field->field_index = 1;
     $id_attr = $field->get_the_name_attr();
     $this->assertEquals($id_attr, 'foo[cmb-field-1]');
 }
コード例 #3
0
 function testNameAttrValue()
 {
     $field = new CMB_Text_Field('foo', 'Text', array(1, 2));
     // Standard use of ID attribute
     $id_attr = $field->get_the_name_attr();
     $this->assertEquals($id_attr, 'foo[cmb-field-0]');
     // Using append
     $id_attr = $field->get_the_name_attr('[bar]');
     $this->assertEquals($id_attr, 'foo[cmb-field-0][bar]');
     // Repeatable
     $field->field_index = 1;
     $id_attr = $field->get_the_name_attr();
     $this->assertEquals($id_attr, 'foo[cmb-field-1]');
     // Test more than 10 fields
     // See https://github.com/humanmade/Custom-Meta-Boxes/pull/164
     $field->field_index = 12;
     $id_attr = $field->get_the_name_attr();
     $this->assertEquals($id_attr, 'foo[cmb-field-12]');
 }
コード例 #4
0
	public function html() {

		$this->args['class'] .= ' cmb_text_small';

		parent::html();

	}