mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Code is Poetry.
WordPress' code just... wasn't. This is now dealt with. Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS. Fixes #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -53,21 +53,30 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
|
||||
$admin_bar = new WP_Admin_Bar;
|
||||
|
||||
$admin_bar->add_node( array(
|
||||
'id' => 'test-node',
|
||||
'meta' => array( 'class' => 'test-class' ),
|
||||
) );
|
||||
$admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'test-node',
|
||||
'meta' => array( 'class' => 'test-class' ),
|
||||
)
|
||||
);
|
||||
|
||||
$node1 = $admin_bar->get_node( 'test-node' );
|
||||
$this->assertEquals( array( 'class' => 'test-class' ), $node1->meta );
|
||||
|
||||
$admin_bar->add_node( array(
|
||||
'id' => 'test-node',
|
||||
'meta' => array( 'some-meta' => 'value' ),
|
||||
) );
|
||||
$admin_bar->add_node(
|
||||
array(
|
||||
'id' => 'test-node',
|
||||
'meta' => array( 'some-meta' => 'value' ),
|
||||
)
|
||||
);
|
||||
|
||||
$node2 = $admin_bar->get_node( 'test-node' );
|
||||
$this->assertEquals( array( 'class' => 'test-class', 'some-meta' => 'value' ), $node2->meta );
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'class' => 'test-class',
|
||||
'some-meta' => 'value',
|
||||
), $node2->meta
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,9 +137,11 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
* @group ms-required
|
||||
*/
|
||||
public function test_admin_bar_contains_correct_links_for_users_with_no_role_on_blog() {
|
||||
$blog_id = self::factory()->blog->create( array(
|
||||
'user_id' => self::$admin_id,
|
||||
) );
|
||||
$blog_id = self::factory()->blog->create(
|
||||
array(
|
||||
'user_id' => self::$admin_id,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertTrue( user_can( self::$admin_id, 'read' ) );
|
||||
$this->assertTrue( user_can( self::$editor_id, 'read' ) );
|
||||
@@ -178,9 +189,11 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
$this->assertTrue( user_can( self::$admin_id, 'read' ) );
|
||||
$this->assertFalse( user_can( self::$no_role_id, 'read' ) );
|
||||
|
||||
$blog_id = self::factory()->blog->create( array(
|
||||
'user_id' => self::$admin_id,
|
||||
) );
|
||||
$blog_id = self::factory()->blog->create(
|
||||
array(
|
||||
'user_id' => self::$admin_id,
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertTrue( is_user_member_of_blog( self::$admin_id, $blog_id ) );
|
||||
$this->assertFalse( is_user_member_of_blog( self::$no_role_id, $blog_id ) );
|
||||
@@ -272,7 +285,7 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
array(
|
||||
// Empty string.
|
||||
array(
|
||||
'id' => 'test-node',
|
||||
'id' => 'test-node',
|
||||
'meta' => array( 'tabindex' => '' ),
|
||||
),
|
||||
'<div class="ab-item ab-empty-item">',
|
||||
@@ -335,16 +348,19 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
wp_set_current_user( self::$editor_id );
|
||||
|
||||
$post = array(
|
||||
'post_author' => self::$editor_id,
|
||||
'post_status' => 'publish',
|
||||
'post_author' => self::$editor_id,
|
||||
'post_status' => 'publish',
|
||||
'post_content' => 'Post Content',
|
||||
'post_title' => 'Post Title',
|
||||
'post_title' => 'Post Title',
|
||||
);
|
||||
$id = wp_insert_post( $post );
|
||||
$id = wp_insert_post( $post );
|
||||
|
||||
// Set queried object to the newly created post.
|
||||
global $wp_the_query;
|
||||
$wp_the_query->queried_object = (object) array( 'ID' => $id, 'post_type' => 'post' );
|
||||
$wp_the_query->queried_object = (object) array(
|
||||
'ID' => $id,
|
||||
'post_type' => 'post',
|
||||
);
|
||||
|
||||
$wp_admin_bar = $this->get_standard_admin_bar();
|
||||
|
||||
@@ -360,7 +376,10 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
|
||||
// Set queried object to a non-existing post.
|
||||
global $wp_the_query;
|
||||
$wp_the_query->queried_object = (object) array( 'ID' => 0, 'post_type' => 'post' );
|
||||
$wp_the_query->queried_object = (object) array(
|
||||
'ID' => 0,
|
||||
'post_type' => 'post',
|
||||
);
|
||||
|
||||
$wp_admin_bar = $this->get_standard_admin_bar();
|
||||
|
||||
@@ -471,11 +490,13 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
* @ticket 34113
|
||||
*/
|
||||
public function test_admin_bar_has_no_archives_link_for_non_public_cpt() {
|
||||
register_post_type( 'foo-non-public', array(
|
||||
'public' => false,
|
||||
'has_archive' => true,
|
||||
'show_in_admin_bar' => true,
|
||||
) );
|
||||
register_post_type(
|
||||
'foo-non-public', array(
|
||||
'public' => false,
|
||||
'has_archive' => true,
|
||||
'show_in_admin_bar' => true,
|
||||
)
|
||||
);
|
||||
|
||||
set_current_screen( 'edit-foo-non-public' );
|
||||
|
||||
@@ -492,11 +513,13 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
* @ticket 34113
|
||||
*/
|
||||
public function test_admin_bar_has_no_archives_link_for_cpt_without_archive() {
|
||||
register_post_type( 'foo-non-public', array(
|
||||
'public' => true,
|
||||
'has_archive' => false,
|
||||
'show_in_admin_bar' => true,
|
||||
) );
|
||||
register_post_type(
|
||||
'foo-non-public', array(
|
||||
'public' => true,
|
||||
'has_archive' => false,
|
||||
'show_in_admin_bar' => true,
|
||||
)
|
||||
);
|
||||
|
||||
set_current_screen( 'edit-foo-non-public' );
|
||||
|
||||
@@ -513,11 +536,13 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
* @ticket 34113
|
||||
*/
|
||||
public function test_admin_bar_has_no_archives_link_for_cpt_not_shown_in_admin_bar() {
|
||||
register_post_type( 'foo-non-public', array(
|
||||
'public' => true,
|
||||
'has_archive' => true,
|
||||
'show_in_admin_bar' => false,
|
||||
) );
|
||||
register_post_type(
|
||||
'foo-non-public', array(
|
||||
'public' => true,
|
||||
'has_archive' => true,
|
||||
'show_in_admin_bar' => false,
|
||||
)
|
||||
);
|
||||
|
||||
set_current_screen( 'edit-foo-non-public' );
|
||||
|
||||
@@ -633,22 +658,26 @@ class Tests_AdminBar extends WP_UnitTestCase {
|
||||
$this->go_to( home_url( "/?customize_changeset_uuid=$uuid" ) );
|
||||
wp_set_current_user( self::$admin_id );
|
||||
|
||||
$this->factory()->post->create( array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_status' => 'auto-draft',
|
||||
'post_name' => $uuid,
|
||||
) );
|
||||
$wp_customize = new WP_Customize_Manager( array(
|
||||
'changeset_uuid' => $uuid,
|
||||
) );
|
||||
$this->factory()->post->create(
|
||||
array(
|
||||
'post_type' => 'customize_changeset',
|
||||
'post_status' => 'auto-draft',
|
||||
'post_name' => $uuid,
|
||||
)
|
||||
);
|
||||
$wp_customize = new WP_Customize_Manager(
|
||||
array(
|
||||
'changeset_uuid' => $uuid,
|
||||
)
|
||||
);
|
||||
$wp_customize->start_previewing_theme();
|
||||
|
||||
set_current_screen( 'front' );
|
||||
$wp_admin_bar = $this->get_standard_admin_bar();
|
||||
$node = $wp_admin_bar->get_node( 'customize' );
|
||||
$node = $wp_admin_bar->get_node( 'customize' );
|
||||
$this->assertNotEmpty( $node );
|
||||
|
||||
$parsed_url = wp_parse_url( $node->href );
|
||||
$parsed_url = wp_parse_url( $node->href );
|
||||
$query_params = array();
|
||||
wp_parse_str( $parsed_url['query'], $query_params );
|
||||
$this->assertEquals( $uuid, $query_params['changeset_uuid'] );
|
||||
|
||||
Reference in New Issue
Block a user