Skip to content

Commit

Permalink
Add comment form-related PHPUnit tests.
Browse files Browse the repository at this point in the history
Test 2 methods:
get_comment_form_state_id() and
filter_comment_form_defaults().
  • Loading branch information
Ryan Kienstra committed Mar 28, 2018
1 parent 92ada3b commit 93bf043
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/test-class-amp-theme-support.php
Expand Up @@ -666,7 +666,10 @@ public function test_get_current_canonical_url() {
* @covers AMP_Theme_Support::get_comment_form_state_id()
*/
public function test_get_comment_form_state_id() {
$this->markTestIncomplete();
$post_id = 54;
$this->assertEquals( 'commentform_post_' . $post_id, AMP_Theme_Support::get_comment_form_state_id( $post_id ) );
$post_id = 91542;
$this->assertEquals( 'commentform_post_' . $post_id, AMP_Theme_Support::get_comment_form_state_id( $post_id ) );
}

/**
Expand All @@ -675,7 +678,19 @@ public function test_get_comment_form_state_id() {
* @covers AMP_Theme_Support::filter_comment_form_defaults()
*/
public function test_filter_comment_form_defaults() {
$this->markTestIncomplete();
global $post;
$post = $this->factory()->post->create_and_get(); // WPCS: global override ok.
$title_reply_to = 'Reply To';
$title_reply = 'Reply';
$defaults = AMP_Theme_Support::filter_comment_form_defaults( array(
'title_reply_to' => $title_reply_to,
'title_reply' => $title_reply,
'cancel_reply_before' => '',
'title_reply_before' => '',
) );
$this->assertContains( AMP_Theme_Support::get_comment_form_state_id( get_the_ID() ), $defaults['title_reply_before'] );
$this->assertContains( 'replyToName ?', $defaults['title_reply_before'] );
$this->assertContains( '</span>', $defaults['cancel_reply_before'] );
}

/**
Expand Down

0 comments on commit 93bf043

Please sign in to comment.