public function testToArray()
 {
     $obj = new stdClass();
     $collection = new OrderedMap(array('test', 12, $obj));
     $array = $collection->toArray();
     $this->assertTrue(is_array($array));
     $this->assertSame(3, count($array));
     $this->assertSame($obj, $array[2]);
 }
Example #2
0
 /**
  * @see \Ableron\Core\Form\FormInterface::getOpenTag()
  */
 public function getOpenTag()
 {
     // get form attributes
     $formAttributes = $this->attributes->toArray();
     // if name is set but and id is not, treat element name as id
     if (!$this->attributes->containsKey('id') && $this->attributes->containsKey(self::ATTR_NAME)) {
         $formAttributes['id'] = $this->attributes->get([self::ATTR_NAME]);
     }
     // declare attribute strings
     $attributeStrings = array();
     // build attribute string
     foreach ($formAttributes as $formAttributeName => $formAttributeValue) {
         // make key lower case
         $formAttributeName = StringUtil::toLowerCase($formAttributeName);
         // skip boolean attributes which values are "false" (false = default)
         if ($formAttributeValue === false) {
             continue;
         }
         // compose attribute
         $attributeStrings[] = sprintf('%s="%s"', StringUtil::encodeHtml($formAttributeName), StringUtil::encodeHtml($formAttributeValue));
     }
     // build final HTML tag
     return sprintf('<form %s>', implode(' ', $attributeStrings));
 }
Example #3
0
 /**
  * Tests whether removeByValue() removed all elements with the given value.
  *
  * @return void
  */
 public function testRemoveByValueRemovesAllMatchingElements()
 {
     $map = new OrderedMap(array('foo' => 'bar', 'bar' => 'bar', 'baz' => 'bar', 'foobar' => 'foobarbaz'));
     $this->assertSame(array('foo' => 'bar', 'bar' => 'bar', 'baz' => 'bar', 'foobar' => 'foobarbaz'), $map->toArray());
     $map->removeByValue('bar');
     $this->assertSame(array('foobar' => 'foobarbaz'), $map->toArray());
 }