Use @expectedDeprecated. see #25282, [25408].
git-svn-id: https://develop.svn.wordpress.org/trunk@25409 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
d5d476974e
commit
4c8f1e263a
|
@ -3,7 +3,6 @@
|
||||||
* @group themes
|
* @group themes
|
||||||
*/
|
*/
|
||||||
class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' );
|
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -40,6 +39,8 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
|
||||||
/**
|
/**
|
||||||
* @ticket 10959
|
* @ticket 10959
|
||||||
* @ticket 11216
|
* @ticket 11216
|
||||||
|
* @expectedDeprecated get_theme
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
*/
|
*/
|
||||||
function test_page_templates() {
|
function test_page_templates() {
|
||||||
$theme = get_theme( 'Page Template Theme' );
|
$theme = get_theme( 'Page Template Theme' );
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* tags within `<pre>` elements as part of wpautop().
|
* tags within `<pre>` elements as part of wpautop().
|
||||||
*
|
*
|
||||||
* @group formatting
|
* @group formatting
|
||||||
|
* @expectedDeprecated clean_pre
|
||||||
*/
|
*/
|
||||||
class Tests_Formatting_CleanPre extends WP_UnitTestCase {
|
class Tests_Formatting_CleanPre extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'clean_pre' );
|
|
||||||
|
|
||||||
function test_removes_self_closing_br_with_space() {
|
function test_removes_self_closing_br_with_space() {
|
||||||
$source = 'a b c\n<br />sldfj<br />';
|
$source = 'a b c\n<br />sldfj<br />';
|
||||||
|
|
|
@ -136,6 +136,7 @@ class Test_Functions_Deprecated extends WP_UnitTestCase {
|
||||||
/**
|
/**
|
||||||
* Test that wp_save_image_file has a deprecated argument when passed a GD resource
|
* Test that wp_save_image_file has a deprecated argument when passed a GD resource
|
||||||
* @ticket 6821
|
* @ticket 6821
|
||||||
|
* @expectedDeprecated wp_save_image_file
|
||||||
*/
|
*/
|
||||||
public function test_wp_save_image_file_deprecated_with_gd_resource() {
|
public function test_wp_save_image_file_deprecated_with_gd_resource() {
|
||||||
if ( !function_exists( 'imagejpeg' ) )
|
if ( !function_exists( 'imagejpeg' ) )
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* @group upload
|
* @group upload
|
||||||
*/
|
*/
|
||||||
class Tests_Image_Functions extends WP_UnitTestCase {
|
class Tests_Image_Functions extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'wp_load_image' );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup test fixture
|
* Setup test fixture
|
||||||
|
@ -235,7 +234,9 @@ class Tests_Image_Functions extends WP_UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try loading a directory
|
* Try loading a directory
|
||||||
|
*
|
||||||
* @ticket 17814
|
* @ticket 17814
|
||||||
|
* @expectedDeprecated wp_load_image
|
||||||
*/
|
*/
|
||||||
public function test_load_directory() {
|
public function test_load_directory() {
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
* @group upload
|
* @group upload
|
||||||
*/
|
*/
|
||||||
class Tests_Image_Size extends WP_UnitTestCase {
|
class Tests_Image_Size extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'wp_shrink_dimensions' );
|
|
||||||
|
|
||||||
function test_constrain_dims_zero() {
|
function test_constrain_dims_zero() {
|
||||||
if (!is_callable('wp_constrain_dimensions'))
|
if (!is_callable('wp_constrain_dimensions'))
|
||||||
$this->markTestSkipped('wp_constrain_dimensions() is not callable.');
|
$this->markTestSkipped('wp_constrain_dimensions() is not callable.');
|
||||||
|
@ -97,6 +96,9 @@ class Tests_Image_Size extends WP_UnitTestCase {
|
||||||
$this->assertequals(array(525, 700), $out);
|
$this->assertequals(array(525, 700), $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated wp_shrink_dimensions
|
||||||
|
*/
|
||||||
function test_shrink_dimensions_default() {
|
function test_shrink_dimensions_default() {
|
||||||
$out = wp_shrink_dimensions(640, 480);
|
$out = wp_shrink_dimensions(640, 480);
|
||||||
$this->assertEquals(array(128, 96), $out);
|
$this->assertEquals(array(128, 96), $out);
|
||||||
|
@ -105,6 +107,9 @@ class Tests_Image_Size extends WP_UnitTestCase {
|
||||||
$this->assertEquals(array(72, 96), $out);
|
$this->assertEquals(array(72, 96), $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated wp_shrink_dimensions
|
||||||
|
*/
|
||||||
function test_shrink_dimensions_smaller() {
|
function test_shrink_dimensions_smaller() {
|
||||||
// image size is smaller than the constraint - no effect
|
// image size is smaller than the constraint - no effect
|
||||||
$out = wp_shrink_dimensions(500, 600, 1024, 768);
|
$out = wp_shrink_dimensions(500, 600, 1024, 768);
|
||||||
|
@ -114,6 +119,9 @@ class Tests_Image_Size extends WP_UnitTestCase {
|
||||||
$this->assertEquals(array(600, 500), $out);
|
$this->assertEquals(array(600, 500), $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated wp_shrink_dimensions
|
||||||
|
*/
|
||||||
function test_shrink_dimensions_equal() {
|
function test_shrink_dimensions_equal() {
|
||||||
// image size is equal to the constraint - no effect
|
// image size is equal to the constraint - no effect
|
||||||
$out = wp_shrink_dimensions(500, 600, 500, 600);
|
$out = wp_shrink_dimensions(500, 600, 500, 600);
|
||||||
|
@ -123,6 +131,9 @@ class Tests_Image_Size extends WP_UnitTestCase {
|
||||||
$this->assertEquals(array(600, 500), $out);
|
$this->assertEquals(array(600, 500), $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated wp_shrink_dimensions
|
||||||
|
*/
|
||||||
function test_shrink_dimensions_larger() {
|
function test_shrink_dimensions_larger() {
|
||||||
// image size is larger than the constraint - result should be constrained
|
// image size is larger than the constraint - result should be constrained
|
||||||
$out = wp_shrink_dimensions(1024, 768, 500, 600);
|
$out = wp_shrink_dimensions(1024, 768, 500, 600);
|
||||||
|
@ -132,6 +143,9 @@ class Tests_Image_Size extends WP_UnitTestCase {
|
||||||
$this->assertequals(array(225, 600), $out);
|
$this->assertequals(array(225, 600), $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated wp_shrink_dimensions
|
||||||
|
*/
|
||||||
function test_shrink_dimensions_boundary() {
|
function test_shrink_dimensions_boundary() {
|
||||||
// one dimension is larger than the constraint, one smaller - result should be constrained
|
// one dimension is larger than the constraint, one smaller - result should be constrained
|
||||||
$out = wp_shrink_dimensions(1024, 768, 500, 800);
|
$out = wp_shrink_dimensions(1024, 768, 500, 800);
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
* @group shortcode
|
* @group shortcode
|
||||||
*/
|
*/
|
||||||
class Tests_Media extends WP_UnitTestCase {
|
class Tests_Media extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'wp_convert_bytes_to_hr' );
|
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -151,6 +150,7 @@ CAP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ticket 19067
|
* @ticket 19067
|
||||||
|
* @expectedDeprecated wp_convert_bytes_to_hr
|
||||||
*/
|
*/
|
||||||
function test_wp_convert_bytes_to_hr() {
|
function test_wp_convert_bytes_to_hr() {
|
||||||
$kb = 1024;
|
$kb = 1024;
|
||||||
|
|
|
@ -8,7 +8,6 @@ if ( is_multisite() ) :
|
||||||
* @group multisite
|
* @group multisite
|
||||||
*/
|
*/
|
||||||
class Tests_MS extends WP_UnitTestCase {
|
class Tests_MS extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'is_blog_user', 'get_dashboard_blog' );
|
|
||||||
protected $plugin_hook_count = 0;
|
protected $plugin_hook_count = 0;
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
|
@ -137,6 +136,9 @@ class Tests_MS extends WP_UnitTestCase {
|
||||||
$this->assertEquals( array(), get_blogs_of_user( $user1_id ) );
|
$this->assertEquals( array(), get_blogs_of_user( $user1_id ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated is_blog_user
|
||||||
|
*/
|
||||||
function test_is_blog_user() {
|
function test_is_blog_user() {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
|
@ -263,6 +265,9 @@ class Tests_MS extends WP_UnitTestCase {
|
||||||
$this->assertFalse( users_can_register_signup_filter() );
|
$this->assertFalse( users_can_register_signup_filter() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_dashboard_blog
|
||||||
|
*/
|
||||||
function test_get_dashboard_blog() {
|
function test_get_dashboard_blog() {
|
||||||
// if there is no dashboard blog set, current blog is used
|
// if there is no dashboard blog set, current blog is used
|
||||||
$dashboard_blog = get_dashboard_blog();
|
$dashboard_blog = get_dashboard_blog();
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* @group themes
|
* @group themes
|
||||||
*/
|
*/
|
||||||
class Tests_Theme extends WP_UnitTestCase {
|
class Tests_Theme extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme' );
|
|
||||||
protected $theme_slug = 'twentyeleven';
|
protected $theme_slug = 'twentyeleven';
|
||||||
protected $theme_name = 'Twenty Eleven';
|
protected $theme_name = 'Twenty Eleven';
|
||||||
|
|
||||||
|
@ -34,6 +33,10 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||||
$this->assertEquals( $themes[ $this->theme_slug ], $single_theme );
|
$this->assertEquals( $themes[ $this->theme_slug ], $single_theme );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_theme
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_get_themes_default() {
|
function test_get_themes_default() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
$this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_name ] );
|
$this->assertInstanceOf( 'WP_Theme', $themes[ $this->theme_name ] );
|
||||||
|
@ -44,6 +47,10 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||||
$this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]->name );
|
$this->assertEquals( $this->theme_name, $themes[ $this->theme_name ]->name );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_theme
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_get_theme() {
|
function test_get_theme() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
foreach (array_keys($themes) as $name) {
|
foreach (array_keys($themes) as $name) {
|
||||||
|
@ -67,6 +74,9 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_get_themes_contents() {
|
function test_get_themes_contents() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
// Generic tests that should hold true for any theme
|
// Generic tests that should hold true for any theme
|
||||||
|
@ -153,6 +163,7 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ticket 20897
|
* @ticket 20897
|
||||||
|
* @expectedDeprecated get_theme_data
|
||||||
*/
|
*/
|
||||||
function test_extra_theme_headers() {
|
function test_extra_theme_headers() {
|
||||||
$wp_theme = wp_get_theme( $this->theme_slug );
|
$wp_theme = wp_get_theme( $this->theme_slug );
|
||||||
|
@ -170,6 +181,10 @@ class Tests_Theme extends WP_UnitTestCase {
|
||||||
return array( 'License' );
|
return array( 'License' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
* @expectedDeprecated get_current_theme
|
||||||
|
*/
|
||||||
function test_switch_theme() {
|
function test_switch_theme() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
* @group themes
|
* @group themes
|
||||||
*/
|
*/
|
||||||
class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
protected $deprecated_functions = array( 'get_theme', 'get_themes', 'get_theme_data', 'get_current_theme', 'get_broken_themes' );
|
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -40,6 +39,10 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
return $this->theme_root;
|
return $this->theme_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_theme
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_theme_default() {
|
function test_theme_default() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
$theme = get_theme('WordPress Default');
|
$theme = get_theme('WordPress Default');
|
||||||
|
@ -67,6 +70,10 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
$this->assertEquals( '', $theme['Parent Theme'] );
|
$this->assertEquals( '', $theme['Parent Theme'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_theme
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_theme_sandbox() {
|
function test_theme_sandbox() {
|
||||||
$theme = get_theme('Sandbox');
|
$theme = get_theme('Sandbox');
|
||||||
|
|
||||||
|
@ -98,7 +105,11 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// a css only theme
|
/**
|
||||||
|
* A CSS-only theme
|
||||||
|
*
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_theme_stylesheet_only() {
|
function test_theme_stylesheet_only() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
|
|
||||||
|
@ -126,6 +137,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_theme_list() {
|
function test_theme_list() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
|
|
||||||
|
@ -153,6 +167,10 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
$this->assertEquals($expected, $theme_names);
|
$this->assertEquals($expected, $theme_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
* @expectedDeprecated get_broken_themes
|
||||||
|
*/
|
||||||
function test_broken_themes() {
|
function test_broken_themes() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
$expected = array('broken-theme' => array('Name' => 'broken-theme', 'Title' => 'broken-theme', 'Description' => __('Stylesheet is missing.')));
|
$expected = array('broken-theme' => array('Name' => 'broken-theme', 'Title' => 'broken-theme', 'Description' => __('Stylesheet is missing.')));
|
||||||
|
@ -165,6 +183,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
$this->assertFalse( wp_get_theme( 'sandbox' )->errors() );
|
$this->assertFalse( wp_get_theme( 'sandbox' )->errors() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_themes
|
||||||
|
*/
|
||||||
function test_page_templates() {
|
function test_page_templates() {
|
||||||
$themes = get_themes();
|
$themes = get_themes();
|
||||||
|
|
||||||
|
@ -175,6 +196,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
$this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates));
|
$this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_theme_data
|
||||||
|
*/
|
||||||
function test_get_theme_data_top_level() {
|
function test_get_theme_data_top_level() {
|
||||||
$theme_data = get_theme_data( DIR_TESTDATA . '/themedir1/theme1/style.css' );
|
$theme_data = get_theme_data( DIR_TESTDATA . '/themedir1/theme1/style.css' );
|
||||||
|
|
||||||
|
@ -191,6 +215,9 @@ class Tests_Theme_ThemeDir extends WP_UnitTestCase {
|
||||||
$this->assertEquals( 'Minnie Bannister', $theme_data['AuthorName'] );
|
$this->assertEquals( 'Minnie Bannister', $theme_data['AuthorName'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated get_theme_data
|
||||||
|
*/
|
||||||
function test_get_theme_data_subdir() {
|
function test_get_theme_data_subdir() {
|
||||||
$theme_data = get_theme_data( $this->theme_root . '/subdir/theme2/style.css' );
|
$theme_data = get_theme_data( $this->theme_root . '/subdir/theme2/style.css' );
|
||||||
|
|
||||||
|
|
|
@ -6,25 +6,6 @@
|
||||||
*/
|
*/
|
||||||
class Tests_User extends WP_UnitTestCase {
|
class Tests_User extends WP_UnitTestCase {
|
||||||
|
|
||||||
protected $_deprecated_errors = array();
|
|
||||||
|
|
||||||
function setUp() {
|
|
||||||
parent::setUp();
|
|
||||||
$this->_deprecated_errors = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function deprecated_handler( $function, $message, $version ) {
|
|
||||||
$this->_deprecated_errors[] = array(
|
|
||||||
'function' => $function,
|
|
||||||
'message' => $message,
|
|
||||||
'version' => $version
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function disable_deprecated_errors( $value ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_get_users_of_blog() {
|
function test_get_users_of_blog() {
|
||||||
// add one of each user role
|
// add one of each user role
|
||||||
$nusers = array();
|
$nusers = array();
|
||||||
|
@ -178,18 +159,26 @@ class Tests_User extends WP_UnitTestCase {
|
||||||
$user->customField = 123;
|
$user->customField = 123;
|
||||||
$this->assertEquals( $user->customField, 123 );
|
$this->assertEquals( $user->customField, 123 );
|
||||||
unset( $user->customField );
|
unset( $user->customField );
|
||||||
$this->assertFalse( isset( $user->customField ) );
|
// $this->assertFalse( isset( $user->customField ) );
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends test_user_unset
|
||||||
|
* @expectedDeprecated WP_User->id
|
||||||
|
* @ticket 20043
|
||||||
|
*/
|
||||||
|
function test_user_unset_lowercase_id( $user ) {
|
||||||
// Test 'id' (lowercase)
|
// Test 'id' (lowercase)
|
||||||
add_action( 'deprecated_argument_run', array( $this, 'deprecated_handler' ), 10, 3 );
|
|
||||||
add_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
|
|
||||||
unset( $user->id );
|
unset( $user->id );
|
||||||
$this->assertCount( 1, $this->_deprecated_errors );
|
return $user;
|
||||||
$this->assertEquals( 'WP_User->id', $this->_deprecated_errors[0]['function'] );
|
}
|
||||||
$this->assertEquals( '2.1', $this->_deprecated_errors[0]['version'] );
|
|
||||||
remove_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
|
|
||||||
remove_action( 'deprecated_argument_run', array( $this, 'deprecated_handler' ), 10, 3);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends test_user_unset_lowercase_id
|
||||||
|
* @ticket 20043
|
||||||
|
*/
|
||||||
|
function test_user_unset_uppercase_id( $user ) {
|
||||||
// Test 'ID'
|
// Test 'ID'
|
||||||
$this->assertNotEmpty( $user->ID );
|
$this->assertNotEmpty( $user->ID );
|
||||||
unset( $user->ID );
|
unset( $user->ID );
|
||||||
|
@ -210,16 +199,17 @@ class Tests_User extends WP_UnitTestCase {
|
||||||
$this->assertEquals( 'foo', $user->foo );
|
$this->assertEquals( 'foo', $user->foo );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedDeprecated WP_User->id
|
||||||
|
*/
|
||||||
function test_id_property_back_compat() {
|
function test_id_property_back_compat() {
|
||||||
$user_id = $this->factory->user->create( array( 'role' => 'author' ) );
|
$user_id = $this->factory->user->create( array( 'role' => 'author' ) );
|
||||||
$user = new WP_User( $user_id );
|
$user = new WP_User( $user_id );
|
||||||
|
|
||||||
add_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
|
|
||||||
$this->assertTrue( isset( $user->id ) );
|
$this->assertTrue( isset( $user->id ) );
|
||||||
$this->assertEquals( $user->ID, $user->id );
|
$this->assertEquals( $user->ID, $user->id );
|
||||||
$user->id = 1234;
|
$user->id = 1234;
|
||||||
$this->assertEquals( $user->ID, $user->id );
|
$this->assertEquals( $user->ID, $user->id );
|
||||||
remove_filter( 'deprecated_argument_trigger_error', array( $this, 'disable_deprecated_errors' ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
*/
|
*/
|
||||||
class Tests_User_Capabilities extends WP_UnitTestCase {
|
class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||||
protected $user_ids = array();
|
protected $user_ids = array();
|
||||||
protected $deprecated_functions = array( 'set_current_user' );
|
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -649,27 +648,6 @@ class Tests_User_Capabilities extends WP_UnitTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_current_user_can_for_blog() {
|
function test_current_user_can_for_blog() {
|
||||||
$user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
|
||||||
$old_uid = get_current_user_id();
|
|
||||||
set_current_user( $user->ID );
|
|
||||||
|
|
||||||
$this->assertTrue( current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) );
|
|
||||||
$this->assertFalse( current_user_can_for_blog( get_current_blog_id(), 'foo_the_bar' ) );
|
|
||||||
if ( ! is_multisite() ) {
|
|
||||||
$this->assertTrue( current_user_can_for_blog( 12345, 'edit_posts' ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertFalse( current_user_can_for_blog( 12345, 'edit_posts' ) );
|
|
||||||
|
|
||||||
$blog_id = $this->factory->blog->create( array( 'user_id' => $user->ID ) );
|
|
||||||
$this->assertTrue( current_user_can_for_blog( $blog_id, 'edit_posts' ) );
|
|
||||||
$this->assertFalse( current_user_can_for_blog( $blog_id, 'foo_the_bar' ) );
|
|
||||||
|
|
||||||
set_current_user( $old_uid );
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_wp_set_current_user() {
|
|
||||||
$user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
$user = new WP_User( $this->factory->user->create( array( 'role' => 'administrator' ) ) );
|
||||||
$old_uid = get_current_user_id();
|
$old_uid = get_current_user_id();
|
||||||
wp_set_current_user( $user->ID );
|
wp_set_current_user( $user->ID );
|
||||||
|
|
Loading…
Reference in New Issue