@@ -30,6 +30,17 @@ protected function getSampleData()
3030 ),
3131 ),
3232 'c ' => array ('c1 ' , 'c2 ' , 'c3 ' ),
33+ 'f ' => array (
34+ 'g ' => array (
35+ 'h ' => 'FGH ' ,
36+ ),
37+ ),
38+ 'h ' => array (
39+ 'i ' => 'I ' ,
40+ ),
41+ 'i ' => array (
42+ 'j ' => 'J ' ,
43+ ),
3344 );
3445 }
3546
@@ -41,6 +52,7 @@ protected function runSampleDataTests(DataInterface $data)
4152 $ this ->assertEquals ('D3 ' , $ data ->get ('b.d.d3 ' ));
4253 $ this ->assertEquals (array ('c1 ' , 'c2 ' , 'c3 ' ), $ data ->get ('c ' ));
4354 $ this ->assertNull ($ data ->get ('foo ' ), 'Foo should not exist ' );
55+ $ this ->assertNull ($ data ->get ('f.g.h.i ' ));
4456 }
4557
4658 public function testAppend ()
@@ -54,6 +66,8 @@ public function testAppend()
5466 $ data ->append ('b.d.d4 ' , 'D ' );
5567 $ data ->append ('e ' , 'E ' );
5668 $ data ->append ('f.a ' , 'b ' );
69+ $ data ->append ('h.i ' , 'I2 ' );
70+ $ data ->append ('i.k.l ' , 'L ' );
5771
5872 $ this ->assertEquals (array ('A ' , 'B ' ), $ data ->get ('a ' ));
5973 $ this ->assertEquals (array ('c1 ' , 'c2 ' , 'c3 ' , 'c4 ' ), $ data ->get ('c ' ));
@@ -62,6 +76,8 @@ public function testAppend()
6276 $ this ->assertEquals (array ('D ' ), $ data ->get ('b.d.d4 ' ));
6377 $ this ->assertEquals (array ('E ' ), $ data ->get ('e ' ));
6478 $ this ->assertEquals (array ('b ' ), $ data ->get ('f.a ' ));
79+ $ this ->assertEquals (array ('I ' , 'I2 ' ), $ data ->get ('h.i ' ));
80+ $ this ->assertEquals (array ('L ' ), $ data ->get ('i.k.l ' ));
6581
6682 $ this ->setExpectedException ('RuntimeException ' );
6783
@@ -91,6 +107,17 @@ public function testSet()
91107 $ data ->set ('' , 'broken ' );
92108 }
93109
110+ public function testSetClobberStringInPath ()
111+ {
112+ $ data = new Data ;
113+
114+ $ data ->set ('a.b.c ' , 'Should not be able to write to a.b.c.d.e ' );
115+
116+ $ this ->setExpectedException ('RuntimeException ' );
117+
118+ $ data ->set ('a.b.c.d.e ' , 'broken ' );
119+ }
120+
94121 public function testRemove ()
95122 {
96123 $ data = new Data ($ this ->getSampleData ());
@@ -100,6 +127,7 @@ public function testRemove()
100127 $ data ->remove ('b.d.d3 ' );
101128 $ data ->remove ('d ' );
102129 $ data ->remove ('d.e.f ' );
130+ $ data ->remove ('empty.path ' );
103131
104132 $ this ->assertNull ($ data ->get ('a ' ));
105133 $ this ->assertNull ($ data ->get ('b.c ' ));
0 commit comments