File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,17 @@ public function get($key)
43
43
return null ;
44
44
}
45
45
46
+ /**
47
+ * Sets a config value
48
+ *
49
+ * @param string $key Key to set value on
50
+ * @param mixed $value Value to set
51
+ */
52
+ public function set ($ key , $ value )
53
+ {
54
+ $ this ->currentConfig [$ key ] = $ value ;
55
+ }
56
+
46
57
/**
47
58
* Gets a config value with html characters encoded
48
59
*
@@ -76,4 +87,23 @@ public function getConfig()
76
87
{
77
88
return $ this ->currentConfig ;
78
89
}
90
+
91
+ /**
92
+ * Saves the current config
93
+ *
94
+ * @return bool
95
+ */
96
+ public function save ()
97
+ {
98
+ $ response = ParseClient::_request (
99
+ 'PUT ' ,
100
+ 'config ' ,
101
+ null ,
102
+ json_encode ([
103
+ 'params ' => $ this ->currentConfig
104
+ ]),
105
+ true
106
+ );
107
+ return $ response ['result ' ];
108
+ }
79
109
}
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ public static function setUpBeforeClass()
11
11
Helper::setUp ();
12
12
}
13
13
14
+ public function tearDown ()
15
+ {
16
+ // clear config on tear down
17
+ Helper::clearClass ('_GlobalConfig ' );
18
+ }
19
+
14
20
/**
15
21
* @group parse-config
16
22
*/
@@ -52,4 +58,18 @@ public function testEscapeConfig()
52
58
// check normal value
53
59
$ this ->assertEquals ('bar ' , $ config ->escape ('foo ' ));
54
60
}
61
+
62
+ /**
63
+ * @group parse-config
64
+ */
65
+ public function testSaveConfig ()
66
+ {
67
+ $ config = new ParseConfig ();
68
+ $ this ->assertNull ($ config ->get ('key ' ));
69
+ $ config ->set ('key ' , 'value ' );
70
+ $ config ->save ();
71
+
72
+ $ config = new ParseConfig ();
73
+ $ this ->assertEquals ($ config ->get ('key ' ), 'value ' );
74
+ }
55
75
}
You can’t perform that action at this time.
0 commit comments