Add all WP db variable to the Env.

This commit is contained in:
marco
2015-07-29 16:35:10 +02:00
parent 0e5f1a74de
commit 8b9cc8c109
2 changed files with 21 additions and 3 deletions

View File

@ -5,9 +5,15 @@ if(!defined('ABSPATH')) exit;
class Env {
public static $db_prefix;
public static $db_host;
public static $db_username;
public static $db_password;
public static function init() {
global $wpdb;
self::$db_prefix = $wpdb->prefix;
self::$db_host = DB_HOST;
self::$db_username = DB_USER;
self::$db_password = DB_PASSWORD;
}
}

View File

@ -4,13 +4,25 @@ use \MailPoet\Config\Env;
class EnvCest {
public function _before() {
global $wpdb;
$this->db_prefix = $wpdb->prefix;
Env::init();
}
public function itCanReturnTheDbPrefix() {
expect(Env::$db_prefix)->equals($this->db_prefix);
global $wpdb;
$db_prefix = $wpdb->prefix;
expect(Env::$db_prefix)->equals($db_prefix);
}
public function itCanReturnTheDbHost() {
expect(Env::$db_host)->equals(DB_HOST);
}
public function itCanReturnTheDbUser() {
expect(Env::$db_username)->equals(DB_USER);
}
public function itCanReturnTheDbPassword() {
expect(Env::$db_password)->equals(DB_PASSWORD);
}
public function _after() {