Elgg\DeprecationWrapperTest::testArrayAccessProxiesObjectArrayAccessMethods PHP Method

testArrayAccessProxiesObjectArrayAccessMethods() public method

    function testArrayAccessProxiesObjectArrayAccessMethods()
    {
        $file = __FILE__;
        $obj = new DeprecationWrapperTestObj2();
        $obj->data['foo'] = 'test';
        $wrapper = new DeprecationWrapper($obj, 'FOO', 1.9, array($this, 'report'));
        $foo = $wrapper['foo'];
        $line = __LINE__;
        $this->assertEquals('test', $foo);
        $this->assertEquals("{$file}:{$line}", $this->last_stack_line);
        $wrapper[0] = 'value';
        $line = __LINE__;
        $this->assertEquals('value', $obj->data[0]);
        $this->assertEquals("{$file}:{$line}", $this->last_stack_line);
        unset($wrapper[0]);
        $line = __LINE__;
        $this->assertFalse(isset($obj->data[0]));
        $this->assertEquals("{$file}:{$line}", $this->last_stack_line);
        $wrapper[] = 'hello';
        $line = __LINE__;
        $key_created = array_search('hello', $obj->data);
        $this->assertFalse($key_created === false);
        $this->assertTrue($key_created !== '');
        $this->assertEquals("{$file}:{$line}", $this->last_stack_line);
    }