Permalink
Browse files

First attempt at creating a test case for taxonomy_select with hierarchy

  • Loading branch information...
bignall committed Sep 30, 2016
1 parent 970e397 commit 4f50d203d02a6c80ebb241b7c88a3bb460ec23e8
Showing with 15 additions and 1 deletion.
  1. +1 −1 tests/test-cmb-types-base.php
  2. +14 −0 tests/test-cmb-types.php
@@ -112,7 +112,7 @@ public function setUp() {
$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' ) );
$this->term2 = $this->factory->term->create( array( 'taxonomy' => 'category', 'name' => 'number_2' , 'parent' => 1 ) );
wp_set_object_terms( $this->post_id, 'test_category', 'category' );
View
@@ -531,6 +531,20 @@ public function test_taxonomy_select_field() {
);
}
public function test_taxonomy_select_field_hierarchy() {
$args = $this->options_test['fields'][0];
$args['type'] = 'taxonomy_select';
$args['taxonomy'] = 'category';
$args['hierarchy'] = true;
$field = $this->get_field_object( $args );
$this->assertHTMLstringsAreEqual(
'<select class="cmb2_select" name="options_test_field" id="options_test_field"><option value="" >None</option><optgroup label="test_category"><option value="number_2" >number_2</option></optgroup></select><p class="cmb2-metabox-description">This is a description</p>',
$this->capture_render( array( $this->get_field_type_object( $field ), 'render' ) )
);
}
public function test_radio_field() {
$args = $this->options_test['fields'][0];
$args['type'] = 'radio';

0 comments on commit 4f50d20

Please sign in to comment.