Пример #1
0
 /**
  * Generated the entry for the users table.
  *
  * @param  string $user_login The user login slug
  *
  * @return array             An associtive array of column/values for the "users" table.
  */
 public static function generateUserTableDataFrom($user_login, array $userData = array())
 {
     $utils = new Slugifier();
     $login = $utils->slugify($user_login);
     $usersTableDefaults = array('user_login' => $login, 'user_pass' => WpPassword::instance()->make($user_login), 'user_nicename' => $user_login, 'user_email' => $login . "@example.com", 'user_url' => "http://{$login}.example.com", 'user_registered' => Date::now(), 'user_activation_key' => '', 'user_status' => '0', 'display_name' => $user_login);
     if (!empty($userData['user_pass'])) {
         $userData['user_pass'] = WpPassword::instance()->make($userData['user_pass']);
     }
     return array_merge($usersTableDefaults, array_intersect_key($userData, $usersTableDefaults));
 }
Пример #2
0
 /**
  * Checks that a user is not in the database.
  *
  * @param  array $criteria An array of search criteria.
  */
 public function dontSeeUserInDatabase(array $criteria)
 {
     $tableName = $this->grabPrefixedTableNameFor('users');
     $allCriteria = $criteria;
     $passwordOk = false;
     if (!empty($criteria['user_pass'])) {
         $userPass = $criteria['user_pass'];
         unset($criteria['user_pass']);
         $hashedPass = $this->grabFromDatabase($tableName, 'user_pass', [$criteria]);
         $passwordOk = WpPassword::instance()->check($userPass, $hashedPass);
     }
     $count = $this->countInDatabase($tableName, $criteria);
     $this->assertTrue(!$passwordOk && $count < 1, 'Unexpectedly found matching records for criteria ' . json_encode($allCriteria) . ' in table ' . $tableName);
 }