3 | | Add new patch and Test. |
| 3 | {{{#!php |
| 4 | <?php |
| 5 | |
| 6 | class SampleTest extends WP_UnitTestCase { |
| 7 | /** |
| 8 | * @var int |
| 9 | */ |
| 10 | public $menu_id; |
| 11 | |
| 12 | function setUp() { |
| 13 | parent::setUp(); |
| 14 | |
| 15 | $this->menu_id = wp_create_nav_menu( rand_str() ); |
| 16 | } |
| 17 | |
| 18 | function test_wp_setup_nav_menu_item_for_post_type_archive() { |
| 19 | |
| 20 | $post_type_slug = rand_str( 12 ); |
| 21 | $post_type_description = rand_str(); |
| 22 | register_post_type( $post_type_slug ,array( |
| 23 | 'public' => true, |
| 24 | 'has_archive' => true, |
| 25 | 'description' => $post_type_description, |
| 26 | 'label' => $post_type_slug |
| 27 | )); |
| 28 | |
| 29 | $post_type_archive_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( |
| 30 | 'menu-item-type' => 'post_type_archive', |
| 31 | 'menu-item-object' => $post_type_slug, |
| 32 | 'menu-item-status' => 'publish' |
| 33 | ) ); |
| 34 | $post_type_archive_item = wp_setup_nav_menu_item( get_post( $post_type_archive_item_id ) ); |
| 35 | |
| 36 | $this->assertEquals( $post_type_slug , $post_type_archive_item->title ); |
| 37 | $this->assertEquals( $post_type_description , $post_type_archive_item->description ); //fail!!! |
| 38 | |
| 39 | } |
| 40 | } |
| 41 | }}} |
| 42 | |
| 43 | |
| 44 | Add new patch and Detailed test. |