Skip to content

Commit 1dc60fd

Browse files
committed
Add test for get_json_data
1 parent d0f8da7 commit 1dc60fd

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

projects/packages/forms/tests/php/contact-form/Contact_Form_Test.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,24 @@ public function assertValidCheckboxField( $html, $attributes ) {
16461646
$this->assertEquals( $attributes['labelstyles'] . $attributes['optionstyles'], $styles, 'Label styles don\'t match' );
16471647
}
16481648

1649+
public function test_get_json_data() {
1650+
$current_post = Utility::create_post_context();
1651+
$post_id = Utility::create_legacy_feedback( array( 'email' => '[email protected]' ) );
1652+
Utility::destroy_post_context( $current_post );
1653+
$response = Contact_Form::get_json_data( $post_id );
1654+
1655+
$this->assertIsArray( $response, 'Response should be an instance of Contact_Form_Response' );
1656+
$this->assertEquals(
1657+
array(
1658+
array(
1659+
'label' => 'email',
1660+
'value' => '[email protected]',
1661+
),
1662+
),
1663+
$response
1664+
);
1665+
}
1666+
16491667
/**
16501668
* Tests whether a multifield contact form field is valid.
16511669
*

0 commit comments

Comments
 (0)