Inheritance: extends Gc\Db\AbstractTable
Esempio n. 1
0
 /**
  * get View Model
  *
  * @return \Gc\View\Model
  */
 public function getLayout()
 {
     if ($this->getData('layout') == null) {
         $view = Layout\Model::fromId($this->getLayoutId());
         if ($view !== null) {
             $this->setData('layout', $view);
         }
     }
     return $this->getData('layout');
 }
Esempio n. 2
0
 /**
  * Test
  *
  * @return void
  */
 public function testGetProperties()
 {
     $documentModel = DocumentModel::fromArray(array('name' => 'DocumentTest', 'url_key' => 'document-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => 0));
     $documentModel->save();
     $this->object->setDocumentId($documentModel->getId());
     $this->object->save();
     $this->object->load($this->documentType->getId(), $this->tab->getId(), 1);
     $this->assertInternalType('array', $this->object->getProperties(true));
     $this->object->load();
     $this->assertInternalType('array', $this->object->getProperties(true));
 }
Esempio n. 3
0
 /**
  * Initialize Render error event
  *
  * @param Event $event Event
  *
  * @return void
  */
 public function prepare($event)
 {
     if ($event->getApplication()->getMvcEvent()->getRouteMatch()->getMatchedRouteName() === 'cms') {
         $coreConfig = $event->getApplication()->getServiceManager()->get('CoreConfig');
         $layout = Layout\Model::fromId($coreConfig->getValue('site_exception_layout'));
         if (!empty($layout)) {
             $templatePathStack = $event->getApplication()->getServiceManager()->get('Zend\\View\\Resolver\\TemplatePathStack');
             $event->getViewModel()->setTemplate('layout/' . $layout->getIdentifier());
         }
     }
 }
Esempio n. 4
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     unset($this->object);
     $this->documentType->delete();
     unset($this->documentType);
     $this->view->delete();
     unset($this->view);
     $this->layout->delete();
     unset($this->layout);
     $this->user->delete();
     unset($this->user);
 }
Esempio n. 5
0
 /**
  * Set layout collection
  *
  * @param boolean $forceReload Force reload
  *
  * @return array
  */
 public function getLayouts($forceReload = false)
 {
     if ($forceReload or $this->getData('layouts') === null) {
         $rows = $this->fetchAll($this->select(function (Select $select) {
             $select->order('name ASC');
         }));
         $layouts = array();
         foreach ($rows as $row) {
             $layouts[] = Model::fromArray((array) $row);
         }
         $this->setData('layouts', $layouts);
     }
     return $this->getData('layouts');
 }
Esempio n. 6
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->boostrap->uninstall();
     $this->document->delete();
     $this->view->delete();
     $this->layout->delete();
     $this->documentType->delete();
     $this->user->delete();
     unset($this->document);
     unset($this->object);
     unset($this->view);
     unset($this->layout);
     unset($this->documentType);
     unset($this->user);
 }
Esempio n. 7
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 public function tearDown()
 {
     StaticEventManager::resetInstance();
     ModuleModel::uninstall(Registry::get('Application')->getServiceManager()->get('CustomModules')->getModule('Blog'), ModuleModel::fromName('Blog'));
     $this->document->delete();
     $this->view->delete();
     $this->layout->delete();
     $this->documentType->delete();
     unset($this->document);
     unset($this->object);
     unset($this->view);
     unset($this->layout);
     unset($this->documentType);
     parent::tearDown();
 }
Esempio n. 8
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->document->delete();
     $this->documentType->delete();
     $this->user->delete();
     $this->layout->delete();
     $this->view->delete();
     unset($this->document);
     unset($this->documentType);
     unset($this->user);
     unset($this->layout);
     unset($this->view);
     unset($this->object);
     StaticEventManager::resetInstance();
     if (file_exists($this->filePath)) {
         unlink($this->filePath);
     }
 }
Esempio n. 9
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->datatype->delete();
     $this->documentType->delete();
     $this->layout->delete();
     $this->property->delete();
     $this->tab->delete();
     $this->user->delete();
     $this->view->delete();
     unset($this->datatype);
     unset($this->documentType);
     unset($this->layout);
     unset($this->property);
     unset($this->tab);
     unset($this->user);
     unset($this->view);
     unset($this->object);
 }
Esempio n. 10
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();
 }
Esempio n. 11
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();
 }
Esempio n. 12
0
 /**
  * Test
  *
  * @return void
  */
 public function testRenderWithIterableInterface()
 {
     $view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $view->save();
     $layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $layout->save();
     $user = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => '*****@*****.**', 'login' => 'test', 'user_acl_role_id' => 1));
     $user->setPassword('test');
     $user->save();
     $documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $view->getId(), 'user_id' => $user->getId()));
     $documentType->save();
     $document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $user->getId(), 'document_type_id' => $documentType->getId(), 'view_id' => $view->getId(), 'layout_id' => $layout->getId(), 'parent_id' => 0));
     $document->save();
     $collection = new DocumentCollection();
     $collection->load(0);
     $this->assertEquals(sprintf('<ul><li><a href="#tabs-%d">Document name</a></li></ul>', $document->getId()), $this->object->render($collection->getChildren()));
     $document->delete();
     $documentType->delete();
     $layout->delete();
     $view->delete();
     $user->delete();
 }
Esempio n. 13
0
 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  *
  * @return void
  */
 protected function tearDown()
 {
     $this->document->delete();
     unset($this->document);
     $this->documentTwo->delete();
     unset($this->documentTwo);
     $this->documentChildren->delete();
     unset($this->documentChildren);
     $this->documentSecondChildren->delete();
     unset($this->documentSecondChildren);
     $this->documentThirdChildren->delete();
     unset($this->documentThirdChildren);
     $this->documentForthChildren->delete();
     unset($this->documentForthChildren);
     $this->view->delete();
     unset($this->view);
     $this->user->delete();
     unset($this->user);
     $this->layout->delete();
     unset($this->layout);
     $this->documentType->delete();
     unset($this->documentType);
     unset($this->object);
 }
Esempio n. 14
0
 /**
  * Test
  *
  * @return void
  */
 public function testFromIdentifier()
 {
     $documentModel = DocumentModel::fromArray(array('name' => 'DocumentTest', 'url_key' => 'document-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => 0));
     $documentModel->save();
     $this->assertInstanceOf('Gc\\Property\\Model', Model::fromIdentifier($this->object->getIdentifier(), $documentModel->getId()));
 }
Esempio n. 15
0
 /**
  * Test
  *
  * @return void
  */
 public function testDeleteWithWrongId()
 {
     $configuration = Registry::get('Application')->getConfig();
     if ($configuration['db']['driver'] == 'pdo_mysql') {
         $this->markTestSkipped('Mysql does not thrown exception.');
     }
     $this->setExpectedException('Gc\\Exception');
     $model = new Model();
     $model->setId('undefined');
     $this->assertFalse($model->delete());
 }
Esempio n. 16
0
 /**
  * Test
  *
  * @return void
  */
 public function testLoad()
 {
     $user = UserModel::fromArray(array('lastname' => 'Test', 'firstname' => 'Test', 'email' => '*****@*****.**', 'login' => 'test-user-model', 'user_acl_role_id' => 1));
     $user->setPassword('test-user-model-password');
     $user->save();
     $view = ViewModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $view->save();
     $layout = LayoutModel::fromArray(array('name' => 'View', 'identifier' => 'ViewIdentifier', 'description' => 'Description', 'content' => ''));
     $layout->save();
     $documenttype = DocumentTypeModel::fromArray(array('name' => 'DocumentType', 'description' => 'description', 'icon_id' => 1, 'default_view_id' => $view->getId(), 'user_id' => $user->getId()));
     $documenttype->save();
     $documenttype->setDependencies(array($documenttype->getId()));
     $documenttype->save();
     $datatype = DatatypeModel::fromArray(array('name' => 'DatatypeTest', 'model' => 'Textstring'));
     $datatype->save();
     $tab = TabModel::fromArray(array('name' => 'test', 'description' => 'test', 'document_type_id' => $documenttype->getId()));
     $tab->save();
     $property = PropertyModel::fromArray(array('name' => 'test', 'identifier' => 'test', 'description' => 'test', 'tab_id' => $tab->getId(), 'datatype_id' => $datatype->getId(), 'is_required' => true));
     $property->save();
     $document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => '', 'status' => DocumentModel::STATUS_ENABLE, 'user_id' => $user->getId(), 'document_type_id' => $documenttype->getId(), 'view_id' => $view->getId(), 'layout_id' => $layout->getId(), 'parent_id' => null));
     $document->save();
     $this->assertNull($this->object->load($document, array('locales' => array('en_GB' => 'English'))));
     $this->object->setData(array());
     $this->assertFalse($this->object->isValid());
     $document->delete();
     $documenttype->delete();
     $property->delete();
     $tab->delete();
     $view->delete();
     $layout->delete();
     $user->delete();
     $datatype->delete();
     unset($documenttype);
     unset($document);
     unset($property);
     unset($tab);
     unset($view);
     unset($layout);
     unset($user);
     unset($datatype);
 }
Esempio n. 17
0
 /**
  * Initiliaze from identifier
  *
  * @param string $identifier Identifier
  *
  * @return \Gc\Layout\Model
  */
 public static function fromIdentifier($identifier)
 {
     $layoutTable = new Model();
     $row = $layoutTable->fetchRow($layoutTable->select(array('identifier' => $identifier)));
     $layoutTable->events()->trigger(__CLASS__, 'before.load', $layoutTable);
     if (!empty($row)) {
         $layoutTable = self::fromArray((array) $row);
         $layoutTable->events()->trigger(__CLASS__, 'after.load', $layoutTable);
         return $layoutTable;
     } else {
         $layoutTable->events()->trigger(__CLASS__, 'after.load.failed', $layoutTable);
         return false;
     }
 }
Esempio n. 18
0
 /**
  * test
  *
  * @return void
  */
 protected function createDocuments()
 {
     $this->view = View\Model::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = Layout\Model::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = User\Model::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => '*****@*****.**', 'login' => 'test', 'user_acl_role_id' => 1));
     $this->user->setPassword('test');
     $this->user->save();
     $this->documentType = DocumentType\Model::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->homeDocument = Document\Model::fromArray(array('name' => 'Document name', 'url_key' => '', 'status' => Document\Model::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => 0));
     $this->homeDocument->save();
     $this->parentDocument = Document\Model::fromArray(array('name' => 'Document name', 'url_key' => 'parent', 'status' => Document\Model::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => 0));
     $this->parentDocument->save();
     $this->document = Document\Model::fromArray(array('name' => 'Document name', 'url_key' => 'children', 'status' => Document\Model::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => $this->parentDocument->getId()));
     $this->document->save();
 }
Esempio n. 19
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();
 }
Esempio n. 20
0
 /**
  * Send a file to the browser
  *
  * @return \Zend\Stdlib\ResponseInterface
  */
 public function downloadAction()
 {
     $layoutId = $this->getRouteMatch()->getParam('id', null);
     if (!empty($layoutId)) {
         $layout = Layout\Model::fromId($layoutId);
         if (empty($layout)) {
             $this->flashMessenger()->addErrorMessage('This layout can not be download');
             return $this->redirect()->toRoute('development/layout/edit', array('id' => $layoutId));
         }
         $content = $layout->getContent();
         $filename = $layout->getIdentifier() . '.phtml';
     } else {
         $layouts = new Layout\Collection();
         $children = $layouts->getLayouts();
         $zip = new ZipArchive();
         $tmpFilename = tempnam(sys_get_temp_dir(), 'zip');
         $res = $zip->open($tmpFilename, ZipArchive::CREATE);
         if ($res === true) {
             foreach ($children as $child) {
                 $zip->addFromString($child->getIdentifier() . '.phtml', $child->getContent());
             }
             $zip->close();
             $content = file_get_contents($tmpFilename);
             $filename = 'layout.zip';
             unlink($tmpFilename);
         }
     }
     if (empty($content) or empty($filename)) {
         $this->flashMessenger()->addErrorMessage('Can not save layouts');
         return $this->redirect()->toRoute('development/layout');
     }
     $headers = new Headers();
     $headers->addHeaderLine('Pragma', 'public')->addHeaderLine('Cache-control', 'must-revalidate, post-check=0, pre-check=0')->addHeaderLine('Cache-control', 'private')->addHeaderLine('Expires', -1)->addHeaderLine('Content-Type', 'application/octet-stream')->addHeaderLine('Content-Transfer-Encoding', 'binary')->addHeaderLine('Content-Length', strlen($content))->addHeaderLine('Content-Disposition', 'attachment; filename=' . $filename);
     $response = $this->getResponse();
     $response->setHeaders($headers);
     $response->setContent($content);
     return $response;
 }
Esempio n. 21
0
 /**
  * Test
  *
  * @return void
  */
 public function testDownloadActionWithoutId()
 {
     $layoutModel = LayoutModel::fromArray(array('name' => 'LayoutName', 'identifier' => 'LayoutIdentifier', 'content' => 'Content'));
     $layoutModel->save();
     $this->dispatch('/admin/development/layout/download');
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcDevelopment');
     $this->assertControllerName('LayoutController');
     $this->assertControllerClass('LayoutController');
     $this->assertMatchedRouteName('development/layout/download');
     $layoutModel->delete();
 }
Esempio n. 22
0
 /**
  * Generate frontend from url key
  *
  * @return ViewModel
  */
 public function indexAction()
 {
     $coreConfig = $this->getServiceLocator()->get('CoreConfig');
     $viewModel = new ViewModel();
     $this->events()->trigger('Front', 'preDispatch', $this, array('viewModel' => $viewModel));
     if ($coreConfig->getValue('site_is_offline') == 1) {
         $isAdmin = $this->getServiceLocator()->get('Auth')->hasIdentity();
         if (!$isAdmin) {
             $document = Document\Model::fromId($coreConfig->getValue('site_offline_document'));
             if (empty($document)) {
                 $viewModel->setTemplate('gc-frontend/site-is-offline');
                 $viewModel->setTerminal(true);
                 return $viewModel;
             }
         }
     }
     try {
         $document = $this->getServiceLocator()->get('CurrentDocument');
     } catch (Exception $e) {
         //Don't care, page is just not found
     }
     $variables = array();
     if (empty($document)) {
         // 404
         $this->getResponse()->setStatusCode(404);
         $layout = Layout\Model::fromId($coreConfig->getValue('site_404_layout'));
         if (empty($layout)) {
             $viewModel->setTerminal(true);
         }
     } else {
         //Load properties from document id
         $properties = new Property\Collection();
         $properties->load(null, null, $document->getId());
         foreach ($properties->getProperties() as $property) {
             $value = $property->getValue();
             if ($this->isSerialized($value)) {
                 $value = unserialize($value);
             }
             $viewModel->setVariable($property->getIdentifier(), $value);
             $this->layout()->setVariable($property->getIdentifier(), $value);
             $variables[$property->getIdentifier()] = $value;
         }
         //Set view from database
         $view = $document->getView();
         $layout = $document->getLayout();
     }
     if (!empty($layout)) {
         $this->layout()->setTemplate('layout/' . $layout->getIdentifier());
     }
     if (!empty($view)) {
         $viewModel->setTemplate('view/' . $view->getIdentifier());
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         if ($this->params()->fromQuery('terminate_layout') or $this->params()->fromPost('terminate_layout')) {
             $viewModel->setTerminal(true);
         }
     }
     $this->events()->trigger('Front', 'postDispatch', $this, array('viewModel' => $viewModel));
     return $viewModel;
 }
Esempio n. 23
0
 /**
  * Test
  *
  * @return void
  */
 public function testSaveEditor()
 {
     $viewModel = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $viewModel->save();
     $layoutModel = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $layoutModel->save();
     $userModel = UserModel::fromArray(array('lastname' => 'User test', 'firstname' => 'User test', 'email' => '*****@*****.**', 'login' => 'test', 'user_acl_role_id' => 1));
     $userModel->setPassword('test');
     $userModel->save();
     $documentTypeModel = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $viewModel->getId(), 'user_id' => $userModel->getId()));
     $documentTypeModel->save();
     $tabModel = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $documentTypeModel->getId()));
     $tabModel->save();
     $documentModel = DocumentModel::fromArray(array('name' => 'DocumentTest', 'url_key' => 'document-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => true, 'user_id' => $userModel->getId(), 'document_type_id' => $documentTypeModel->getId(), 'view_id' => $viewModel->getId(), 'layout_id' => $layoutModel->getId(), 'parent_id' => 0));
     $documentModel->save();
     $propertyModel = PropertyModel::fromArray(array('datatype_id' => $this->object->getId(), 'document_id' => $documentModel->getId(), 'tab_id' => $tabModel->getId(), 'name' => 'PropertyTest', 'identifier' => 'PropertyTest', 'description' => 'PropertyTest', 'required' => true, 'sort_order' => 1));
     $propertyModel->save();
     $this->assertFalse(Model::saveEditor(Registry::get('Application')->getServiceManager(), $propertyModel));
     $propertyModel->isRequired(false);
     $this->assertTrue(Model::saveEditor(Registry::get('Application')->getServiceManager(), $propertyModel));
     $propertyModel->delete();
     $documentModel->delete();
     $tabModel->delete();
     $documentTypeModel->delete();
     $viewModel->delete();
     $layoutModel->delete();
 }