Skip to content

Commit 6cfa1b9

Browse files
jehervewestonruter
andauthored
More concise expected string building
Co-authored-by: Weston Ruter <[email protected]>
1 parent 2160d0c commit 6cfa1b9

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

tests/phpunit/tests/functions/wpGetArchives.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,15 @@ public function test_wp_get_archives_args_filter() {
218218

219219
$ids = array_slice( array_reverse( self::$post_ids ), 0, 3 );
220220

221-
$link1 = get_permalink( $ids[0] );
222-
$link2 = get_permalink( $ids[1] );
223-
$link3 = get_permalink( $ids[2] );
224-
225-
$title1 = get_post( $ids[0] )->post_title;
226-
$title2 = get_post( $ids[1] )->post_title;
227-
$title3 = get_post( $ids[2] )->post_title;
228-
229-
$expected = <<<EOF
230-
<li><a href='$link1'>$title1</a></li>
231-
<li><a href='$link2'>$title2</a></li>
232-
<li><a href='$link3'>$title3</a></li>
233-
EOF;
221+
$expected = join(
222+
"\n",
223+
array_map(
224+
static function ( $id ) {
225+
return sprintf( '<li><a href="%s">%s</a></li>', get_permalink( $id ), get_the_title( $id ) );
226+
},
227+
$ids
228+
)
229+
);
234230
$archives = wp_get_archives(
235231
array(
236232
'echo' => false,

0 commit comments

Comments
 (0)