From 8b9cc8c109d85cd7517c44b8ab6a8ec7a9e206d7 Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 29 Jul 2015 16:35:10 +0200 Subject: [PATCH] Add all WP db variable to the Env. --- lib/config/env.php | 6 ++++++ tests/unit/EnvCest.php | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/config/env.php b/lib/config/env.php index 6d0baf26ec..6bd7aa239e 100644 --- a/lib/config/env.php +++ b/lib/config/env.php @@ -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; } } diff --git a/tests/unit/EnvCest.php b/tests/unit/EnvCest.php index d34ad67a48..66104a1a9c 100644 --- a/tests/unit/EnvCest.php +++ b/tests/unit/EnvCest.php @@ -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() {