Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/phpunit/tests/user/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,8 @@

// Add 'edit_foobars' primitive cap to a user.
$admin->add_cap( 'edit_foobars', true );
$admin = new WP_User( $admin->ID );

Check warning on line 1408 in tests/phpunit/tests/user/capabilities.php

View workflow job for this annotation

GitHub Actions / Coding standards / PHP checks

Equals sign not aligned with surrounding assignments; expected 24 spaces but found 1 space
self::$users['administrator'] = $admin;
$this->assertTrue( $admin->has_cap( $cap->create_posts ) );
$this->assertFalse( $author->has_cap( $cap->create_posts ) );
$this->assertFalse( $editor->has_cap( $cap->create_posts ) );
Expand Down
7 changes: 6 additions & 1 deletion tests/phpunit/tests/user/countUserPosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ public function test_count_user_posts_for_non_existent_user() {
*/
public function test_count_user_posts_for_user_created_after_being_assigned_posts() {
global $wpdb;
$next_user_id = (int) $wpdb->get_var( "SELECT `auto_increment` FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '$wpdb->users'" );
$next_user_id = (int) $wpdb->get_var(
$wpdb->prepare(
'SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = %s',
$wpdb->users
)
);

// Assign post to next user.
self::factory()->post->create(
Expand Down
43 changes: 27 additions & 16 deletions tests/phpunit/tests/user/mapMetaCap.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,22 +336,6 @@ public function test_unfiltered_html_cap() {
}
}

/**
* @ticket 20488
*/
public function test_file_edit_caps_not_reliant_on_unfiltered_html_constant() {
$this->assertFalse( defined( 'DISALLOW_FILE_MODS' ) );
$this->assertFalse( defined( 'DISALLOW_FILE_EDIT' ) );

if ( ! defined( 'DISALLOW_UNFILTERED_HTML' ) ) {
define( 'DISALLOW_UNFILTERED_HTML', true );
}

$this->assertTrue( DISALLOW_UNFILTERED_HTML );
$this->assertSame( array( 'update_core' ), map_meta_cap( 'update_core', self::$user_id ) );
$this->assertSame( array( 'edit_plugins' ), map_meta_cap( 'edit_plugins', self::$user_id ) );
}

/**
* Test a post without an author.
*
Expand Down Expand Up @@ -458,3 +442,30 @@ public function data_meta_caps_throw_doing_it_wrong_without_required_argument_pr
);
}
}

/**
* @group user
* @group capabilities
* @covers ::map_meta_cap
*/
class Tests_User_MapMetaCap_Constants extends WP_UnitTestCase {

/**
* @ticket 20488
*
* @runInSeparateProcess
* @preserveGlobalState disabled
*/
public function test_file_edit_caps_not_reliant_on_unfiltered_html_constant() {
$this->assertFalse( defined( 'DISALLOW_FILE_MODS' ) );
$this->assertFalse( defined( 'DISALLOW_FILE_EDIT' ) );

if ( ! defined( 'DISALLOW_UNFILTERED_HTML' ) ) {
define( 'DISALLOW_UNFILTERED_HTML', true );
}

$this->assertTrue( DISALLOW_UNFILTERED_HTML );
$this->assertSame( array( 'update_core' ), map_meta_cap( 'update_core', 0 ) );
$this->assertSame( array( 'edit_plugins' ), map_meta_cap( 'edit_plugins', 0 ) );
}
}
12 changes: 6 additions & 6 deletions tests/phpunit/tests/user/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1656,20 +1656,20 @@
*/
public function test_search_by_display_name_only() {

$new_user1 = self::factory()->user->create(
$new_user1 = self::factory()->user->create(

Check warning on line 1659 in tests/phpunit/tests/user/query.php

View workflow job for this annotation

GitHub Actions / Coding standards / PHP checks

Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
array(
'user_login' => 'name1',
'display_name' => 'Sophia Andresen',
)
);
self::$author_ids[] = $new_user1;
$author_ids = array_merge( self::$author_ids, array( $new_user1 ) );

$q = new WP_User_Query(
array(
'search' => '*Sophia*',
'fields' => '',
'search_columns' => array( 'display_name' ),
'include' => self::$author_ids,
'include' => $author_ids,
)
);

Expand All @@ -1684,20 +1684,20 @@
*/
public function test_search_by_display_name_only_ignore_others() {

$new_user1 = self::factory()->user->create(
$new_user1 = self::factory()->user->create(

Check warning on line 1687 in tests/phpunit/tests/user/query.php

View workflow job for this annotation

GitHub Actions / Coding standards / PHP checks

Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space
array(
'user_login' => 'Sophia Andresen',
'display_name' => 'name1',
)
);
self::$author_ids[] = $new_user1;
$author_ids = array_merge( self::$author_ids, array( $new_user1 ) );

$q = new WP_User_Query(
array(
'search' => '*Sophia*',
'fields' => '',
'search_columns' => array( 'display_name' ),
'include' => self::$author_ids,
'include' => $author_ids,
)
);

Expand Down
Loading