File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 44
55use PhpPkg \Config \ConfigBox ;
66use PHPUnit \Framework \TestCase ;
7+ use Toolkit \FsUtil \File ;
8+ use function fclose ;
9+ use function fopen ;
710use function vdump ;
811
912/**
@@ -63,4 +66,19 @@ public function testNewFromStrings(): void
6366 $ this ->assertEquals ('val2 ' , $ c ->get ('key2 ' ));
6467 $ this ->assertEquals ('val4 ' , $ c ->get ('key4 ' ));
6568 }
69+
70+ public function testLoadFromStream (): void
71+ {
72+ $ s1 = fopen (__DIR__ . '/testdata/config.json ' , 'rb+ ' );
73+ $ c = ConfigBox::newFromStream (ConfigBox::FORMAT_JSON , $ s1 );
74+ fclose ($ s1 );
75+
76+ $ this ->assertNotEmpty ($ c ->all ());
77+ $ this ->assertEquals ('val at json ' , $ c ->get ('atJson ' ));
78+
79+ $ s2 = fopen (__DIR__ . '/testdata/config.yml ' , 'rb+ ' );
80+ $ c ->loadFromStream (ConfigBox::FORMAT_YML , $ s2 );
81+ fclose ($ s2 );
82+ $ this ->assertEquals ('val at yaml ' , $ c ->get ('atYaml ' ));
83+ }
6684}
Original file line number Diff line number Diff line change 11name : inhere
22age : 89
3- atYaml : value2
3+ atYaml : val at yaml
44
You can’t perform that action at this time.
0 commit comments