@@ -93,6 +93,52 @@ public function testMagicIsset()
9393 $ this ->assertFalse ( isset ( $ Reg1 ->testKey ) );
9494 }
9595
96+ public function testHasMethod ()
97+ {
98+ $ Reg1 = Registry::getInstance ();
99+ $ Reg1 ->reset ();
100+
101+ // Test has() returns false for non-existent key
102+ $ this ->assertFalse ( $ Reg1 ->has ( 'testKey ' ) );
103+
104+ // Set a value using regular method
105+ $ Reg1 ->set ( 'testKey ' , 'test value ' );
106+
107+ // Test has() returns true for existing key
108+ $ this ->assertTrue ( $ Reg1 ->has ( 'testKey ' ) );
109+
110+ // Set another value using magic method
111+ $ Reg1 ->magicKey = 'magic value ' ;
112+
113+ // Test has() works with magic-set values
114+ $ this ->assertTrue ( $ Reg1 ->has ( 'magicKey ' ) );
115+
116+ // Reset and verify has() returns false
117+ $ Reg1 ->reset ();
118+ $ this ->assertFalse ( $ Reg1 ->has ( 'testKey ' ) );
119+ $ this ->assertFalse ( $ Reg1 ->has ( 'magicKey ' ) );
120+ }
121+
122+ public function testHasMethodConsistency ()
123+ {
124+ $ Reg1 = Registry::getInstance ();
125+ $ Reg1 ->reset ();
126+
127+ // has() and isset() should be consistent
128+ $ this ->assertFalse ( $ Reg1 ->has ( 'testKey ' ) );
129+ $ this ->assertFalse ( isset ( $ Reg1 ->testKey ) );
130+
131+ $ Reg1 ->set ( 'testKey ' , 'value ' );
132+
133+ $ this ->assertTrue ( $ Reg1 ->has ( 'testKey ' ) );
134+ $ this ->assertTrue ( isset ( $ Reg1 ->testKey ) );
135+
136+ // Test with null value - both should return true (key exists)
137+ $ Reg1 ->set ( 'nullKey ' , null );
138+ $ this ->assertTrue ( $ Reg1 ->has ( 'nullKey ' ) );
139+ $ this ->assertTrue ( isset ( $ Reg1 ->nullKey ) );
140+ }
141+
96142 public function testMagicMethodsIntegration ()
97143 {
98144 $ Reg1 = Registry::getInstance ();
0 commit comments