walker-nav-menu-edit.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @group menu
  4. * @group walker
  5. */
  6. class Tests_Menu_Walker_Nav_Menu_Edit extends WP_UnitTestCase {
  7. protected $_wp_nav_menu_max_depth;
  8. function setUp() {
  9. global $_wp_nav_menu_max_depth;
  10. parent::setUp();
  11. /** Walker_Nav_Menu_Edit class */
  12. require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php';
  13. $this->walker = new Walker_Nav_Menu_Edit();
  14. $this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth;
  15. }
  16. function tearDown() {
  17. global $_wp_nav_menu_max_depth;
  18. $_wp_nav_menu_max_depth = $this->_wp_nav_menu_max_depth;
  19. parent::tearDown();
  20. }
  21. /**
  22. * @ticket 36729
  23. */
  24. function test_original_title_prefix_should_not_be_shown_if_empty() {
  25. $expected = '';
  26. $post_id = $this->factory->post->create();
  27. $item = array(
  28. 'classes' => array(),
  29. 'description' => '',
  30. 'ID' => $post_id,
  31. 'menu_item_parent' => 0,
  32. 'menu_order' => 0,
  33. 'object_id' => $post_id,
  34. 'object' => 'post',
  35. 'post_excerpt' => get_the_excerpt( $post_id ),
  36. 'title' => get_the_title( $post_id ),
  37. 'type' => 'foobar',
  38. 'type_label' => 'Foo Bar',
  39. 'target' => '_blank',
  40. 'url' => '',
  41. 'xfn' => '',
  42. );
  43. $this->walker->start_el( $expected, (object) $item );
  44. $this->assertNotRegExp( '#<p class="link-to-original">\s*Original: <a href=""></a>#', $expected );
  45. }
  46. }