fromArray() public static method

Initialize module from array
public static fromArray ( array $array ) : Model
$array array Data
return Model
Beispiel #1
0
 /**
  * Test
  *
  * @return void
  */
 public function testInit()
 {
     $moduleModel = ModuleModel::fromArray(array('name' => 'Sitemap'));
     $moduleModel->save();
     $this->assertNull($this->object->init());
     $moduleModel->delete();
 }
Beispiel #2
0
 /**
  * Initialize modules
  *
  * @return \Gc\Module\Collection
  */
 protected function setModules()
 {
     $rows = $this->fetchAll($this->select(function (Select $select) {
         $select->order('name ASC');
     }));
     $modules = array();
     foreach ($rows as $row) {
         $modules[] = Model::fromArray((array) $row);
     }
     $this->setData('modules', $modules);
     return $this;
 }
Beispiel #3
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();
 }
Beispiel #4
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'));
 }
Beispiel #5
0
 /**
  * Test
  *
  * @return void
  */
 public function testUninstallAction()
 {
     $moduleModel = ModuleModel::fromArray(array('name' => 'Sitemap'));
     $moduleModel->save();
     $this->dispatch('/admin/module/uninstall/' . $moduleModel->getId());
     $this->assertResponseStatusCode(200);
     $this->assertModuleName('GcModule');
     $this->assertControllerName('ModuleController');
     $this->assertControllerClass('IndexController');
     $this->assertMatchedRouteName('module/uninstall');
     $moduleModel->delete();
 }
Beispiel #6
0
 /**
  * Test
  *
  * @return void
  */
 public function testFromArray()
 {
     $this->assertInstanceOf('Gc\\Module\\Model', Model::fromArray($this->object->getData()));
 }