fromArray() public static method

Initialize document from array
public static fromArray ( array $array ) : Model
$array array Data
return Model
Example #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $serviceManager = Registry::get('Application')->getServiceManager();
     $renderer = $serviceManager->get('Zend\\View\\Renderer\\PhpRenderer');
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', Model::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
     $this->object = new CurrentDocument($serviceManager);
 }
Example #2
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->script = ScriptModel::fromArray(array('name' => 'Script name', 'identifier' => 'script-identifier', 'description' => 'Script description', 'content' => 'script Content'));
     $this->script->save();
     $serviceManager = Registry::get('Application')->getServiceManager();
     $this->object = new Script($serviceManager);
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', DocumentModel::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
 }
Example #3
0
 /**
  * Generate Xml accessor
  *
  * @param Request $request Request
  *
  * @return string
  */
 public function generate(Request $request)
 {
     $collection = new DocumentCollection();
     $documents = array();
     $rows = $collection->getAvailableDocuments();
     foreach ($rows as $row) {
         $documents[] = DocumentModel::fromArray((array) $row);
     }
     return $this->generateXml($documents, $request);
 }
Example #4
0
 public function setUp()
 {
     $this->addthis = Mockery::mock('Social\\Model\\AddThis');
     $this->addthis->shouldReceive('getConfig')->once()->andReturn(array('profile_id' => '', 'username' => '', 'password' => '', 'show_stats' => '1', 'language' => 'fr', 'data_ga_property_id' => 'test', 'data_track_clickback' => '1', 'data_track_addressbar' => '1', 'config_json' => '', 'widgets' => array(array('name' => 'blog', 'identifier' => 'custom_string', 'settings' => 'custom_string', 'custom_string' => '<!-- AddThis Button BEGIN -->' . '<div class="addthis_toolbox addthis_default_style">' . '<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>' . '<a class="addthis_button_tweet"></a>' . '<a class="addthis_button_pinterest_pinit" pi:pinit:layout="horizontal"></a>' . '<a class="addthis_counter addthis_pill_style"></a>' . '</div>', 'chosen_list' => ''), array('name' => 'something', 'identifier' => 'something', 'settings' => 'nothing', 'custom_string' => '', 'chosen_list' => ''), array('name' => 'large_toolbox', 'identifier' => 'large_toolbox', 'settings' => 'large_toolbox', 'custom_string' => '', 'chosen_list' => 'facebook, twitter, pinterest_share, advqr, google_plusone_share, compact, counter'), array('name' => 'fb_tw_p1_sc', 'identifier' => 'fb_tw_p1_sc', 'settings' => 'fb_tw_p1_sc', 'custom_string' => '', 'chosen_list' => 'facebook, twitter, pinterest_share, google_plusone, google_plusone_share, compact, counter'), array('name' => 'large_toolbox_without_chosen_list', 'identifier' => 'large_toolbox_without_chosen_list', 'settings' => 'large_toolbox', 'custom_string' => '', 'chosen_list' => ''), array('name' => 'small_toolbox', 'identifier' => 'small_toolbox', 'settings' => 'small_toolbox', 'custom_string' => '', 'chosen_list' => 'facebook, twitter, pinterest_share, advqr, google_plusone_share, compact, counter')), 'addthis_show_stats' => true, 'addthis_append_data' => true, 'addthis_copytracking1' => false, 'addthis_copytracking2' => false, 'addthis_brand' => '', 'addthis_language' => 'fr', 'custom_size' => '', 'custom_services' => '', 'custom_preferred' => '', 'custom_more' => '', 'custom_string' => '', 'json_config' => '{"language":"fr"}'));
     $this->addthis->shouldReceive('getDefaultStyles')->once()->andReturn(array('large_toolbox' => array('src' => '<div class="addthis_toolbox addthis_default_style addthis_32x32_style" %1$s>' . '<a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a>' . '<a class="addthis_button_email"></a><a class="addthis_button_pinterest_share"></a>' . '<a class="addthis_button_compact"></a><a class="addthis_counter addthis_bubble_style">' . '</a></div>', 'img' => 'toolbox-large.png', 'name' => 'Large Toolbox'), 'small_toolbox' => array('src' => '<div class="addthis_toolbox addthis_default_style addthis_" %1$s>' . '<a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a>' . '<a class="addthis_button_email"></a><a class="addthis_button_pinterest_share"></a>' . '<a class="addthis_button_compact"></a><a class="addthis_counter addthis_bubble_style">' . '</a></div>', 'img' => 'toolbox-small.png', 'name' => 'Small Toolbox'), 'fb_tw_p1_sc' => array('src' => '<div class="addthis_toolbox addthis_default_style" %1$s>' . '<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>' . '<a class="addthis_button_tweet"></a><a class="addthis_button_pinterest_pinit"></a>' . '<a class="addthis_counter addthis_pill_style"></a></div>', 'img' => 'horizontal_share_rect.png', 'name' => 'Like, Tweet, +1, Share'), 'button' => array('src' => '<div><a class="addthis_button" href="//addthis.com/bookmark.php?v=' . Model\AddThis::ADDTHIS_VERSION . '" %1$s><img src="//cache.addthis.com/cachefly/' . 'static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" ' . 'style="border:0"/></a></div>', 'img' => 'horizontal_share.png', 'name' => 'Classic Share Button'), 'custom_string' => array('name' => 'Custom string')));
     $serviceManager = Registry::get('Application')->getServiceManager();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('CurrentDocument', DocumentModel::fromArray(array('id' => 1, 'url_key' => 'test', 'name' => 'Test')));
     $serviceManager->setService('AddThisModel', $this->addthis);
     $serviceManager->setAllowOverride(false);
     $this->object = new AddThisWidget();
 }
Example #5
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $serviceManager = Registry::get('Application')->getServiceManager();
     $this->renderer = new PhpRenderer();
     $renderer = $serviceManager->get('Zend\\View\\Renderer\\PhpRenderer');
     $this->renderer->setHelperPluginManager($renderer->getHelperPluginManager());
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('currentDocument', DocumentModel::fromArray(array('id' => 1)));
     $serviceManager->setAllowOverride(false);
     $this->object = $this->renderer->plugin('modulePlugin');
     $this->module = ModuleModel::fromArray(array('name' => 'Blog'));
     $this->module->save();
 }
Example #6
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 Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->documentType = DocumentTypeModel::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->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::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' => null));
     $this->document->save();
     ModuleModel::install(Registry::get('Application')->getServiceManager()->get('CustomModules'), 'Blog');
 }
Example #7
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::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 = DocumentTypeModel::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->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::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' => null));
     $this->document->save();
     $this->object = new Sitemap();
 }
Example #8
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::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 = DocumentTypeModel::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->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::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->document->save();
     $this->object = new Documents();
     $view = new View();
     $view->resolver()->addPath(__DIR__ . '/_files/views');
     $view->setHelperPluginManager(Registry::get('Application')->getServiceManager()->get('viewhelpermanager'));
     $this->object->setView($view);
 }
Example #9
0
 /**
  * Initialize documents
  *
  * @return \Gc\Document\Collection
  */
 protected function setDocuments()
 {
     $parentId = $this->getParentId();
     $rows = $this->fetchAll($this->select(function (Select $select) use($parentId) {
         if (empty($parentId)) {
             $select->where->isNull('parent_id');
         } else {
             $select->where->equalTo('parent_id', $parentId);
         }
         $select->order('sort_order ASC');
         $select->order('created_at ASC');
     }));
     $documents = array();
     foreach ($rows as $row) {
         $documents[] = Model::fromArray((array) $row);
     }
     $this->setData('documents', $documents);
     return $this;
 }
Example #10
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();
 }
Example #11
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();
 }
Example #12
0
 /**
  * Test
  *
  * @return void
  */
 public function testSaveWithWrongValues()
 {
     $this->setExpectedException('Gc\\Exception');
     $model = $this->object->fromArray(array('name' => 'Document name', 'url_key' => null, 'status' => Model::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => null, 'document_type_id' => null, 'view_id' => null, 'layout_id' => null, 'parent_id' => null));
     $this->assertFalse($model->save());
 }
Example #13
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 #14
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::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 = DocumentTypeModel::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->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::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' => null));
     $this->document->save();
     $this->renderer = new PhpRenderer();
     $renderer = Registry::get('Application')->getServiceManager()->get('Zend\\View\\Renderer\\PhpRenderer');
     $this->renderer->setHelperPluginManager(clone $renderer->getHelperPluginManager());
     $this->renderer->layout()->currentDocument = DocumentModel::fromArray(array('id' => $this->document->getId()));
     $this->module = ModuleModel::fromArray(array('name' => 'Blog'));
     $this->module->save();
     $this->boostrap = new Module();
     $this->boostrap->install();
     $this->object = new CommentList();
     $this->object->plugin('layout')->setController($this->getMockForAbstractClass('\\Zend\\Mvc\\Controller\\AbstractController'));
 }
Example #15
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::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 = DocumentTypeModel::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->datatype = DatatypeModel::fromArray(array('name' => 'jQueryFileUploadTest', 'prevalue_value' => '', 'model' => 'jQueryFileUpload'));
     $this->datatype->save();
     $this->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $this->document = DocumentModel::fromArray(array('name' => 'jQueryFileUploadTest', 'url_key' => '/jqueryfileupload-test', 'status' => DocumentModel::STATUS_ENABLE, 'sort_order' => 1, 'show_in_nav' => false, '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->document->save();
     $datatype = new Datatype();
     $application = Registry::get('Application');
     $datatype->setRequest($application->getServiceManager()->get('Request'));
     $datatype->setRouter($application->getServiceManager()->get('Router'));
     $datatype->setHelperManager($application->getServiceManager()->get('viewhelpermanager'));
     $datatype->load($this->datatype, $this->document->getId());
     $this->object = $datatype->getEditor($this->property);
 }
Example #16
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->user = UserModel::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 = DocumentTypeModel::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->tab = TabModel::fromArray(array('name' => 'TabTest', 'description' => 'TabTest', 'sort_order' => 1, 'document_type_id' => $this->documentType->getId()));
     $this->tab->save();
     $this->datatype = DatatypeModel::fromArray(array('name' => 'BooleanTest', 'prevalue_value' => '', 'model' => 'Boolean'));
     $this->datatype->save();
     $this->property = PropertyModel::fromArray(array('name' => 'DatatypeTest', 'identifier' => 'DatatypeTest', 'description' => 'DatatypeTest', 'required' => false, 'sort_order' => 1, 'tab_id' => $this->tab->getId(), 'datatype_id' => $this->datatype->getId()));
     $this->property->save();
     $this->document = 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));
     $this->document->save();
     $this->object = Model::fromArray(array('document_id' => $this->document->getId(), 'property_id' => $this->property->getId(), 'value' => ''));
     $this->object->save();
 }
Example #17
0
 /**
  * Test
  *
  * @return void
  */
 public function testPasteActionWithCutSession()
 {
     $document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => 'about', '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));
     $document->save();
     $session = new SessionContainer();
     $session->offsetSet('document-cut', $this->document->getId());
     $this->dispatch('/admin/content/document/paste/' . $document->getId());
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcContent');
     $this->assertControllerName('DocumentController');
     $this->assertControllerClass('DocumentController');
     $this->assertMatchedRouteName('content/document/paste');
     $document->delete();
 }
Example #18
0
 /**
  * Test
  *
  * @return void
  */
 public function testIndexActionWithUrlKeyWithPreview()
 {
     $auth = new AuthenticationService(new Storage\Session(UserModel::BACKEND_AUTH_NAMESPACE));
     $auth->clearIdentity();
     $document = DocumentModel::fromArray(array('name' => 'test', 'url_key' => 'test', '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));
     $document->save();
     $this->dispatch($document->getUrl() . '?preview');
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcFrontend');
     $this->assertControllerName('IndexController');
     $this->assertControllerClass('IndexController');
     $this->assertMatchedRouteName('cms');
     $document->delete();
     $enableCache = $this->config->setValue('cache_is_active', 0);
 }
Example #19
0
 /**
  * Load Document data
  *
  * @return string
  */
 public function createDocument()
 {
     $documents = new Document\Collection();
     $rows = $documents->fetchAll($documents->select(function ($select) {
         $select->order('sort_order ASC');
         $select->order('created_at ASC');
     }));
     if (empty($rows)) {
         return '';
     }
     $documentArray = array();
     foreach ($rows as $row) {
         $documentArray[] = Document\Model::fromArray((array) $row);
     }
     $propertiyCollection = new Property\Collection();
     foreach ($documentArray as $document) {
         $array = array();
         $properties = $propertiyCollection->load(null, null, $document->getId())->getProperties();
         foreach ($properties as $property) {
             $value = $property->getValueModel()->getValue();
             $property->getValueModel()->setValue(base64_encode($value));
             $array[] = $property->getValueModel();
         }
         $document->setProperties($array);
     }
     return $documents->toXml($documentArray, 'documents');
 }
Example #20
0
 /**
  * Initiliaze files
  *
  * @return void
  */
 protected function initializeFiles()
 {
     $_FILES = array('test' => array('name' => __DIR__ . '/_files/test.jpg', 'type' => 'plain/text', 'size' => 8, 'tmp_name' => __DIR__ . '/_files/test.jpg', 'error' => 0));
     $property = PropertyModel::fromArray(array('id' => 'test-upload'));
     $document = DocumentModel::fromArray(array('id' => 'test-upload'));
     $this->object->load($property, $document, 'test');
 }
Example #21
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);
 }
Example #22
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()));
 }
Example #23
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));
 }