Example #1
0
 /**
  * @see Form::createElements()
  */
 public function createElements(array $formData)
 {
     $this->addElement('hidden', 'type', array('required' => true, 'value' => 'db'));
     if (isset($formData['skip_validation']) && $formData['skip_validation']) {
         $this->addSkipValidationCheckbox();
     } else {
         $this->addElement('hidden', 'skip_validation', array('required' => true, 'value' => 0));
     }
     $resourceForm = new DbResourceForm();
     $this->addElements($resourceForm->createElements($formData)->getElements());
     $this->getElement('name')->setValue('icingaweb_db');
 }
Example #2
0
 /**
  * Create and add elements to this form
  *
  * @param   array   $formData
  */
 public function createElements(array $formData)
 {
     $this->addElement('hidden', 'type', array('required' => true, 'value' => 'db'));
     if (isset($formData['skip_validation']) && $formData['skip_validation']) {
         // In case another error occured and the checkbox was displayed before
         $this->addSkipValidationCheckbox();
     } else {
         $this->addElement('hidden', 'skip_validation', array('required' => true, 'value' => 0));
     }
     $dbResourceForm = new DbResourceForm();
     $this->addElements($dbResourceForm->createElements($formData)->getElements());
     $this->getElement('name')->setValue('icinga_ido');
 }
Example #3
0
 /**
  * Return whether the given values are valid
  *
  * @param   array   $formData   The data to validate
  *
  * @return  bool
  */
 public function isValid($formData)
 {
     if (!parent::isValid($formData)) {
         return false;
     }
     if (!isset($formData['skip_validation']) || !$formData['skip_validation']) {
         $configObject = new ConfigObject($this->getValues());
         if (!DbResourceForm::isValidResource($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate connectivity with the given database server.'));
             return false;
         } elseif (!BackendConfigForm::isValidIdoSchema($this, $configObject) || !BackendConfigForm::isValidIdoInstance($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate the IDO schema in the given database.'));
             return false;
         }
     }
     return true;
 }
Example #4
0
 public function isValid($data)
 {
     if (false === parent::isValid($data)) {
         return false;
     }
     if (false === isset($data['skip_validation']) || $data['skip_validation'] == 0) {
         $configObject = new ConfigObject($this->getValues());
         if (false === DbResourceForm::isValidResource($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate connectivity with the given database server'));
             return false;
         } elseif (false === BackendConfigForm::isValidIdoSchema($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate the ido schema'));
             return false;
         } elseif (false === BackendConfigForm::isValidIdoInstance($this, $configObject)) {
             $this->addSkipValidationCheckbox($this->translate('Check this to not to validate the ido instance'));
             return false;
         }
     }
     return true;
 }
 /**
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testInvalidDbResourceIsNotValid()
 {
     $this->setUpResourceFactoryMock(Mockery::mock()->shouldReceive('getConnection')->once()->andThrow('\\Exception')->getMock());
     $this->assertFalse(DbResourceForm::isValidResource(new DbResourceForm()), 'ResourceForm claims that an invalid db resource is valid');
 }
 /**
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testInvalidDbResourceIsNotValid()
 {
     $this->setUpResourceFactoryMock(Mockery::mock()->shouldReceive('inspect')->andReturn(self::createInspector(true))->getMock());
     $this->assertFalse(DbResourceForm::isValidResource(new DbResourceForm()), 'ResourceForm claims that an invalid db resource is valid');
 }