public function testGetAttribute()
 {
     $vh = new AgaviConfigValueHolder();
     $this->assertNull($vh->getAttribute('attr1'));
     $this->assertSame('default1', $vh->getAttribute('attr1', 'default1'));
     $vh->setAttribute('attr1', 'val1');
     $vh->setAttribute('attr2', 'val2');
     $this->assertSame('val1', $vh->getAttribute('attr1', 'default1'));
     $this->assertSame('val1', $vh->getAttribute('attr1'));
     $this->assertSame('val2', $vh->getAttribute('attr2'));
 }
 /**
  * Returns a properly ordered array of AgaviConfigValueHolder configuration
  * elements for given env and context.
  *
  * @param      AgaviConfigValueHolder The root config element
  * @param      string                 An environment name.
  * @param      string                 A context name.
  * @param      bool                   Whether the parser class should be
  *                                    autoloaded or not.
  *
  * @return     array An array of ConfigValueHolder configuration elements.
  *
  * @author     David Zülke <*****@*****.**>
  * @since      0.11.0
  */
 public function orderConfigurations(AgaviConfigValueHolder $configurations, $environment = null, $context = null, $autoloadParser = true)
 {
     $configs = array();
     if ($configurations->hasAttribute('parent')) {
         $parent = AgaviToolkit::literalize($configurations->getAttribute('parent'));
         $parentConfigs = $this->orderConfigurations(AgaviConfigCache::parseConfig($parent, $autoloadParser, $this->getValidationFile(), $this->parser)->configurations, $environment, $context, $autoloadParser);
         $configs = array_merge($configs, $parentConfigs);
     }
     foreach ($configurations as $cfg) {
         if (!$cfg->hasAttribute('environment') && !$cfg->hasAttribute('context')) {
             $configs[] = $cfg;
         }
     }
     foreach ($configurations as $cfg) {
         if ($environment !== null && $cfg->hasAttribute('environment') && self::testPattern($cfg->getAttribute('environment'), $environment) && !$cfg->hasAttribute('context')) {
             $configs[] = $cfg;
         }
     }
     foreach ($configurations as $cfg) {
         if (!$cfg->hasAttribute('environment') && $context !== null && $cfg->hasAttribute('context') && self::testPattern($cfg->getAttribute('context'), $context)) {
             $configs[] = $cfg;
         }
     }
     foreach ($configurations as $cfg) {
         if ($environment !== null && $cfg->hasAttribute('environment') && self::testPattern($cfg->getAttribute('environment'), $environment) && $context !== null && $cfg->hasAttribute('context') && self::testPattern($cfg->getAttribute('context'), $context)) {
             $configs[] = $cfg;
         }
     }
     return $configs;
 }