コード例 #1
0
 /**
  * Create a new WordPress website from scratch
  *
  * @Given /^\w+ have|has a vanilla wordpress installation$/
  */
 public function installWordPress(TableNode $table = null)
 {
     global $wp_rewrite;
     $name = "admin";
     $email = "*****@*****.**";
     $password = "******";
     $username = "******";
     if ($table) {
         $hash = $table->getHash();
         $row = $hash[0];
         $name = $row["name"];
         $username = $row["username"];
         $email = $row["email"];
         $password = $row["password"];
     }
     $mysqli = new \Mysqli(DB_HOST, DB_USER, DB_PASSWORD);
     $value = $mysqli->multi_query(implode("\n", array("DROP DATABASE IF EXISTS " . DB_NAME . ";", "CREATE DATABASE " . DB_NAME . ";")));
     assertTrue($value);
     $mysqli->select_db(DB_NAME);
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     wp_install($name, $username, $email, true, '', $password);
     $wp_rewrite->init();
     $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/');
 }