示例#1
0
 /**
  * Test
  *
  * @return void
  */
 public function testSaveWithWrongValues()
 {
     $configuration = Registry::get('Application')->getConfig();
     if ($configuration['db']['driver'] == 'pdo_mysql') {
         $this->markTestSkipped('Mysql does not thrown exception.');
     }
     $this->setExpectedException('Gc\\Exception');
     $this->object->setIdentifier(null);
     $this->assertFalse($this->object->save());
 }
示例#2
0
 /**
  * Save properties
  *
  * @param Zend\InputFilter\InputFilter $propertiesSubform Properties sub form
  * @param array                        $existingTabs      Array of tabs
  *
  * @return array
  */
 protected function saveProperties($propertiesSubform, $existingTabs)
 {
     $existingProperties = array();
     $idx = 0;
     foreach ($propertiesSubform->getValidInput() as $propertyId => $propertyValues) {
         if (!preg_match('~^property(\\d+)$~', $propertyId, $matches)) {
             continue;
         }
         $propertyId = $matches[1];
         $propertyModel = Property\Model::fromId($propertyId);
         if (empty($propertyModel) or !in_array($propertyModel->getTabId(), $existingTabs)) {
             $propertyModel = new Property\Model();
         }
         $propertyModel->setDescription($propertyValues->getValue('description'));
         $propertyModel->setName($propertyValues->getValue('name'));
         $propertyModel->setIdentifier($propertyValues->getValue('identifier'));
         $propertyModel->setTabId($existingTabs[$propertyValues->getValue('tab')]);
         $propertyModel->setDatatypeId($propertyValues->getValue('datatype'));
         $required = $propertyValues->getValue('required');
         $propertyModel->isRequired(!empty($required) ? true : false);
         $propertyModel->setSortOrder(++$idx);
         $propertyModel->save();
         $existingProperties[] = $propertyModel->getId();
     }
     return $existingProperties;
 }