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)
4343 return null ;
4444 }
4545
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+
4657 /**
4758 * Gets a config value with html characters encoded
4859 *
@@ -76,4 +87,23 @@ public function getConfig()
7687 {
7788 return $ this ->currentConfig ;
7889 }
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+ }
79109}
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ public static function setUpBeforeClass()
1111 Helper::setUp ();
1212 }
1313
14+ public function tearDown ()
15+ {
16+ // clear config on tear down
17+ Helper::clearClass ('_GlobalConfig ' );
18+ }
19+
1420 /**
1521 * @group parse-config
1622 */
@@ -52,4 +58,18 @@ public function testEscapeConfig()
5258 // check normal value
5359 $ this ->assertEquals ('bar ' , $ config ->escape ('foo ' ));
5460 }
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+ }
5575}
You can’t perform that action at this time.
0 commit comments