|
@@ 193-216 (lines=24) @@
|
| 190 |
|
* |
| 191 |
|
* @author tonykova |
| 192 |
|
*/ |
| 193 |
|
public function test_process_submission_will_store_subject_with_token_replaced_from_name_and_text_field() { |
| 194 |
|
// Fill field values. |
| 195 |
|
$this->add_field_values( |
| 196 |
|
array( |
| 197 |
|
'name' => 'John Doe', |
| 198 |
|
'state' => 'Kansas', |
| 199 |
|
) |
| 200 |
|
); |
| 201 |
|
|
| 202 |
|
$form = new Grunion_Contact_Form( array( 'subject' => 'Hello {name} from {state}!' ), "[contact-field label='Name' type='name' required='1'/][contact-field label='State' type='text'/]" ); |
| 203 |
|
|
| 204 |
|
$result = $form->process_submission(); |
| 205 |
|
|
| 206 |
|
// Processing should be successful and produce the success message. |
| 207 |
|
$this->assertTrue( is_string( $result ) ); |
| 208 |
|
|
| 209 |
|
$feedback = get_posts( array( 'post_type' => 'feedback' ) ); |
| 210 |
|
$this->assertSame( 1, count( $feedback ), 'There should be one feedback after process_submission' ); |
| 211 |
|
|
| 212 |
|
// Default metadata should be saved. |
| 213 |
|
$submission = $feedback[0]; |
| 214 |
|
|
| 215 |
|
$this->assertContains( 'SUBJECT: Hello John Doe from Kansas!', $submission->post_content, 'The stored subject didn\'t match the given' ); |
| 216 |
|
} |
| 217 |
|
|
| 218 |
|
/** |
| 219 |
|
* Tests that the submission will store the subject with a token replaced using the radio button field. |
|
@@ 223-245 (lines=23) @@
|
| 220 |
|
* |
| 221 |
|
* @author tonykova |
| 222 |
|
*/ |
| 223 |
|
public function test_process_submission_will_store_subject_with_token_replaced_from_radio_button_field() { |
| 224 |
|
// Fill field values. |
| 225 |
|
$this->add_field_values( |
| 226 |
|
array( |
| 227 |
|
'name' => 'John Doe', |
| 228 |
|
'state' => 'Kansas', |
| 229 |
|
) |
| 230 |
|
); |
| 231 |
|
|
| 232 |
|
$form = new Grunion_Contact_Form( array( 'subject' => 'Hello {name} from {state}!' ), "[contact-field label='Name' type='name' required='1'/][contact-field label='State' type='radio' options='Kansas,California'/]" ); |
| 233 |
|
$result = $form->process_submission(); |
| 234 |
|
|
| 235 |
|
// Processing should be successful and produce the success message. |
| 236 |
|
$this->assertTrue( is_string( $result ) ); |
| 237 |
|
|
| 238 |
|
$feedback = get_posts( array( 'post_type' => 'feedback' ) ); |
| 239 |
|
$this->assertSame( 1, count( $feedback ), 'There should be one feedback after process_submission' ); |
| 240 |
|
|
| 241 |
|
// Default metadata should be saved. |
| 242 |
|
$submission = $feedback[0]; |
| 243 |
|
|
| 244 |
|
$this->assertContains( 'SUBJECT: Hello John Doe from Kansas!', $submission->post_content, 'The stored subject didn\'t match the given' ); |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
/** |
| 248 |
|
* Tests that the submission will store the subject with a token replaced using the dropdown field. |
|
@@ 252-274 (lines=23) @@
|
| 249 |
|
* |
| 250 |
|
* @author tonykova |
| 251 |
|
*/ |
| 252 |
|
public function test_process_submission_will_store_subject_with_token_replaced_from_dropdown_field() { |
| 253 |
|
// Fill field values. |
| 254 |
|
$this->add_field_values( |
| 255 |
|
array( |
| 256 |
|
'name' => 'John Doe', |
| 257 |
|
'state' => 'Kansas', |
| 258 |
|
) |
| 259 |
|
); |
| 260 |
|
|
| 261 |
|
$form = new Grunion_Contact_Form( array( 'subject' => 'Hello {name} from {state}!' ), "[contact-field label='Name' type='name' required='1'/][contact-field label='State' type='select' options='Kansas,California'/]" ); |
| 262 |
|
$result = $form->process_submission(); |
| 263 |
|
|
| 264 |
|
// Processing should be successful and produce the success message. |
| 265 |
|
$this->assertTrue( is_string( $result ) ); |
| 266 |
|
|
| 267 |
|
$feedback = get_posts( array( 'post_type' => 'feedback' ) ); |
| 268 |
|
$this->assertSame( 1, count( $feedback ), 'There should be one feedback after process_submission' ); |
| 269 |
|
|
| 270 |
|
// Default metadata should be saved. |
| 271 |
|
$submission = $feedback[0]; |
| 272 |
|
|
| 273 |
|
$this->assertContains( 'SUBJECT: Hello John Doe from Kansas!', $submission->post_content, 'The stored subject didn\'t match the given' ); |
| 274 |
|
} |
| 275 |
|
|
| 276 |
|
/** |
| 277 |
|
* Tests the form submission will store the fields and their values in the post content. |