@@ -70,6 +70,14 @@ public function testAddKeyValuePair()
7070 $ this ->assertEquals ('baz ' , $ dot ->get ('foo.bar ' ));
7171 }
7272
73+ public function testAddKeyValuePairWithCustomDelimeter ()
74+ {
75+ $ dot = new Dot ([], '/ ' );
76+ $ dot ->add ('foo/bar ' , 'baz ' );
77+
78+ $ this ->assertEquals ('baz ' , $ dot ->get ('foo/bar ' ));
79+ }
80+
7381 public function testAddValueToExistingKey ()
7482 {
7583 $ dot = new Dot (['foo ' => 'bar ' ]);
@@ -116,6 +124,14 @@ public function testClearKey()
116124 $ this ->assertSame ([], $ dot ->get ('foo.bar ' ));
117125 }
118126
127+ public function testClearKeyWithCustomDelimiter ()
128+ {
129+ $ dot = new Dot (['foo ' => ['bar ' => 'baz ' ]], '/ ' );
130+ $ dot ->clear ('foo/bar ' );
131+
132+ $ this ->assertSame ([], $ dot ->get ('foo/bar ' ));
133+ }
134+
119135 public function testClearNonExistingKey ()
120136 {
121137 $ dot = new Dot ;
@@ -154,6 +170,14 @@ public function testDeleteKey()
154170 $ this ->assertFalse ($ dot ->has ('foo.bar ' ));
155171 }
156172
173+ public function testDeleteKeyWithCustomDelimeter ()
174+ {
175+ $ dot = new Dot (['foo ' => ['bar ' => 'baz ' ]], '/ ' );
176+ $ dot ->delete ('foo/bar ' );
177+
178+ $ this ->assertFalse ($ dot ->has ('foo/bar ' ));
179+ }
180+
157181 public function testDeleteNonExistingKey ()
158182 {
159183 $ dot = new Dot (['foo ' => 'bar ' ]);
@@ -182,15 +206,25 @@ public function testFlatten()
182206 $ this ->assertEquals ('xyz ' , $ flatten ['foo.abc ' ]);
183207 $ this ->assertEquals ('baz ' , $ flatten ['foo.bar.0 ' ]);
184208 }
185-
209+
186210 public function testFlattenWithCustomDelimiter ()
187211 {
188- $ dot = new Dot (['foo ' => ['abc ' => 'xyz ' , 'bar ' => ['baz ' ]]]);
212+ $ dot = new Dot (['foo ' => ['abc ' => 'xyz ' , 'bar ' => ['baz ' ]]], '/ ' );
213+ $ flatten = $ dot ->flatten ();
214+ $ this ->assertEquals ('xyz ' , $ flatten ['foo/abc ' ]);
215+ $ this ->assertEquals ('baz ' , $ flatten ['foo/bar/0 ' ]);
216+ }
217+
218+
219+ public function testFlattenWithDoubleCustomDelimiter ()
220+ {
221+ $ dot = new Dot (['foo ' => ['abc ' => 'xyz ' , 'bar ' => ['baz ' ]]], '/ ' );
189222 $ flatten = $ dot ->flatten ('_ ' );
190223 $ this ->assertEquals ('xyz ' , $ flatten ['foo_abc ' ]);
191224 $ this ->assertEquals ('baz ' , $ flatten ['foo_bar_0 ' ]);
192225 }
193226
227+
194228 /*
195229 * --------------------------------------------------------------
196230 * Get
@@ -532,6 +566,15 @@ public function testSetKeyValuePair()
532566 $ this ->assertEquals ('baz ' , $ dot ->get ('foo.bar ' ));
533567 }
534568
569+ public function testSetKeyValuePairWithCustomDelimiter ()
570+ {
571+ $ dot = new Dot ([], '/ ' );
572+ $ dot ->set ('foo/bar ' , 'baz ' );
573+
574+ $ this ->assertEquals ('baz ' , $ dot ->get ('foo/bar ' ));
575+ }
576+
577+
535578 public function testSetArrayOfKeyValuePairs ()
536579 {
537580 $ dot = new Dot ;
0 commit comments