Skip to content

Commit

Permalink
Modify and add unit test code
Browse files Browse the repository at this point in the history
  • Loading branch information
mae829 committed Feb 6, 2020
1 parent 34f7e56 commit ef087bb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions php/class-fieldmanager-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function form_element( $value = array() ) {
$preview = '';
}
return sprintf(
'<input type="button" class="fm-media-button button-secondary fm-incrementable" id="%1$s" value="%3$s" data-choose="%7$s" data-update="%8$s" data-preview-size="%6$s" data-mime-type="%9$s" data-queryargs="%10$s" %11$s />
'<input type="button" class="fm-media-button button-secondary fm-incrementable" id="%1$s" value="%3$s" data-choose="%7$s" data-update="%8$s" data-preview-size="%6$s" data-queryargs="%9$s" data-mime-type="%10$s" %11$s />
<input type="hidden" name="%2$s" value="%4$s" class="fm-element fm-media-id" />
<div class="media-wrapper">%5$s</div>',
esc_attr( $this->get_element_id() ),
Expand All @@ -187,8 +187,8 @@ public function form_element( $value = array() ) {
esc_attr( $this->preview_size ),
esc_attr( $this->modal_title ),
esc_attr( $this->modal_button_label ),
esc_attr( $this->mime_type ),
esc_attr( wp_json_encode( $this->queryargs ) ),
esc_attr( $this->mime_type ),
$this->get_element_attributes()
);
}
Expand Down
6 changes: 4 additions & 2 deletions tests/php/test-fieldmanager-media-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function test_basic_render() {
'selected_file_label' => rand_str(),
'remove_media_label' => rand_str(),
'preview_size' => rand_str(),
'queryargs' => rand_str(),
);
$fm = new Fieldmanager_Media( $args );
$context = $fm->add_meta_box( 'Test Media', 'post' );
Expand All @@ -38,11 +39,12 @@ public function test_basic_render() {
$html = ob_get_clean();
$this->assertRegExp(
sprintf(
'#<input type="button" class="[^"]*fm-media-button[^>]+value="%s" data-choose="%s" data-update="%s" data-preview-size="%s" data-mime-type="all" */>#',
'#<input type="button" class="[^"]*fm-media-button[^>]+value="%s" data-choose="%s" data-update="%s" data-preview-size="%s" data-queryargs="%s" data-mime-type="all" */>#',
$args['button_label'],
$args['modal_title'],
$args['modal_button_label'],
$args['preview_size']
$args['preview_size'],
$args['queryargs']
),
$html
);
Expand Down

0 comments on commit ef087bb

Please sign in to comment.