File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Parse ;
4
+
5
+ /**
6
+ * ParseConfig - For accessing Parse Config settings
7
+ *
8
+ * @package Parse
9
+ * @author Fosco Marotto <fjm@fb.com>
10
+ */
11
+ class ParseConfig {
12
+
13
+ private $ currentConfig ;
14
+
15
+ /**
16
+ * Creates
17
+ */
18
+ public function __construct () {
19
+ $ result = ParseClient::_request ("GET " , "/1/config " );
20
+ $ this ->setConfig ($ result ['params ' ]);
21
+ }
22
+
23
+ public function get ($ key ) {
24
+ if (isset ($ this ->currentConfig [$ key ])) {
25
+ return $ this ->currentConfig [$ key ];
26
+ }
27
+ return null ;
28
+ }
29
+
30
+ public function escape ($ key ) {
31
+ if (isset ($ this ->currentConfig [$ key ])) {
32
+ return htmlentities ($ this ->currentConfig [$ key ]);
33
+ }
34
+ return null ;
35
+ }
36
+
37
+ protected function setConfig ($ config ) {
38
+ $ this ->currentConfig = $ config ;
39
+ }
40
+
41
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Parse \ParseConfig ;
4
+
5
+ require_once 'ParseTestHelper.php ' ;
6
+
7
+ class ParseConfigMock extends ParseConfig {
8
+ public function __construct () {
9
+ $ this ->setConfig (["foo " => "bar " , "some " => 1 ]);
10
+ }
11
+ }
12
+
13
+ class ParseConfigTest extends PHPUnit_Framework_TestCase
14
+ {
15
+
16
+ public function testGetConfig ()
17
+ {
18
+ $ config = new ParseConfigMock ();
19
+ $ this ->assertEquals ("bar " , $ config ->get ("foo " ));
20
+ $ this ->assertEquals (1 , $ config ->get ("some " ));
21
+ }
22
+
23
+ }
You can’t perform that action at this time.
0 commit comments