Beispiel #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->setDocumentTypeId('undefined');
     $this->assertFalse($this->object->save());
 }
 /**
  * Save tabs
  *
  * @param Zend\InputFilter\InputFilter $tabsSubform  Tabs sub form
  * @param DocumentType\Model           $documentType DocumentType model
  *
  * @return array
  */
 protected function saveTabs($tabsSubform, $documentType)
 {
     $existingTabs = array();
     $idx = 0;
     foreach ($tabsSubform->getValidInput() as $tabId => $tabValues) {
         if (!preg_match('~^tab(\\d+)$~', $tabId, $matches)) {
             continue;
         }
         $tabId = $matches[1];
         $tabModel = Tab\Model::fromId($tabId);
         if (empty($tabModel) or $tabModel->getDocumentTypeId() != $documentType->getId()) {
             $tabModel = new Tab\Model();
         }
         $tabModel->setDescription($tabValues->getValue('description'));
         $tabModel->setName($tabValues->getValue('name'));
         $tabModel->setDocumentTypeId($documentType->getId());
         $tabModel->setSortOrder(++$idx);
         $tabModel->save();
         $existingTabs[$tabId] = $tabModel->getId();
     }
     return $existingTabs;
 }