Exemple #1
0
 public function testFormBeanConfig()
 {
     $fpConfig = new FormPropertyConfig();
     $fpConfig->setName('myName');
     $fpConfig->setType(FormPropertyConfig::TYPE_INTEGER);
     $fpConfig->setInitial('2');
     $config = new FormBeanConfig();
     $config->setType('\\MyForm');
     $config->setName('name');
     $config->addFormPropertyConfig($fpConfig);
     $expected = "\\Phruts\\Config\\FormBeanConfig[name='name',type='\\\\MyForm',properties=array (" . "\n" . "  0 => 'myName'," . "\n" . ")]";
     $this->assertEquals($expected, (string) $config);
     $config->setModuleConfig(new ModuleConfig('prefix'));
     $this->assertEquals('prefix', $config->getModuleConfig()->getPrefix());
     $this->assertEquals(1, count($config->findFormPropertyConfigs()));
     $this->assertEquals('2', $config->findFormPropertyConfig('myName')->getInitial());
     // TODO: Test exception
     $config->freeze();
     $this->setExpectedException('\\Phruts\\Exception\\IllegalStateException');
     $config->setModuleConfig(new ModuleConfig('prefix'));
 }
 /**
  * Add a new <code>FormPropertyConfig</code> instance to the set associated
  * with this module.
  *
  * @param config - The new configuration instance to be added
  *
  * @exception \Phruts\Exception\IllegalArgumentException if this property name has already
  *  been defined
  */
 public function addFormPropertyConfig(\Phruts\Config\FormPropertyConfig $config)
 {
     if ($this->configured) {
         throw new \Phruts\Exception\IllegalStateException("Configuration is frozen");
     }
     if (!empty($this->formProperties[$config->getName()])) {
         throw new \Phruts\Exception\IllegalArgumentException("Property " + $config->getName() + " already defined");
     }
     $this->formProperties[$config->getName()] = $config;
 }