Skip to content

Commit

Permalink
added test for wp_find_hierarchy_loop
Browse files Browse the repository at this point in the history
  • Loading branch information
pbearne committed Nov 13, 2023
1 parent cfecc5c commit f5842a1
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/phpunit/tests/functions/wpFindHierarchyLoop.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* Tests for the wp_find_hierarchy_loop function.
*
* @group Functions.php
*
* @covers ::wp_find_hierarchy_loop
*/
class Tests_Functions_wpFindHierarchyLoop extends WP_UnitTestCase {

/**
* @ticket 59901
*/
public function test_wp_find_hierarchy_loop() {
$result = wp_find_hierarchy_loop(
static function ( $id ) {
return 1;
},
1,
2
);
$expected = array(
1 => true,
2 => true,
);
$this->assertSame( $expected, $result );
}

/**
* @ticket 59901
*/
public function test_wp_find_hierarchy_loop_null_parent() {
$result = wp_find_hierarchy_loop(
static function ( $id ) {
return 1;
},
1,
null
);
$expected = array(
1 => true,
);
$this->assertSame( $expected, $result );
}
}

0 comments on commit f5842a1

Please sign in to comment.