Example #1
0
 public function testArrayAccess()
 {
     $this->object['test1'] = 'OK1';
     $this->object->set('test2', 'OK2');
     $this->assertSame('OK1', $this->object->get('test1'));
     $this->assertSame('OK2', $this->object['test2']);
     $this->assertEquals(2, count($this->object));
     $i = 0;
     foreach ($this->object as $v) {
         ++$i;
     }
     $this->assertEquals($i, count($this->object));
     $this->assertSame('OK2', $v);
 }
Example #2
0
 /**
  * render attributes as a string to include in HTML output
  *
  * @return string
  */
 public function renderAttributeString()
 {
     $this->suppressRender($this->suppressList);
     // title attribute needs to be generated if not already set
     if (!$this->has('title')) {
         $this->set('title', $this->getTitle());
     }
     // generate id from name if not already set
     if (!$this->has('id')) {
         $id = $this->get('name');
         if (substr($id, -2) === '[]') {
             $id = substr($id, 0, strlen($id) - 2);
         }
         $this->set('id', $id);
     }
     return parent::renderAttributeString();
 }