/**
  * Prevent generating ids like "0-0" for (grouped) elements named "0"
  * @see http://news.php.net/php.pear.general/31496
  */
 public function testGeneratedIdsShouldNotStartWithNumbers()
 {
     $el = new HTML_QuickForm2_ElementImpl('0');
     $this->assertNotRegExp('/^\\d/', $el->getId());
 }
Пример #2
0
 public function testManualIdsNotReused()
 {
     $usedIds = array('foo-0', 'foo-2', 'foo-bar-0', 'foo-bar-2', 'foo-baz-0-0');
     $names = array('foo', 'foo[bar]', 'foo[baz][]');
     foreach ($usedIds as $id) {
         $elManual = new HTML_QuickForm2_ElementImpl('foo', array('id' => $id));
     }
     foreach ($names as $name) {
         $el = new HTML_QuickForm2_ElementImpl($name);
         $this->assertNotContains($el->getId(), $usedIds);
         $usedIds[] = $el->getId();
         // Duplicate name...
         $el2 = new HTML_QuickForm2_ElementImpl($name);
         $this->assertNotContains($el2->getId(), $usedIds);
         $usedIds[] = $el2->getId();
     }
 }