Example #1
0
 protected function createContent()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewContentIdentifier', 'description' => 'Description', 'content' => 'Content of the webpage <br/>This is my view'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout', 'identifier' => 'LayoutContentIdentifier', 'description' => 'Description', 'content' => '<?php echo $this->content; '));
     $this->layout->save();
     $this->script = ScriptModel::fromArray(array('name' => 'Script', 'identifier' => 'ScriptContentIdentifier', 'description' => 'Description', 'content' => ''));
     $this->script->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->documentType->setDependencies(array($this->documentType->getId()));
     $this->documentType->addView($this->view->getId());
     $this->documentType->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $this->datatype->save();
     $this->tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $this->documentType->getId()));
     $this->tabModel->save();
     $this->property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'azd', 'description' => 'test', 'tab_id' => $this->tabModel->getId(), 'datatype_id' => $this->datatype->getId(), 'is_required' => true));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => '', 'status' => DocumentModel::STATUS_ENABLE, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $this->document->save();
     $this->property->setDocumentId($this->document->getId());
     $this->property->setValue('string');
     $this->property->saveValue();
 }
Example #2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->init();
     $this->view = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $this->layout->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->documentType->setDependencies(array($this->documentType->getId()));
     $this->documentType->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $this->datatype->save();
     $this->tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $this->documentType->getId()));
     $this->tabModel->save();
     $this->property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'test', 'description' => 'test', 'tab_id' => $this->tabModel->getId(), 'datatype_id' => $this->datatype->getId(), 'is_required' => true));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => '', 'status' => DocumentModel::STATUS_ENABLE, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $this->document->save();
 }
Example #3
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->init();
     $this->view = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'View', 'identifier' => 'LayoutIdentifier', 'description' => 'Description', 'content' => ''));
     $this->layout->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->documentType->setDependencies(array($this->documentType->getId()));
     $this->documentType->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $this->datatype->save();
     $this->tabModel = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $this->documentType->getId()));
     $this->tabModel->save();
     $this->property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'test', 'description' => 'test', 'tab_id' => $this->tabModel->getId(), 'datatype_id' => $this->datatype->getId(), 'is_required' => true));
     $this->property->save();
     $this->config = Registry::get('Application')->getServiceManager()->get('CoreConfig');
     $this->getApplicationServiceLocator()->get('ViewTemplatePathStack')->addPath(GC_TEMPLATE_PATH);
     $this->getApplicationServiceLocator()->get('Auth')->clearIdentity();
 }
Example #4
0
 /**
  * Test
  *
  * @return void
  */
 public function testSave()
 {
     $this->object->addViews(array($this->view->getId(), 0));
     $this->object->setDependencies(array($this->object->getId()));
     $this->assertInternalType('integer', (int) $this->object->save());
 }
Example #5
0
 /**
  * Create document type
  *
  * @return \Zend\View\Model\ViewModel|array
  */
 public function createAction()
 {
     $form = new DocumentTypeForm();
     $form->setAttribute('action', $this->url()->fromRoute('development/document-type/create', array()));
     $request = $this->getRequest();
     $session = $this->getSession();
     if (!$request->isPost()) {
         $session['document-type'] = array('tabs' => array());
     } else {
         $postData = $this->getRequest()->getPost()->toArray();
         $form->setData($postData);
         $form->setValues($postData);
         if (!$form->isValid()) {
             $this->flashMessenger()->addErrorMessage('Can not save document type');
             $this->useFlashMessenger();
         } else {
             $input = $form->getInputFilter();
             $infosSubform = $input->get('infos');
             $viewsSubform = $input->get('views');
             $documentType = new DocumentType\Model();
             $documentType->addData(array('name' => $infosSubform->getValue('name'), 'icon_id' => $infosSubform->getValue('icon_id'), 'description' => $infosSubform->getValue('description'), 'default_view_id' => $viewsSubform->getValue('default_view'), 'user_id' => $this->getServiceLocator()->get('Auth')->getIdentity()->getId()));
             $documentType->getAdapter()->getDriver()->getConnection()->beginTransaction();
             try {
                 $availableViews = $viewsSubform->getValue('available_views');
                 if (empty($availableViews)) {
                     $availableViews = array();
                 }
                 $documentType->addViews($availableViews);
                 $documentType->setDependencies($infosSubform->getValue('dependency'));
                 $documentType->save();
                 $existingTabs = $this->saveTabs($input->get('tabs'), $documentType);
                 $this->saveProperties($input->get('properties'), $existingTabs);
                 $documentType->getAdapter()->getDriver()->getConnection()->commit();
                 $this->flashMessenger()->addSuccessMessage('This document type has been saved');
                 return $this->redirect()->toRoute('development/document-type/edit', array('id' => $documentType->getId()));
             } catch (Exception $e) {
                 $documentType->getAdapter()->getDriver()->getConnection()->rollBack();
                 throw new \Gc\Exception('Error Processing Request ' . print_r($e, true), 1);
             }
         }
     }
     return array('form' => $form);
 }