Skip to content

Commit d6cf076

Browse files
Check child deletion with both ‘0’ and ‘1’ statuses
1 parent f0d2076 commit d6cf076

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tests/phpunit/tests/comment.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,15 +1678,16 @@ public function test_unspam_should_invalidate_comment_cache() {
16781678
*
16791679
* @covers ::wp_trash_comment
16801680
* @covers ::wp_trash_comment_children
1681+
* @dataProvider data_comment_approved_statuses
16811682
*/
1682-
public function test_wp_trash_comment_trashes_child_notes() {
1683+
public function test_wp_trash_comment_trashes_child_notes( $approved_status ) {
16831684
// Create a parent note (top-level, comment_parent=0).
16841685
$parent_note = self::factory()->comment->create(
16851686
array(
16861687
'comment_post_ID' => self::$post_id,
16871688
'comment_type' => 'note',
16881689
'comment_parent' => 0,
1689-
'comment_approved' => '1',
1690+
'comment_approved' => $approved_status,
16901691
)
16911692
);
16921693

@@ -1696,7 +1697,7 @@ public function test_wp_trash_comment_trashes_child_notes() {
16961697
'comment_post_ID' => self::$post_id,
16971698
'comment_type' => 'note',
16981699
'comment_parent' => $parent_note,
1699-
'comment_approved' => '1',
1700+
'comment_approved' => $approved_status,
17001701
)
17011702
);
17021703

@@ -1705,7 +1706,7 @@ public function test_wp_trash_comment_trashes_child_notes() {
17051706
'comment_post_ID' => self::$post_id,
17061707
'comment_type' => 'note',
17071708
'comment_parent' => $parent_note,
1708-
'comment_approved' => '1',
1709+
'comment_approved' => $approved_status,
17091710
)
17101711
);
17111712

@@ -1714,16 +1715,10 @@ public function test_wp_trash_comment_trashes_child_notes() {
17141715
'comment_post_ID' => self::$post_id,
17151716
'comment_type' => 'note',
17161717
'comment_parent' => $parent_note,
1717-
'comment_approved' => '1',
1718+
'comment_approved' => $approved_status,
17181719
)
17191720
);
17201721

1721-
// Verify initial state - all notes are approved.
1722-
$this->assertSame( '1', get_comment( $parent_note )->comment_approved );
1723-
$this->assertSame( '1', get_comment( $child_note_1 )->comment_approved );
1724-
$this->assertSame( '1', get_comment( $child_note_2 )->comment_approved );
1725-
$this->assertSame( '1', get_comment( $child_note_3 )->comment_approved );
1726-
17271722
// Trash the parent note.
17281723
wp_trash_comment( $parent_note );
17291724

@@ -1736,6 +1731,16 @@ public function test_wp_trash_comment_trashes_child_notes() {
17361731
$this->assertSame( 'trash', get_comment( $child_note_3 )->comment_approved );
17371732
}
17381733

1734+
/**
1735+
* Data provider for test_wp_trash_comment_trashes_child_notes.
1736+
*/
1737+
public function data_comment_approved_statuses() {
1738+
return array(
1739+
array( '1' ),
1740+
array( '0' ),
1741+
);
1742+
}
1743+
17391744
/**
17401745
* Tests that trashing a regular comment does NOT trash its children.
17411746
*
@@ -1771,11 +1776,6 @@ public function test_wp_trash_comment_does_not_trash_child_comments() {
17711776
)
17721777
);
17731778

1774-
// Verify initial state - all comments are approved.
1775-
$this->assertSame( '1', get_comment( $parent_comment )->comment_approved );
1776-
$this->assertSame( '1', get_comment( $child_comment_1 )->comment_approved );
1777-
$this->assertSame( '1', get_comment( $child_comment_2 )->comment_approved );
1778-
17791779
// Trash the parent comment.
17801780
wp_trash_comment( $parent_comment );
17811781

0 commit comments

Comments
 (0)