@@ -25,13 +25,32 @@ public function testCheckingWhetherVariableExists()
2525 $ this ->assertFalse ($ envVars ->has ('NON_EXISTING_VARIABLE ' ));
2626 }
2727
28+ public function testCheckingHasWithBadType ()
29+ {
30+ $ envVars = $ this ->envFactory ->create ();
31+
32+ $ this ->assertFalse ($ envVars ->has (123 ));
33+ $ this ->assertFalse ($ envVars ->has (null ));
34+ }
35+
2836 public function testGettingVariableByName ()
2937 {
3038 $ envVars = $ this ->envFactory ->create ();
3139
3240 $ this ->assertSame ('bar ' , $ envVars ->get ('FOO ' ));
3341 }
3442
43+ /**
44+ * @expectedException \InvalidArgumentException
45+ * @expectedExceptionMessage Expected name to be a string.
46+ */
47+ public function testGettingBadVariable ()
48+ {
49+ $ envVars = $ this ->envFactory ->create ();
50+
51+ $ envVars ->get (null );
52+ }
53+
3554 public function testSettingVariable ()
3655 {
3756 $ envVars = $ this ->envFactory ->create ();
@@ -43,6 +62,17 @@ public function testSettingVariable()
4362 $ this ->assertSame ('new ' , $ envVars ->get ('FOO ' ));
4463 }
4564
65+ /**
66+ * @expectedException \InvalidArgumentException
67+ * @expectedExceptionMessage Expected name to be a string.
68+ */
69+ public function testSettingBadVariable ()
70+ {
71+ $ envVars = $ this ->envFactory ->create ();
72+
73+ $ envVars ->set (null , 'foo ' );
74+ }
75+
4676 public function testClearingVariable ()
4777 {
4878 $ envVars = $ this ->envFactory ->create ();
@@ -52,6 +82,17 @@ public function testClearingVariable()
5282 $ this ->assertFalse ($ envVars ->has ('FOO ' ));
5383 }
5484
85+ /**
86+ * @expectedException \InvalidArgumentException
87+ * @expectedExceptionMessage Expected name to be a string.
88+ */
89+ public function testClearingBadVariable ()
90+ {
91+ $ envVars = $ this ->envFactory ->create ();
92+
93+ $ envVars ->clear (null );
94+ }
95+
5596 public function testCannotSetVariableOnImmutableInstance ()
5697 {
5798 $ envVars = $ this ->envFactory ->createImmutable ();
0 commit comments