|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | /** |
9 | | - * Sample test case. |
| 9 | + * @group post |
| 10 | + * @group navmenus |
| 11 | + * @group taxonomy |
| 12 | + * @group walker |
| 13 | + * https://develop.svn.wordpress.org/trunk/tests/phpunit/tests/walker.php |
10 | 14 | */ |
11 | | -class SampleTest extends WP_UnitTestCase { |
12 | | - |
13 | | - /** |
14 | | - * A single example test. |
15 | | - */ |
16 | | - function test_sample() { |
17 | | - // Replace this with some actual testing code. |
18 | | - $this->assertTrue( true ); |
| 15 | +class WP_Test_Bootstrap_NavWalker extends WP_UnitTestCase { |
| 16 | + |
| 17 | + function setUp() { |
| 18 | + $this->walker = new WP_Bootstrap_Navwalker(); |
| 19 | + parent::setUp(); |
| 20 | + } |
| 21 | + |
| 22 | + function test_single_item() { |
| 23 | + $items = array( (object) array( 'id' => 1, 'parent' => 0 ) ); |
| 24 | + $output = $this->walker->walk( $items, 0 ); |
| 25 | + $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); |
| 26 | + $this->assertEquals( '<li>1</li>', $output ); |
| 27 | + } |
| 28 | + |
| 29 | + function test_single_item_flat() { |
| 30 | + $items = array( (object) array( 'id' => 1, 'parent' => 0 ) ); |
| 31 | + $output = $this->walker->walk( $items, -1 ); |
| 32 | + $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); |
| 33 | + $this->assertEquals( '<li>1</li>', $output ); |
| 34 | + } |
| 35 | + |
| 36 | + function test_single_item_depth_1() { |
| 37 | + $items = array( (object) array( 'id' => 1, 'parent' => 0 ) ); |
| 38 | + $output = $this->walker->walk( $items, 1 ); |
| 39 | + $this->assertEquals( 1, $this->walker->get_number_of_root_elements( $items ) ); |
| 40 | + $this->assertEquals( '<li>1</li>', $output ); |
19 | 41 | } |
| 42 | + |
20 | 43 | } |
0 commit comments