@@ -24,6 +24,33 @@ public function __isset($name)
2424 }
2525}
2626
27+ class ArrayAccessObject implements \ArrayAccess
28+ {
29+ protected $ data = array (
30+ 'foo ' => 'bar ' ,
31+ );
32+
33+ public function offsetGet ($ name )
34+ {
35+ return $ this ->data [$ name ];
36+ }
37+
38+ public function offsetExists ($ name )
39+ {
40+ return isset ($ this ->data [$ name ]);
41+ }
42+
43+ public function offsetSet ($ name , $ value )
44+ {
45+ $ this ->data [$ name ] = $ value ;
46+ }
47+
48+ public function offsetUnset ($ name )
49+ {
50+ unset($ this ->data [$ name ]);
51+ }
52+ }
53+
2754class DotHelperTest extends \PHPUnit_Framework_TestCase
2855{
2956 protected function getDotHelper ()
@@ -114,4 +141,13 @@ public function testMagicMethod()
114141 $ this ->assertSame ('biz ' , call_user_func ($ dotHelper ($ object , 'bar ' )));
115142 $ this ->assertSame (null , call_user_func ($ dotHelper ($ object , 'biz ' )));
116143 }
144+
145+ public function testArrayAccess ()
146+ {
147+ $ dotHelper = $ this ->getDotHelper ();
148+ $ object = new ArrayAccessObject ();
149+
150+ $ this ->assertSame ('bar ' , $ dotHelper ($ object , 'foo ' ));
151+ $ this ->assertSame (null , $ dotHelper ($ object , 'biz ' ));
152+ }
117153}
0 commit comments