Wordpress/tests/phpunit/tests/menu/walker-nav-menu-edit.php
Sergey Biryukov e72fff9cef Code Modernization: Replace dirname( __FILE__ ) calls with __DIR__ magic constant.
This avoids the performance overhead of the function call every time `dirname( __FILE__ )` was used instead of `__DIR__`.

This commit also includes:

* Removing unnecessary parentheses from `include`/`require` statements. These are language constructs, not function calls.
* Replacing `include` statements for several files with `require_once`, for consistency:
 * `wp-admin/admin-header.php`
 * `wp-admin/admin-footer.php`
 * `wp-includes/version.php`

Props ayeshrajans, desrosj, valentinbora, jrf, joostdevalk, netweb.
Fixes #48082.

git-svn-id: https://develop.svn.wordpress.org/trunk@47198 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-06 06:31:22 +00:00

61 lines
1.4 KiB
PHP

<?php
/**
* @group menu
* @group walker
*/
class Tests_Menu_Walker_Nav_Menu_Edit extends WP_UnitTestCase {
protected $_wp_nav_menu_max_depth;
function setUp() {
global $_wp_nav_menu_max_depth;
parent::setUp();
/** Walker_Nav_Menu_Edit class */
require_once ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php';
$this->walker = new Walker_Nav_Menu_Edit();
$this->_wp_nav_menu_max_depth = $_wp_nav_menu_max_depth;
}
function tearDown() {
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = $this->_wp_nav_menu_max_depth;
parent::tearDown();
}
/**
* @ticket 36729
*/
function test_original_title_prefix_should_not_be_shown_if_empty() {
$expected = '';
$post_id = $this->factory->post->create();
$item = array(
'classes' => array(),
'description' => '',
'ID' => $post_id,
'menu_item_parent' => 0,
'menu_order' => 0,
'object_id' => $post_id,
'object' => 'post',
'post_excerpt' => get_the_excerpt( $post_id ),
'title' => get_the_title( $post_id ),
'type' => 'foobar',
'type_label' => 'Foo Bar',
'target' => '_blank',
'url' => '',
'xfn' => '',
);
$this->walker->start_el( $expected, (object) $item );
$this->assertNotRegExp( '#<p class="link-to-original">\s*Original: <a href=""></a>#', $expected );
}
}