Skip to content

Commit

Permalink
CMB2_Option::get_options should cast CMB2_Option::$options to array, …
Browse files Browse the repository at this point in the history
…not just the return. Fixes CMB2#993
  • Loading branch information
jtsternberg committed Jul 7, 2017
1 parent 0ef40fd commit ed2e58f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion includes/CMB2_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ public function get_options( $default = null ) {
}
}

return (array) $this->options;
$this->options = (array) $this->options;

return $this->options;
}

}
11 changes: 11 additions & 0 deletions tests/test-cmb-options.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ public function test_cmb2_get_option_bad_value() {
$opts->set( $this->opt_set );
}

public function test_cmb2_remove_option_bad_value() {
$opts = cmb2_options( $this->options_cmb->cmb_id );
$opts->delete_option();

$val = $opts->remove( 'my_name' );

$this->assertSame( array(), $val );

$opts->set( $this->opt_set );
}

public function test_cmb2_update_option() {
$new_value = 'James';

Expand Down

0 comments on commit ed2e58f

Please sign in to comment.