public void GetSetting()
        {
            Configuration config = new Configuration("../../Files/wp-config.php");
            string dbName = config.Settings["DB_NAME"];

            Assert.AreEqual("'database'", dbName);
        }
        public void UpdateSettingsFromAnotherFile()
        {
            string[] keys = { "AUTH_KEY", "SECURE_AUTH_KEY", "LOGGED_IN_KEY", "NONCE_KEY", "AUTH_SALT", "SECURE_AUTH_SALT", "LOGGED_IN_SALT", "NONCE_SALT" };
            Configuration config1 = new Configuration("../../Files/wp-config.php");
            Configuration config2 = new Configuration("../../Files/new-wp-config.php");

            config1.UpdateWith(config2);
            config1.Save();

            foreach (var key in keys)
                Assert.AreEqual(config1.Settings[key], config2.Settings[key]);
        }
        public void AddAndRemoveSetting()
        {
            Configuration config = new Configuration("../../Files/wp-config.php");

            string key = "SOMETHING";
            string value = "'cool'";

            config.Settings.Add(key, value);
            config.Save();

            string value2 = config.Settings[key];

            Assert.AreEqual(value, value2);

            config.Settings.Remove(key);
            config.Save();

            Assert.AreEqual(config.Settings.ContainsKey(key), false);
        }
        public void SetSetting()
        {
            Configuration config = new Configuration("../../Files/wp-config.php");

            string key = "DB_NAME";
            string value, value2;
            string newValue = "'hello'";

            value = config.Settings[key];

            config.Settings[key] = newValue;
            config.Save();

            value2 = config.Settings[key];

            Assert.AreEqual(newValue, value2);

            config.Settings[key] = value;
            config.Save();

            value2 = config.Settings[key];

            Assert.AreEqual(value, value2);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Updates the current Configuration settings with the settings of another WordPress
 /// Configuration. Doesn't remove anything.
 /// </summary>
 /// <param name="config">Another instance of Cob.WordPress.Configuration</param>
 public void UpdateWith(Configuration config)
 {
     if (config.FilePath != this.FilePath)
     {
         foreach (var setting in config.Settings)
         {
             if (this.Settings.ContainsKey(setting.Key))
             {
                 if (this.Settings[setting.Key] != setting.Value)
                     this.Settings[setting.Key] = setting.Value;
             }
             else
                 this.Settings.Add(setting.Key, setting.Value);
         }
     }
 }