WordPress.org

Make WordPress Core

Changeset 467 in tests


Ignore:
Timestamp:
10/25/2011 06:48:27 AM (7 years ago)
Author:
nacin
Message:

Tests for convert_to_screen(). A hook_suffix used to set the current screen, or the resulting screen->id, should be able to be converted to the same WP_Screen object. Exception is ?taxonomy, ?post_type query strings. Add a edit-tags.php text case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_admin_includes_screen.php

    r466 r467  
    66        'edit.php' => array( 'base' => 'edit', 'id' => 'edit-post', 'post_type' => 'post' ),
    77        'post-new.php'=> array( 'action' => 'add', 'base' => 'post', 'id' => 'post', 'post_type' => 'post' ),
     8        'edit-tags.php' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ),
     9        'edit-tags.php?taxonomy=post_tag' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ),
    810        'edit-tags.php?taxonomy=category' => array( 'base' => 'edit-tags', 'id' => 'edit-category', 'post_type' => 'post', 'taxonomy' => 'category' ),
    9         'edit-tags.php?taxonomy=post_tag' => array( 'base' => 'edit-tags', 'id' => 'edit-post_tag', 'post_type' => 'post', 'taxonomy' => 'post_tag' ),
    1011        'upload.php' => array( 'base' => 'upload', 'id' => 'upload' ),
    1112        'media-new.php' => array( 'action' => 'add', 'base' => 'media', 'id' => 'media' ),
     
    7879            if ( isset( $screen->taxonomy ) )
    7980                $this->assertEquals( $screen->taxonomy, $current_screen->taxonomy, $hook_name );
     81
     82            // With convert_to_screen(), the same ID should return the exact $current_screen.
     83            $this->assertSame( $current_screen, convert_to_screen( $screen->id ) );
     84
     85            // With convert_to_screen(), the hook_suffix should return the exact $current_screen.
     86            // But, convert_to_screen() cannot figure out ?taxonomy and ?post_type.
     87            if ( ! $hook['query'] )
     88                $this->assertSame( $current_screen, convert_to_screen( $GLOBALS['hook_suffix'] ) );
    8089        }
    8190    }
Note: See TracChangeset for help on using the changeset viewer.