Skip to content

Commit 193b5da

Browse files
committed
Add dedicated test for get_post_class()
1 parent f329ef5 commit 193b5da

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/phpunit/tests/post/getPostClass.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,27 @@ public function test_taxonomy_classes_hit_cache() {
135135

136136
$this->assertSame( $num_queries, get_num_queries() );
137137
}
138+
139+
/**
140+
* @ticket 64247
141+
*/
142+
public function test_class_list_is_list() {
143+
144+
// Filter 'post_class' to add a duplicate, which should be removed by `array_unique()`, causing a non-indexed array.
145+
add_filter(
146+
'post_class',
147+
function ( $classes ) {
148+
return array_merge(
149+
array( 'duplicate-class', 'duplicate-class' ),
150+
$classes
151+
);
152+
}
153+
);
154+
155+
$class_list = get_post_class( 'original', $this->post_id );
156+
157+
$this->assertTrue( array_is_list( $class_list ), 'Expected get_post_class() to return list.' );
158+
$this->assertContains( 'duplicate-class', $class_list );
159+
$this->assertContains( 'original', $class_list );
160+
}
138161
}

0 commit comments

Comments
 (0)