@@ -143,9 +143,9 @@ public function testRemove()
143143 $ data ->remove ('d.e.f ' );
144144 $ data ->remove ('empty.path ' );
145145
146- $ this ->assertNull ($ data ->get ('a ' ));
147- $ this ->assertNull ($ data ->get ('b/c ' ));
148- $ this ->assertNull ($ data ->get ('b.d.d3 ' ));
146+ $ this ->assertNull ($ data ->get ('a ' , null ));
147+ $ this ->assertNull ($ data ->get ('b/c ' , null ));
148+ $ this ->assertNull ($ data ->get ('b.d.d3 ' , null ));
149149 $ this ->assertNull (null );
150150 $ this ->assertEquals ('D2 ' , $ data ->get ('b.d.d2 ' ));
151151
@@ -161,6 +161,21 @@ public function testGet()
161161 $ this ->runSampleDataTests ($ data );
162162 }
163163
164+ public function testGetWhenValueDoesNotExist ()
165+ {
166+ $ data = new Data ($ this ->getSampleData ());
167+
168+ // With a default parameter given:
169+ $ this ->assertSame ('DEFAULT ' , $ data ->get ('foo.bar ' , 'DEFAULT ' ));
170+ $ this ->assertSame (false , $ data ->get ('foo.bar ' , false ));
171+ $ this ->assertSame (null , $ data ->get ('foo/bar ' , null ));
172+
173+ // Without a default parameter:
174+ $ this ->expectException (DataException::class);
175+ $ this ->expectExceptionMessage ('No data exists at the given path: "foo » bar" ' );
176+ $ data ->get ('foo.bar ' );
177+ }
178+
164179 public function testHas ()
165180 {
166181 $ data = new Data ($ this ->getSampleData ());
0 commit comments