Add all WP db variable to the Env.
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
Reference in New Issue
Block a user