|
@@ 564-572 (lines=9) @@
|
| 561 |
|
* @author tonykova |
| 562 |
|
* @covers Grunion_Contact_Form_Plugin |
| 563 |
|
*/ |
| 564 |
|
public function test_token_left_intact_when_no_matching_field() { |
| 565 |
|
$plugin = Grunion_Contact_Form_Plugin::init(); |
| 566 |
|
$subject = 'Hello {name}!'; |
| 567 |
|
$field_values = array( |
| 568 |
|
'City' => 'Chicago', |
| 569 |
|
); |
| 570 |
|
|
| 571 |
|
$this->assertEquals( 'Hello {name}!', $plugin->replace_tokens_with_input( $subject, $field_values ) ); |
| 572 |
|
} |
| 573 |
|
|
| 574 |
|
/** |
| 575 |
|
* Tests that token is replaced with an empty string when there is not value in field. |
|
@@ 580-588 (lines=9) @@
|
| 577 |
|
* @author tonykova |
| 578 |
|
* @covers Grunion_Contact_Form_Plugin |
| 579 |
|
*/ |
| 580 |
|
public function test_replaced_with_empty_string_when_no_value_in_field() { |
| 581 |
|
$plugin = Grunion_Contact_Form_Plugin::init(); |
| 582 |
|
$subject = 'Hello {name}!'; |
| 583 |
|
$field_values = array( |
| 584 |
|
'Name' => null, |
| 585 |
|
); |
| 586 |
|
|
| 587 |
|
$this->assertEquals( 'Hello !', $plugin->replace_tokens_with_input( $subject, $field_values ) ); |
| 588 |
|
} |
| 589 |
|
|
| 590 |
|
/** |
| 591 |
|
* Tests that token in curly brackets is replaced with the value when the name has whitespace. |
|
@@ 596-604 (lines=9) @@
|
| 593 |
|
* @author tonykova |
| 594 |
|
* @covers Grunion_Contact_Form_Plugin |
| 595 |
|
*/ |
| 596 |
|
public function test_token_can_replace_entire_subject_with_token_field_whose_name_has_whitespace() { |
| 597 |
|
$plugin = Grunion_Contact_Form_Plugin::init(); |
| 598 |
|
$subject = '{subject token}'; |
| 599 |
|
$field_values = array( |
| 600 |
|
'Subject Token' => 'Chicago', |
| 601 |
|
); |
| 602 |
|
|
| 603 |
|
$this->assertEquals( 'Chicago', $plugin->replace_tokens_with_input( $subject, $field_values ) ); |
| 604 |
|
} |
| 605 |
|
|
| 606 |
|
/** |
| 607 |
|
* Tests that token with curly brackets is replaced with value. |
|
@@ 612-620 (lines=9) @@
|
| 609 |
|
* @author tonykova |
| 610 |
|
* @covers Grunion_Contact_Form_Plugin |
| 611 |
|
*/ |
| 612 |
|
public function test_token_with_curly_brackets_can_be_replaced() { |
| 613 |
|
$plugin = Grunion_Contact_Form_Plugin::init(); |
| 614 |
|
$subject = '{subject {token}}'; |
| 615 |
|
$field_values = array( |
| 616 |
|
'Subject {Token}' => 'Chicago', |
| 617 |
|
); |
| 618 |
|
|
| 619 |
|
$this->assertEquals( 'Chicago', $plugin->replace_tokens_with_input( $subject, $field_values ) ); |
| 620 |
|
} |
| 621 |
|
|
| 622 |
|
/** |
| 623 |
|
* Tests that the field attributes remain the same when no escaping is necessary. |