<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[35188] trunk/tests/phpunit/tests/user.php: Unit Tests: create more fixtures for `Tests_User`.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/35188">35188</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/35188","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>wonderboymusic</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-15 05:29:40 +0000 (Thu, 15 Oct 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Unit Tests: create more fixtures for `Tests_User`. When using a factory to create ad hoc users, use the inherited static prop `$static_factory` instead of the instance prop, `$factory`. If 2 factories are used out of sync, the generator sequences diverge and dupes can be created, causing an untold number of unforeseen errors. Yay.
See <a href="https://core.trac.wordpress.org/ticket/30017">#30017</a>, <a href="https://core.trac.wordpress.org/ticket/33968">#33968</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsuserphp">trunk/tests/phpunit/tests/user.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsuserphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user.php 2015-10-15 05:10:32 UTC (rev 35187)
+++ trunk/tests/phpunit/tests/user.php 2015-10-15 05:29:40 UTC (rev 35188)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,13 +5,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @group user
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_User extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ protected static $test_id;
+ protected static $author_id;
+ protected static $_author;
+ protected $author;
</ins><span class="cx" style="display: block; padding: 0 10px"> protected $user_data;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function setUp() {
- parent::setUp();
-
- $this->user_data = array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpSetUpBeforeClass( $factory ) {
+ self::$test_id = $factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'user1',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_nicename' => 'userone',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => 'password',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -20,14 +21,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 'display_name' => 'John Doe',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_email' => 'blackburn@battlefield3.com',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_url' => 'http://tacos.com'
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ) );
+ self::$author_id = $factory->user->create( array( 'role' => 'author' ) );
+ self::$_author = get_user_by( 'ID', self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public static function wpTearDownAfterClass() {
+ $ids = array( self::$test_id, self::$author_id );
+ foreach ( $ids as $id ) {
+ if ( is_multisite() ) {
+ wpmu_delete_user( $id );
+ } else {
+ wp_delete_user( $id );
+ }
+ }
+ }
+
+ function setUp() {
+ parent::setUp();
+
+ $this->author = clone self::$_author;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> function test_get_users_of_blog() {
</span><span class="cx" style="display: block; padding: 0 10px"> // add one of each user role
</span><span class="cx" style="display: block; padding: 0 10px"> $nusers = array();
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( array('administrator', 'editor', 'author', 'contributor', 'subscriber' ) as $role ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = $this->factory->user->create( array( 'role' => $role ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $id = self::$static_factory->user->create( array( 'role' => $role ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $nusers[ $id ] = $id;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -51,54 +71,48 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $key = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px"> $val = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // get an option that doesn't exist
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertFalse(get_user_option($key, $user_id));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertFalse( get_user_option( $key, self::$author_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // set and get
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_option( $user_id, $key, $val );
- $this->assertEquals( $val, get_user_option($key, $user_id) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_option( self::$author_id, $key, $val );
+ $this->assertEquals( $val, get_user_option( $key, self::$author_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // change and get again
</span><span class="cx" style="display: block; padding: 0 10px"> $val2 = rand_str();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_option( $user_id, $key, $val2 );
- $this->assertEquals( $val2, get_user_option($key, $user_id) );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_option( self::$author_id, $key, $val2 );
+ $this->assertEquals( $val2, get_user_option( $key, self::$author_id ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // simple tests for usermeta functions
</span><span class="cx" style="display: block; padding: 0 10px"> function test_usermeta() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px"> $key = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px"> $val = rand_str();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // get a meta key that doesn't exist
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( '', get_user_meta($user_id, $key, true));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // set and get
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $user_id, $key, $val );
- $this->assertEquals( $val, get_user_meta($user_id, $key, true) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( self::$author_id, $key, $val );
+ $this->assertEquals( $val, get_user_meta( self::$author_id, $key, true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // change and get again
</span><span class="cx" style="display: block; padding: 0 10px"> $val2 = rand_str();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $user_id, $key, $val2 );
- $this->assertEquals( $val2, get_user_meta($user_id, $key, true) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( self::$author_id, $key, $val2 );
+ $this->assertEquals( $val2, get_user_meta( self::$author_id, $key, true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // delete and get
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_user_meta( $user_id, $key );
- $this->assertEquals( '', get_user_meta($user_id, $key, true) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_user_meta( self::$author_id, $key );
+ $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // delete by key AND value
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_meta( $user_id, $key, $val );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_meta( self::$author_id, $key, $val );
</ins><span class="cx" style="display: block; padding: 0 10px"> // incorrect key: key still exists
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_user_meta( $user_id, $key, rand_str() );
- $this->assertEquals( $val, get_user_meta($user_id, $key, true) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_user_meta( self::$author_id, $key, rand_str() );
+ $this->assertEquals( $val, get_user_meta( self::$author_id, $key, true ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> // correct key: deleted
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_user_meta( $user_id, $key, $val );
- $this->assertEquals( '', get_user_meta($user_id, $key, true) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_user_meta( self::$author_id, $key, $val );
+ $this->assertEquals( '', get_user_meta( self::$author_id, $key, true ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -111,40 +125,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> rand_str() => 'val-'.rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
-
</del><span class="cx" style="display: block; padding: 0 10px"> // there is already some stuff in the array
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue(is_array(get_user_meta($user_id)));
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( is_array( get_user_meta( self::$author_id ) ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ($vals as $k=>$v)
- update_user_meta( $user_id, $k, $v );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $vals as $k => $v ) {
+ update_user_meta( self::$author_id, $k, $v );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> // get the complete usermeta array
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $out = get_user_meta($user_id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $out = get_user_meta( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // for reasons unclear, the resulting array is indexed numerically; meta keys are not included anywhere.
</span><span class="cx" style="display: block; padding: 0 10px"> // so we'll just check to make sure our values are included somewhere.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ($vals as $k=>$v)
- $this->assertTrue(isset($out[$k]) && $out[$k][0] == $v);
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $vals as $k => $v ) {
+ $this->assertTrue( isset( $out[$k] ) && $out[$k][0] == $v );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> // delete one key and check again
</span><span class="cx" style="display: block; padding: 0 10px"> $keys = array_keys( $vals );
</span><span class="cx" style="display: block; padding: 0 10px"> $key_to_delete = array_pop( $keys );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- delete_user_meta($user_id, $key_to_delete);
- $out = get_user_meta($user_id);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ delete_user_meta( self::$author_id, $key_to_delete );
+ $out = get_user_meta( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> // make sure that key is excluded from the results
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ($vals as $k=>$v) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ($k == $key_to_delete)
- $this->assertFalse(isset($out[$k]));
- else
- $this->assertTrue(isset($out[$k]) && $out[$k][0] == $v);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ($k == $key_to_delete) {
+ $this->assertFalse( isset( $out[$k] ) );
+ } else {
+ $this->assertTrue( isset( $out[$k] ) && $out[$k][0] == $v );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Test property magic functions for property get/set/isset.
</span><span class="cx" style="display: block; padding: 0 10px"> function test_user_properties() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $user->data as $key => $data ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $data, $user->$key );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -168,9 +180,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 20043
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_user_unset() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // New user
- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Test custom fields
</span><span class="cx" style="display: block; padding: 0 10px"> $user->customField = 123;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -204,13 +214,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Test meta property magic functions for property get/set/isset.
</span><span class="cx" style="display: block; padding: 0 10px"> function test_user_meta_properties() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- global $wpdb;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ update_user_option( self::$author_id, 'foo', 'foo', true );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- update_user_option( $user_id, 'foo', 'foo', true );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( isset( $user->foo ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'foo', $user->foo );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -220,8 +227,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @expectedDeprecated WP_User->id
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_id_property_back_compat() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( isset( $user->id ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user->ID, $user->id );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -242,7 +248,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> foreach ( $roles as $role => $level ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => $role ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::$static_factory->user->create( array( 'role' => $role ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $user = new WP_User( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( isset( $user->user_level ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -251,15 +257,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_construction() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
-
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_User', $user );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user->ID );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user2 = new WP_User( 0, $user->user_login );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_User', $user2 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user2->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user2->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user->user_login, $user2->user_login );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user3 = new WP_User();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -268,31 +272,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertFalse( isset( $user3->user_login ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user3->init( $user->data );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user3->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user3->ID );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user4 = new WP_User( $user->user_login );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_User', $user4 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user4->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user4->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user->user_login, $user4->user_login );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user5 = new WP_User( null, $user->user_login );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_User', $user5 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user5->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user5->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user->user_login, $user5->user_login );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user6 = new WP_User( $user );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_User', $user6 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user6->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user6->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user->user_login, $user6->user_login );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user7 = new WP_User( $user->data );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_User', $user7 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user7->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user7->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $user->user_login, $user7->user_login );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_get() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::$static_factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'test_wp_user_get',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => 'password',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -310,7 +314,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_has_prop() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::$static_factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'test_wp_user_has_prop',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => 'password',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -327,7 +331,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_update_user() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::$static_factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'role' => 'author',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => 'test_wp_update_user',
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => 'password',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -363,15 +367,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( 'some test user', $user->get( 'display_name' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // Test update of fields in _get_additional_user_keys()
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_data = array( 'ID' => $user_id, 'use_ssl' => 1, 'show_admin_bar_front' => 1,
- 'rich_editing' => 1, 'first_name' => 'first', 'last_name' => 'last',
- 'nickname' => 'nick', 'comment_shortcuts' => 'true', 'admin_color' => 'classic',
- 'description' => 'describe' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_data = array(
+ 'ID' => $user_id, 'use_ssl' => 1, 'show_admin_bar_front' => 1,
+ 'rich_editing' => 1, 'first_name' => 'first', 'last_name' => 'last',
+ 'nickname' => 'nick', 'comment_shortcuts' => 'true', 'admin_color' => 'classic',
+ 'description' => 'describe'
+ );
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_update_user( $user_data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $user = new WP_User( $user_id );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- foreach ( $user_data as $key => $value )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ foreach ( $user_data as $key => $value ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $value, $user->get( $key ), $key );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -380,7 +387,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> function test_global_userdata() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $userdata, $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'subscriber' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::$static_factory->user->create( array( 'role' => 'subscriber' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> wp_set_current_user( $user_id );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $userdata );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -396,13 +403,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_global_userdata_is_null_when_logged_out() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $userdata;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_set_current_user(0);
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_set_current_user( 0 );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertNull( $userdata );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_exists() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertTrue( $user->exists() );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -420,11 +426,10 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $old_post_id = $id;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array( 'role' => 'author' ) );
- $user = new WP_User( $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = new WP_User( self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $post = array(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'post_author' => $user_id,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'post_author' => self::$author_id,
</ins><span class="cx" style="display: block; padding: 0 10px"> 'post_status' => 'publish',
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_content' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'post_title' => rand_str(),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -439,10 +444,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $authordata );
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'WP_User', $authordata );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $authordata->ID, $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $authordata->ID, self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( $old_post_id )
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( $old_post_id ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> setup_postdata( get_post( $old_post_id ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -456,51 +462,47 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_user_get_data_by_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create();
-
- $user = WP_User::get_data_by( 'id', $user_id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = WP_User::get_data_by( 'id', self::$author_id );
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertInstanceOf( 'stdClass', $user );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $user_id, $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( self::$author_id, $user->ID );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> // @ticket 23480
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = WP_User::get_data_by( 'id', -1 );
- $this->assertEquals( false, $user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user1 = WP_User::get_data_by( 'id', -1 );
+ $this->assertEquals( false, $user1 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = WP_User::get_data_by( 'id', 0 );
- $this->assertEquals( false, $user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user2 = WP_User::get_data_by( 'id', 0 );
+ $this->assertEquals( false, $user2 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = WP_User::get_data_by( 'id', null );
- $this->assertEquals( false, $user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user3 = WP_User::get_data_by( 'id', null );
+ $this->assertEquals( false, $user3 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = WP_User::get_data_by( 'id', '' );
- $this->assertEquals( false, $user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user4 = WP_User::get_data_by( 'id', '' );
+ $this->assertEquals( false, $user4 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = WP_User::get_data_by( 'id', false );
- $this->assertEquals( false, $user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user5 = WP_User::get_data_by( 'id', false );
+ $this->assertEquals( false, $user5 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = WP_User::get_data_by( 'id', @$user->user_nicename );
- $this->assertEquals( false, $user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user6 = WP_User::get_data_by( 'id', $user->user_nicename );
+ $this->assertEquals( false, $user6 );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = WP_User::get_data_by( 'id', 99999 );
- $this->assertEquals( false, $user );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user7 = WP_User::get_data_by( 'id', 99999 );
+ $this->assertEquals( false, $user7 );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 33869
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_user_get_data_by_ID_should_alias_to_id() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $u = $this->factory->user->create();
-
- $user = WP_User::get_data_by( 'ID', $u );
- $this->assertEquals( $u, $user->ID );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = WP_User::get_data_by( 'ID', self::$author_id );
+ $this->assertEquals( self::$author_id, $user->ID );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 21431
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_count_many_users_posts() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id_a = $this->factory->user->create( array( 'role' => 'author' ) );
- $user_id_b = $this->factory->user->create( array( 'role' => 'author' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id_a = self::$static_factory->user->create( array( 'role' => 'author' ) );
+ $user_id_b = self::$static_factory->user->create( array( 'role' => 'author' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> $post_id_a = $this->factory->post->create( array( 'post_author' => $user_id_a ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id_b = $this->factory->post->create( array( 'post_author' => $user_id_b ) );
</span><span class="cx" style="display: block; padding: 0 10px"> $post_id_c = $this->factory->post->create( array( 'post_author' => $user_id_b, 'post_status' => 'private' ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -571,28 +573,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $id1 = wp_insert_user( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => 'password',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user_email' => 'blackburn@battlefield3.com',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user_email' => 'blackburn@battlefield4.com',
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $id1, email_exists( 'blackburn@battlefield3.com' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $id1, email_exists( 'blackburn@battlefield4.com' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $id2 = wp_insert_user( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_login' => rand_str(),
</span><span class="cx" style="display: block; padding: 0 10px"> 'user_pass' => 'password',
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user_email' => 'miller@battlefield3.com',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user_email' => 'miller@battlefield4.com',
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $id2, email_exists( 'miller@battlefield3.com' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $id2, email_exists( 'miller@battlefield4.com' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if( ! is_wp_error( $id2 ) ){
- $return = wp_update_user( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! is_wp_error( $id2 ) ){
+ wp_update_user( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $id2,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user_email' => 'david@battlefield3.com',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user_email' => 'david@battlefield4.com',
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertEquals( $id2, email_exists( 'david@battlefield3.com' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertEquals( $id2, email_exists( 'david@battlefield4.com' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $return = wp_update_user( array(
</span><span class="cx" style="display: block; padding: 0 10px"> 'ID' => $id2,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- 'user_email' => 'blackburn@battlefield3.com',
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ 'user_email' => 'blackburn@battlefield4.com',
</ins><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( ! defined( 'WP_IMPORTING' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertWPError( $return );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -636,7 +639,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 29696
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_user_should_sanitize_user_nicename_parameter() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = $this->factory->user->create_and_get();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = $this->author;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $userdata = $user->to_array();
</span><span class="cx" style="display: block; padding: 0 10px"> $userdata['user_nicename'] = str_replace( '-', '.', $user->user_nicename );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -719,7 +722,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 33793
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $u1 = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $u1 = self::$static_factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_nicename' => str_repeat( 'a', 50 ),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -740,7 +743,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 33793
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_wp_insert_user_should_not_truncate_to_a_duplicate_user_nicename_when_suffix_has_more_than_one_character() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $users = $this->factory->user->create_many( 9, array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $users = self::$static_factory->user->create_many( 4, array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_nicename' => str_repeat( 'a', 50 ),
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -753,14 +756,14 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertNotEmpty( $u );
</span><span class="cx" style="display: block; padding: 0 10px"> $user = new WP_User( $u );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $expected = str_repeat( 'a', 47 ) . '-10';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $expected = str_repeat( 'a', 48 ) . '-5';
</ins><span class="cx" style="display: block; padding: 0 10px"> $this->assertSame( $expected, $user->user_nicename );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> function test_changing_email_invalidates_password_reset_key() {
</span><span class="cx" style="display: block; padding: 0 10px"> global $wpdb;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = $this->factory->user->create_and_get();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = $this->author;
</ins><span class="cx" style="display: block; padding: 0 10px"> $wpdb->update( $wpdb->users, array( 'user_activation_key' => 'key' ), array( 'ID' => $user->ID ) );
</span><span class="cx" style="display: block; padding: 0 10px"> clean_user_cache( $user );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -790,43 +793,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_search_users_login() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = $this->factory->user->create( $this->user_data );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $users = get_users( array( 'search' => 'user1', 'fields' => 'ID' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( in_array( $id, $users ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( in_array( self::$test_id, $users ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_search_users_url() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = $this->factory->user->create( $this->user_data );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $users = get_users( array( 'search' => '*tacos*', 'fields' => 'ID' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( in_array( $id, $users ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( in_array( self::$test_id, $users ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_search_users_email() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = $this->factory->user->create( $this->user_data );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $users = get_users( array( 'search' => '*battle*', 'fields' => 'ID' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( in_array( $id, $users ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( in_array( self::$test_id, $users ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_search_users_nicename() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = $this->factory->user->create( $this->user_data );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $users = get_users( array( 'search' => '*one*', 'fields' => 'ID' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( in_array( $id, $users ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( in_array( self::$test_id, $users ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> public function test_search_users_display_name() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $id = $this->factory->user->create( $this->user_data );
-
</del><span class="cx" style="display: block; padding: 0 10px"> $users = get_users( array( 'search' => '*Doe*', 'fields' => 'ID' ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $this->assertTrue( in_array( $id, $users ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $this->assertTrue( in_array( self::$test_id, $users ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -834,7 +827,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_email_case() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Create a test user with a lower-case email address.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::$static_factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_email' => 'test@test.com',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -853,7 +846,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_email_change() {
</span><span class="cx" style="display: block; padding: 0 10px"> // Create a test user.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user_id = $this->factory->user->create( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user_id = self::$static_factory->user->create( array(
</ins><span class="cx" style="display: block; padding: 0 10px"> 'user_email' => 'test@test.com',
</span><span class="cx" style="display: block; padding: 0 10px"> ) );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -884,10 +877,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $was_admin_email_sent = false;
</span><span class="cx" style="display: block; padding: 0 10px"> $was_user_email_sent = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = $this->factory->user->create( $this->user_data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ wp_new_user_notification( self::$test_id, null, $notify );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp_new_user_notification( $user, null, $notify );
-
</del><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * Check to see if a notification email was sent to the
</span><span class="cx" style="display: block; padding: 0 10px"> * post author `blackburn@battlefield3.com` and and site admin `admin@example.org`.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -943,14 +934,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @expectedDeprecated wp_new_user_notification
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_wp_new_user_notification_old_signature_throws_deprecated_warning() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $user = $this->factory->user->create(
- array(
- 'role' => 'author',
- 'user_login' => 'test_wp_new_user_notification',
- 'user_pass' => 'password',
- 'user_email' => 'test@test.com',
- )
- );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $user = self::$static_factory->user->create( array(
+ 'role' => 'author',
+ 'user_login' => 'test_wp_new_user_notification',
+ 'user_pass' => 'password',
+ 'user_email' => 'test@test.com',
+ ) );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> wp_new_user_notification( $user, 'this_is_deprecated' );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -963,7 +952,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $user = get_userdata( $testuserid );
</span><span class="cx" style="display: block; padding: 0 10px"> $pwd_before = $user->user_pass;
</span><span class="cx" style="display: block; padding: 0 10px"> wp_update_user( $user );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> // Reload the data
</span><span class="cx" style="display: block; padding: 0 10px"> $pwd_after = get_userdata( $testuserid )->user_pass;
</span><span class="cx" style="display: block; padding: 0 10px"> $this->assertEquals( $pwd_before, $pwd_after );
</span></span></pre>
</div>
</div>
</body>
</html>