Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated Template Editor

  • Loading branch information...
commit 07525e16b1fa1194b31e9eb75a8e4101aec9e069 1 parent 46f8114
@ArchiCroc authored
Showing with 358 additions and 131 deletions.
  1. +1 −1  application/modules/Content/controllers/CategorySetController.php
  2. +5 −0 application/modules/Content/controllers/TemplateController.php
  3. +3 −0  application/modules/Content/forms/Field.php
  4. +18 −8 application/modules/Content/models/Content/MapperDbTable.php
  5. +2 −3 application/modules/Content/models/Field/Service.php
  6. +5 −4 application/modules/Content/models/Plugin/Template.php
  7. +10 −0 application/modules/Content/plugins/Element/DateTime/Element.php
  8. +2 −2 application/modules/Content/plugins/Template/Base/Installer.php
  9. +92 −0 application/modules/Content/plugins/Template/Blog/Installer.php
  10. +7 −0 application/modules/Content/plugins/Template/Blog/category.phtml
  11. +7 −0 application/modules/Content/plugins/Template/Blog/index.phtml
  12. +7 −0 application/modules/Content/plugins/Template/Blog/tag.phtml
  13. +7 −0 application/modules/Content/plugins/Template/Blog/view.phtml
  14. +10 −4 application/modules/Content/plugins/Template/Pages/Installer.php
  15. +13 −24 application/modules/Content/plugins/Template/Projects/Installer.php
  16. +35 −0 application/modules/Content/plugins/Template/Projects/category.phtml
  17. +7 −0 application/modules/Content/plugins/Template/Projects/index.phtml
  18. +13 −0 application/modules/Content/plugins/Template/Projects/view.phtml
  19. +2 −2 application/modules/Core/forms/Confirm.php
  20. +4 −4 application/modules/Core/models/Reflection/Service.php
  21. +8 −0 library/CMS/Form/Element/JsCodeEditor.php
  22. +65 −52 library/CMS/Test/PHPUnit/ControllerTestCase.php
  23. +11 −2 library/CMS/View/Helper/FormJsCodeEditor.php
  24. +2 −2 tests/application/modules/Content/controllers/Content_CategoryControllerTest.php
  25. +5 −2 tests/application/modules/Content/controllers/Content_CategorySetControllerTest.php
  26. +2 −2 tests/application/modules/Content/controllers/Content_ContentControllerTest.php
  27. +2 −2 tests/application/modules/Content/controllers/Content_FieldControllerTest.php
  28. +2 −2 tests/application/modules/Content/controllers/Content_FieldSetControllerTest.php
  29. +1 −1  tests/application/modules/Content/controllers/Content_IndexControllerTest.php
  30. +2 −2 tests/application/modules/Content/controllers/Content_SectionControllerTest.php
  31. +2 −2 tests/application/modules/Content/controllers/Content_TemplateControllerTest.php
  32. +1 −1  tests/application/modules/Content/models/Field/Content_Model_Field_ServiceTest.php
  33. +1 −1  tests/application/modules/Content/models/Section/Content_Model_Section_ManagerTest.php
  34. +1 −1  tests/application/modules/Core/models/Acl/Core_Model_Acl_ManagerTest.php
  35. +3 −7 tests/application/modules/Core/models/Reflection/Core_Model_Reflection_ServiceTest.php
View
2  application/modules/Content/controllers/CategorySetController.php
@@ -159,6 +159,6 @@ public function deleteAction()
$csService->delete($object);
$this->view->messages()->add('Successfully Deleted Category Set "'.$title.'"');
}
- return $this->_redirect($this->view->url(array('controller'=>'category-set'),'content-admin'));
+ return $this->_redirect($this->view->url(array('controller'=>'category-set'),'content-admin'));
}
}
View
5 application/modules/Content/controllers/TemplateController.php
@@ -97,6 +97,7 @@ public function newAction() {
//save
$values = $form->getValues();
+ $values['content'] = base64_decode($values['content']);
$values['owner'] = Core_Model_User_Manager::getUser()->id;
$values['section'] = $this->view->id;
$values['type'] = Content_Model_Template::USER;
@@ -136,6 +137,10 @@ public function editAction() {
//save
$values = $form->getValues();
+
+
+ $values['content'] = base64_decode($values['content']);
+
$values['owner'] = Core_Model_User_Manager::getUser()->id;
$object->fromArray($values);
$service->update($object);
View
3  application/modules/Content/forms/Field.php
@@ -42,6 +42,9 @@ public function init()
$service = new Core_Model_Reflection_Service();
$configs = $service->getPluginConfigsByModuleType('Content','Element');
+ //var_dump($configs);
+ //exit;
+
$options = array('' => 'Select One');
foreach($configs as $key => $value){
View
26 application/modules/Content/models/Content/MapperDbTable.php
@@ -43,8 +43,9 @@ public function getTable() {
}
public function getCustomTable($section) {
+
if (!array_key_exists($section, $this->_customTables)) {
- $customTable = new Zend_Db_Table('content_custom_' . $section);
+ $customTable = new Zend_Db_Table('content_custom_' . $this->escapeInt($section));
// die(debugArray($customTable->info(Zend_Db_Table::METADATA)));
$this->_customTables[$section] = $customTable;
}
@@ -110,7 +111,7 @@ public function fetchObjectsBySection($section, $query = array(), $itemsPerPage
$select = $this->getTable()->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
$select->setIntegrityCheck(false)
->where('section = ?', $section)
- ->join(array('c' => 'content_custom_' . $section), 'content_content.id = c.id AND
+ ->join(array('c' => 'content_custom_' . $this->escapeInt($section)), 'content_content.id = c.id AND
content_content.active_revision = c.revision'
); //,'homenet_node_models.id = homenet_nodes.model', array('driver', 'name AS modelName', 'type', 'settings')
@@ -327,7 +328,7 @@ public function fetchObjectById($id) {
public function addCustomTable($section) {
- $table = 'content_custom_' . mysql_real_escape_string($section);
+ $table = 'content_custom_' . $this->escapeInt($section);
//@todo security issue validate $section
// return $this->getMapper()->prepareTable($section, $fields);
@@ -366,7 +367,7 @@ public function addCustomField(Content_Model_Field_Interface $field) {
}
$element = new $class();
- $result = $this->getTable()->getAdapter()->query('ALTER TABLE `content_custom_' . mysql_real_escape_string($field->section) . '` ADD `' . mysql_real_escape_string($field->name) . '` ' . $element->getMysqlColumn() . ' ');;
+ $result = $this->getTable()->getAdapter()->query('ALTER TABLE `content_custom_' . $this->escapeInt($field->section) . '` ADD `' . $this->escapeString($field->name) . '` ' . $element->getMysqlColumn() . ' ');;
$this->cleanCache(); //reset metadata cache
return $result;
}
@@ -380,6 +381,13 @@ public function cleanCache(){
}
}
+ public function escapeString($string){
+ return $this->getTable()->getAdapter()->quote($string);
+ }
+
+ public function escapeInt($int){
+ return $this->getTable()->getAdapter()->quote($int,'INT');
+ }
public function renameCustomField(Content_Model_Field_Interface $old, Content_Model_Field_Interface $field) {
//@todo check to make sure section is valid
@@ -400,9 +408,11 @@ public function renameCustomField(Content_Model_Field_Interface $old, Content_Mo
$element = new $class();
-
+ if($field->section === null){
+ throw new Exception('Section Cannot be NULL');
+ }
- $result = $this->getTable()->getAdapter()->query('ALTER TABLE `content_custom_' . mysql_real_escape_string($field->section) . '` CHANGE `' . mysql_real_escape_string($old->name) . '` `' . mysql_real_escape_string($field->name) . '` ' . $element->getMysqlColumn() . ' ');
+ $result = $this->getTable()->getAdapter()->query('ALTER TABLE `content_custom_' . $this->escapeInt($field->section) . '` CHANGE `' . $this->escapeString($old->name) . '` `' . $this->escapeString($field->name) . '` ' . $element->getMysqlColumn() . ' ');
$this->cleanCache(); //reset metadata cache
return $result;
@@ -410,7 +420,7 @@ public function renameCustomField(Content_Model_Field_Interface $old, Content_Mo
public function removeCustomField(Content_Model_Field_Interface $field) {
//alter table
- $result = $this->getTable()->getAdapter()->query('ALTER TABLE `content_custom_' . mysql_real_escape_string($field->section) . '` DROP `' . mysql_real_escape_string($field->name) . '`');
+ $result = $this->getTable()->getAdapter()->query('ALTER TABLE `content_custom_' . $this->escapeInt($field->section) . '` DROP `' . $this->escapeString($field->name) . '`');
$this->cleanCache(); //reset metadata cache
return $result;
}
@@ -418,7 +428,7 @@ public function removeCustomField(Content_Model_Field_Interface $field) {
public function removeCustomTable($section) {
//drop table
//DROP TABLE `content_section_5`
- $result = $this->getTable()->getAdapter()->query('DROP TABLE IF EXISTS `content_custom_' . mysql_real_escape_string($section));
+ $result = $this->getTable()->getAdapter()->query('DROP TABLE IF EXISTS `content_custom_' . $this->escapeInt($section));
$this->cleanCache(); //reset metadata cache
return $result;
}
View
5 application/modules/Content/models/Field/Service.php
@@ -171,7 +171,7 @@ public function update($mixed) {
try {
$found = $this->getObjectBySectionName($object->section, $object->name);
} catch (NotFoundException $e) {
-
+ //throw new DuplicateEntryException('Name already exists ');
}
if ($found !== null) {
@@ -182,10 +182,9 @@ public function update($mixed) {
$old = $this->getObjectById($object->id);
-
$field = $this->getMapper()->save($object);
- if ($field->type != Content_Model_Field::SYSTEM) {
+ if (($field->type != Content_Model_Field::SYSTEM) && ($old->name != $field->name)) {
$service = new Content_Model_Content_Service();
$service->renameCustomField($old, $field);
}
View
9 application/modules/Content/models/Plugin/Template.php
@@ -33,14 +33,15 @@ public function getTemplates(){
public function getFieldSets(){
$fieldSets = array();
- $fieldSets['publish'] = array('title' => 'Publish', 'visible' => true);
+ $fieldSets['default'] = array('title' => 'Publish', 'visible' => true);
return $fieldSets;
}
- public function getFields($fieldSets){
+ public function getFields(){
+ $fieldSets = $this->getFields();
$fields = array();
$fields['title'] = array(
- 'set' => $fieldSets['publish'],
+ 'set' => $fieldSets['default'],
'order' => 1,
'type' => Content_Model_Field::SYSTEM,
'element' => 'Text',
@@ -53,7 +54,7 @@ public function getFields($fieldSets){
'required' => true,
'visible' => true);
$fields['url'] = array(
- 'set' => $fieldSets['publish'],
+ 'set' => $fieldSets['default'],
'order' => 2,
'type' => Content_Model_Field::SYSTEM,
'element' => 'Slug',
View
10 application/modules/Content/plugins/Element/DateTime/Element.php
@@ -227,5 +227,15 @@ public function format($format){
$tempDate = new Zend_Date($this->_value, Zend_Date::ISO_8601);
return $tempDate->toString($format);
}
+
+ public function render() {
+
+ if(!empty($this->_options['format'])){
+ // die(strtotime());
+
+ return $this->format($this->_options['format']);
+ }
+ return parent::render();
+ }
}
View
4 application/modules/Content/plugins/Template/Base/Installer.php
@@ -36,8 +36,8 @@ function getDependencies(){
}
- function getFields($fieldSets){
- $fields = parent::getFields($fieldSets);
+ function getFields(){
+ $fields = parent::getFields();
// $fields[] = array(
// 'set' => $fieldSets['publish'],
// 'order' => 2,
View
92 application/modules/Content/plugins/Template/Blog/Installer.php
@@ -0,0 +1,92 @@
+<?php
+
+/*
+ * Installer.php
+ *
+ * Copyright (c) 2011 Matthew Doll <mdoll at homenet.me>.
+ *
+ * This file is part of HomeNet.
+ *
+ * HomeNet is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HomeNet is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HomeNet. If not, see <http ://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Description of Installer
+ *
+ * @author Matthew Doll <mdoll at homenet.me>
+ */
+class Content_Plugin_Template_Blog_Installer extends Content_Model_Plugin_Template {
+
+ public function getDependencies() {
+ $dependencies = array(
+ );
+ return $dependencies;
+ }
+
+ public function getTemplates() {
+
+ $path = dirname(__FILE__);
+
+ $templates = array();
+ $templates[] = array(
+ 'type' => Content_Model_Template::TEMPLATE,
+ 'url' => 'index',
+ 'content' => file_get_contents($path . '/index.phtml'));
+ return $templates;
+ }
+
+ public function getFields() {
+
+ $fieldSets = $this->getFieldSets();
+ $fields = parent::getFields($fieldSets);
+ $fields['date'] = array(
+ 'set' => $fieldSets['publish'],
+ 'order' => 4,
+ 'type' => Content_Model_Field::TEMPLATE,
+ 'element' => 'DateTime',
+ 'name' => 'date',
+ 'label' => 'Date',
+ 'locked' => false,
+ 'required' => true,
+ 'visible' => true);
+ $fields['categories'] = array(
+ 'set' => $fieldSets['publish'],
+ 'order' => 2,
+ 'type' => Content_Model_Field::TEMPLATE,
+ 'element' => 'Categories',
+ 'name' => 'categories',
+ 'label' => 'Categories',
+ 'locked' => false,
+ 'required' => true,
+ 'visible' => true);
+ $fields['content'] = array(
+ 'set' => $fieldSets['publish'],
+ 'order' => 3,
+ 'type' => Content_Model_Field::TEMPLATE,
+ 'element' => 'Editor',
+ 'name' => 'content',
+ 'label' => 'Content',
+ 'required' => true);
+
+ return $fields;
+ }
+
+// function getContent(){
+// return;
+// }
+//
+// function getOptionalContent(){
+// return array();
+// }
+}
View
7 application/modules/Content/plugins/Template/Blog/category.phtml
@@ -0,0 +1,7 @@
+<?php
+$service = new Content_Model_Content_Service();
+$object = $service->getObjectByUrl($this->params['id']);
+
+echo $this->heading($object->title);
+echo $object->content;
+?>
View
7 application/modules/Content/plugins/Template/Blog/index.phtml
@@ -0,0 +1,7 @@
+<?php
+$service = new Content_Model_Content_Service();
+$object = $service->getObjectByUrl($this->params['id']);
+
+echo $this->heading($object->title);
+echo $object->content;
+?>
View
7 application/modules/Content/plugins/Template/Blog/tag.phtml
@@ -0,0 +1,7 @@
+<?php
+$service = new Content_Model_Content_Service();
+$object = $service->getObjectByUrl($this->params['id']);
+
+echo $this->heading($object->title);
+echo $object->content;
+?>
View
7 application/modules/Content/plugins/Template/Blog/view.phtml
@@ -0,0 +1,7 @@
+<?php
+$service = new Content_Model_Content_Service();
+$object = $service->getObjectByUrl($this->params['id']);
+
+echo $this->heading($object->title);
+echo $object->content;
+?>
View
14 application/modules/Content/plugins/Template/Pages/Installer.php
@@ -48,16 +48,22 @@ public function getTemplates(){
}
- public function getFields($fieldSets){
- $fields = parent::getFields($fieldSets);
- $fields[] = array(
- 'set' => $fieldSets['publish'],
+ public function getFields(){
+
+ $fields = parent::getFields();
+ $fieldSets = $this->getFieldSets();
+ $fields['content'] = array(
+ 'set' => $fieldSets['default'],
'order' => 2,
'type' => Content_Model_Field::TEMPLATE,
'element' => 'Editor',
'name' => 'content',
'label' => 'Content',
'required' => true);
+
+
+
+
return $fields;
}
View
37 application/modules/Content/plugins/Template/Projects/Installer.php
@@ -36,16 +36,19 @@ function getDependencies(){
}
function getFieldSets(){
$fieldSets = array();
- $fieldSets['publish'] = array('title' => 'Project', 'visible' => true);
+ $fieldSets['default'] = array('title' => 'Project', 'visible' => true);
return $fieldSets;
}
- function getFields($fieldSets){
- $fields = parent::getFields($fieldSets);
+ function getFields(){
+
+ $fieldSets = $this->getFieldSets();
+ $fields = parent::getFields($fieldSets);
+
$fields['title']['label'] = 'Project Name';
$fields['categories'] = array(
- 'set' => $fieldSets['publish'],
+ 'set' => $fieldSets['default'],
'order' => 3,
'type' => Content_Model_Field::TEMPLATE,
'element' => 'Categories',
@@ -64,28 +67,14 @@ function getFields($fieldSets){
'locked' => false,
'required' => true,
'visible' => true);
- $fields['description'] = array(
+ $fields['content'] = array(
'set' => $fieldSets['publish'],
- 'order' => 5,
+ 'order' => 2,
'type' => Content_Model_Field::TEMPLATE,
- 'element' => 'textarea',
- 'name' => 'shortDescription',
- 'label' => 'Short Description',
- 'options' => array('rows'=>5,'cols'=>75),
- 'locked' => false,
- 'required' => true,
- 'visible' => true);
- $fields[] = array(
- 'set' => $fieldSets['publish'],
- 'order' => 6,
- 'type' => Content_Model_Field::TEMPLATE,
- 'element' => 'textarea',
- 'name' => 'longDescription',
- 'label' => 'Long Description',
- 'options' => array('rows'=>50,'cols'=>75),
- 'locked' => false,
- 'required' => false,
- 'visible' => true);
+ 'element' => 'Editor',
+ 'name' => 'content',
+ 'label' => 'Content',
+ 'required' => true);
return $fields;
}
View
35 application/modules/Content/plugins/Template/Projects/category.phtml
@@ -0,0 +1,35 @@
+<?php
+$service = new Content_Model_Section_Service();
+$section = $service->getObjectByUrl($this->params['section']);
+
+$service = new Content_Model_Category_Service();
+$category = $service->getObjectByUrl($this->params['id']);
+
+$service = new Content_Model_Content_Service();
+$objects = $service->getObjectsBySectionCategory($section->id,$category->id, array(array('order','date_published','DESC')));
+?>
+<header>
+<?php echo $this->heading($category->title); ?>
+<?php if(!empty($category->description)){ ?>
+<p><?php echo $category->description; ?></p>
+<?php } ?>
+</header>
+<?php
+foreach($objects as $object){
+
+$url = $this->url(array('controller'=>'projects', 'id'=>$object->url),'content-view');
+?>
+
+<section>
+<header>
+ <h2><a href="<?php echo $url ?>"><?php echo $object->title; ?></a></h2>
+ <p><?php echo $object->date; ?></p>
+</header>
+<?php echo $object->description->block('divider')->before(); ?>
+<?php
+if($object->description->block('divider')->exists()){ ?><a class="content-readmore" href="<?php echo $url ?>">Read More</a><?php } ?>
+</section>
+
+<?php
+}
+?>
View
7 application/modules/Content/plugins/Template/Projects/index.phtml
@@ -0,0 +1,7 @@
+<?php
+$service = new Content_Model_Content_Service();
+$object = $service->getObjectByUrl($this->params['id']);
+
+echo $this->heading($object->title);
+echo $object->content;
+?>
View
13 application/modules/Content/plugins/Template/Projects/view.phtml
@@ -0,0 +1,13 @@
+<?php
+$service = new Content_Model_Content_Service();
+$object = $service->getObjectByUrl($this->params['id']);
+?>
+<article>
+<header>
+<?php
+echo $this->heading($object->title);
+?><p><?php echo $object->date ?></p></header>
+<section>
+<?php echo $object->description ?>
+</section>
+</article>
View
4 application/modules/Core/forms/Confirm.php
@@ -24,7 +24,7 @@
* @copyright Copyright (c) 2011 Matthew Doll <mdoll at homenet.me>.
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
*/
-class Core_Form_Confirm extends Zend_Form
+class Core_Form_Confirm extends CMS_Form
{
public $label;
@@ -42,7 +42,7 @@ public function init()
$this->addElement('submit', 'confirm', array('label' => $this->label));
$this->addElement('submit', 'cancel', array('label' => 'Cancel'));
- $this->addElement('hash', 'hash', array('salt' => 'unique'));
+ //$this->addElement('hash', 'hash', array('salt' => 'unique'));
}
}
View
8 application/modules/Core/models/Reflection/Service.php
@@ -225,7 +225,7 @@ public function getPluginConfigsByModuleType($module = null, $type) {
foreach (scandir($path) as $file) {
if (($file != '.') && ($file != '..') && is_dir($path . DIRECTORY_SEPARATOR . $file)) {
- $iniPath = $path . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'Plugin.ini';
+ $iniPath = $path . DIRECTORY_SEPARATOR . $file . DIRECTORY_SEPARATOR . 'plugin.ini';
if (file_exists($iniPath)) {
// require_once($iniPath);
// $className = 'Content_Plugin_Template_' . $file . '_Installer';
@@ -233,9 +233,9 @@ public function getPluginConfigsByModuleType($module = null, $type) {
//$templates[$file] = $className;
$configs[$file] = new Zend_Config_Ini($iniPath);
//$templates[$file] = $config->toArray();
- // } else {
- // throw new Exception('Can Not load Template, Class DNE: '.$file );
- // }
+ } else {
+ throw new Exception('Can Not load Template, Class DNE: '.$file. ' Path:'.$iniPath );
+ // }
} //throw new Exception('Can Not load Template: '.$classPath );
}
}
View
8 library/CMS/Form/Element/JsCodeEditor.php
@@ -32,4 +32,12 @@ class CMS_Form_Element_JsCodeEditor extends CMS_Form_Element_JsElement
*/
public $helper = 'formJsCodeEditor';
public $wide = true;
+
+ // private $decoded = false;
+
+ public function __construct($spec, $options = null) {
+ parent::__construct($spec, $options);
+ }
+
+
}
View
117 library/CMS/Test/PHPUnit/ControllerTestCase.php
@@ -1,28 +1,6 @@
<?php
-abstract class cms_Test_PHPUnit_ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase
-{
-
- final public function bootstrap()
- {
- $this->reset();
- if (null !== $this->bootstrap) {
- if ($this->bootstrap instanceof Zend_Application) {
- $this->bootstrap->bootstrap();
- $this->_frontController = $this->bootstrap->getBootstrap()->getResource('frontcontroller');
- } elseif (is_callable($this->bootstrap)) {
- call_user_func($this->bootstrap);
- } elseif (is_string($this->bootstrap)) {
- require_once 'Zend/Loader.php';
- if (Zend_Loader::isReadable($this->bootstrap)) {
- include $this->bootstrap;
- }
- }
- }
- $this->frontController
- ->setRequest($this->getRequest())
- ->setResponse($this->getResponse());
- }
+abstract class CMS_Test_PHPUnit_ControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase {
/**
* Dispatch the MVC
@@ -31,12 +9,14 @@
* Then sets test case request and response objects in front controller,
* disables throwing exceptions, and disables returning the response.
* Finally, dispatches the front controller.
+ *
+ *
+ * Modfied to throw Exceptions so I can find issues
*
* @param string|null $url
* @return void
*/
- public function dispatch($url = null)
- {
+ public function dispatch($url = null) {
// redirector should not exit
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$redirector->setExit(false);
@@ -45,7 +25,7 @@ public function dispatch($url = null)
$json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
$json->suppressExit = true;
- $request = $this->getRequest();
+ $request = $this->getRequest();
if (null !== $url) {
$request->setRequestUri($url);
}
@@ -53,10 +33,10 @@ public function dispatch($url = null)
$controller = $this->getFrontController();
$this->frontController
- ->setRequest($request)
- ->setResponse($this->getResponse())
- ->throwExceptions(false)
- ->returnResponse(false);
+ ->setRequest($request)
+ ->setResponse($this->getResponse())
+ ->throwExceptions(true)//the line that changed
+ ->returnResponse(false);
if ($this->bootstrap instanceof Zend_Application) {
$this->bootstrap->run();
@@ -65,31 +45,64 @@ public function dispatch($url = null)
}
}
- /**
- * Retrieve test case request object
- *
- * @return Zend_Controller_Request_Abstract
- */
- public function getRequest()
- {
- if (null === $this->_request) {
- require_once 'Zend/Controller/Request/HttpTestCase.php';
- $this->_request = new Zend_Controller_Request_HttpTestCase;
+ private $_module;
+ private $_controller;
+ private $_action;
+
+ protected function setModule($module) {
+ $this->_module = $module;
+ $this->getRequest()->setModuleName($module);
+ }
+
+ protected function setController($controller) {
+ $this->_controller = $controller;
+ $this->getRequest()->setControllerName($controller);
+ }
+
+ protected function setAction($action) {
+ $this->_action = $action;
+ $this->getRequest()->setActionName($action);
+ }
+
+ protected function assertACM($action = null, $controller = null, $module = null) {
+
+ if ($action === null) {
+ $this->assertAction($this->_action);
+ } else {
+ $this->assertAction($action);
}
- return $this->_request;
+
+ if ($controller === null) {
+ $this->assertController($this->_controller);
+ } else {
+ $this->assertController($controller);
+ }
+
+ if ($module === null) {
+ $this->assertModule($this->_module);
+ } else {
+ $this->assertModule($module);
+ }
+ }
+
+ protected function _getTestData($seed = 0) {
+
+ return array();
}
- /**
- * Retrieve test case response object
- *
- * @return Zend_Controller_Response_Abstract
- */
- public function getResponse()
- {
- if (null === $this->_response) {
- require_once 'Zend/Controller/Response/HttpTestCase.php';
- $this->_response = new Zend_Controller_Response_HttpTestCase;
+ protected function _fillObject($object, $seed = 0) {
+ $data = $this->_getTestData($seed);
+ foreach ($data as $key => $value) {
+ $object->$key = $value;
}
- return $this->_response;
+ return $object;
}
+
+ protected function _fillArray($array, $seed = 0) {
+ if (is_object($array)) {
+ $array = $array->toArray();
+ }
+ return array_merge($array, $this->_getTestData($seed));
+ }
+
}
View
13 library/CMS/View/Helper/FormJsCodeEditor.php
@@ -65,7 +65,7 @@ public function formJsCodeEditor($name, $value, $attribs = null, $params = null)
//$params['layout'] = 'gallery';
// $params['types'] = 'images';
-
+ $this->view->headScript()->appendFile('/js/libs/jquery.base64.min.js');
$this->view->headScript()->appendFile('/plugins/codemirror/lib/codemirror.js');
$this->view->headLink()->appendStylesheet('/plugins/codemirror/lib/codemirror.css');
$this->view->headLink()->appendStylesheet('/plugins/codemirror/theme/default.css');
@@ -94,7 +94,16 @@ public function formJsCodeEditor($name, $value, $attribs = null, $params = null)
unset($params['type']);
$this->view->jquery()->addOnLoad('var editor = CodeMirror.fromTextArea(document.getElementById("'.$attribs['id'].'"), '.str_replace('\/', '/', Zend_Json::encode($params,false,
- array('enableJsonExprFinder' => true))).');');
+ array('enableJsonExprFinder' => true))).");
+
+ var jEditor = $('#$name');
+ jEditor.parents('form').submit(function(){
+ jEditor.val($.base64.encode(jEditor.val()));
+
+ })
+
+
+");
return '<textarea '.$this->_htmlAttribs($attribs).'>'.$value.'</textarea>';
View
4 tests/application/modules/Content/controllers/Content_CategoryControllerTest.php
@@ -16,7 +16,7 @@ class Content_CategoryControllerTest extends Zend_Test_PHPUnit_ControllerTestCas
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
@@ -219,7 +219,7 @@ public function testDeleteAction_submitDelete() {
$this->getRequest()->setActionName('Delete');
$this->getRequest()->setParam('id', $object->id);
$this->getRequest()->setMethod('POST')
- ->setPost(array('delete' => 'delete'));
+ ->setPost(array('confirm' => 'confirm'));
//run
$this->dispatch();
View
7 tests/application/modules/Content/controllers/Content_CategorySetControllerTest.php
@@ -16,7 +16,7 @@ class Content_CategorySetControllerTest extends Zend_Test_PHPUnit_ControllerTest
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
@@ -204,13 +204,16 @@ public function testDeleteAction_submitDelete() {
$this->getRequest()->setActionName('Delete');
$this->getRequest()->setParam('id', $object->id);
$this->getRequest()->setMethod('POST')
- ->setPost(array('delete' => 'delete'));
+ ->setPost(array('confirm' => 'confirm'));
//run
$this->dispatch();
+ // var_dump($this->getResponse()->getBody());
+ // die('early');
$this->assertModule('Content');
$this->assertController('CategorySet');
$this->assertAction('Delete');
$this->assertRedirect();
+
}
}
View
4 tests/application/modules/Content/controllers/Content_ContentControllerTest.php
@@ -16,7 +16,7 @@ class Content_ContentControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
@@ -213,7 +213,7 @@ public function testDeleteAction_submitDelete() {
$this->getRequest()->setActionName('Delete');
$this->getRequest()->setParam('id', $object->id);
$this->getRequest()->setMethod('POST')
- ->setPost(array('delete' => 'delete'));
+ ->setPost(array('confirm' => 'confirm'));
//run
$this->dispatch();
View
4 tests/application/modules/Content/controllers/Content_FieldControllerTest.php
@@ -16,7 +16,7 @@ class Content_FieldControllerTest extends Zend_Test_PHPUnit_ControllerTestCase {
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
@@ -230,7 +230,7 @@ public function testDeleteAction_submitDelete() {
$this->getRequest()->setActionName('Delete');
$this->getRequest()->setParam('id', $object->id);
$this->getRequest()->setMethod('POST')
- ->setPost(array('delete' => 'delete'));
+ ->setPost(array('confirm' => 'confirm'));
//run
$this->dispatch();
View
4 tests/application/modules/Content/controllers/Content_FieldSetControllerTest.php
@@ -16,7 +16,7 @@ class Content_FieldSetControllerTest extends Zend_Test_PHPUnit_ControllerTestCas
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
@@ -201,7 +201,7 @@ public function testDeleteAction_submitDelete() {
$this->getRequest()->setActionName('Delete');
$this->getRequest()->setParam('id', $object->id);
$this->getRequest()->setMethod('POST')
- ->setPost(array('delete' => 'delete'));
+ ->setPost(array('confirm' => 'confirm'));
//run
$this->dispatch();
View
2  tests/application/modules/Content/controllers/Content_IndexControllerTest.php
@@ -16,7 +16,7 @@ class Content_IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase {
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
View
4 tests/application/modules/Content/controllers/Content_SectionControllerTest.php
@@ -16,7 +16,7 @@ class Content_SectionControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
@@ -214,7 +214,7 @@ public function testDeleteAction_submitDelete() {
$this->getRequest()->setActionName('Delete');
$this->getRequest()->setParam('id', $object->id);
$this->getRequest()->setMethod('POST')
- ->setPost(array('delete' => 'delete'));
+ ->setPost(array('confirm' => 'confirm'));
//run
$this->dispatch();
View
4 tests/application/modules/Content/controllers/Content_TemplateControllerTest.php
@@ -19,7 +19,7 @@ class Content_TemplateControllerTest extends Zend_Test_PHPUnit_ControllerTestCas
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->installer->loginAsSuperAdmin();
@@ -230,7 +230,7 @@ public function testDeleteAction_submitDelete() {
$this->getRequest()->setActionName('Delete');
$this->getRequest()->setParam('id', $object->id);
$this->getRequest()->setMethod('POST')
- ->setPost(array('delete' => 'delete'));
+ ->setPost(array('confirm' => 'confirm'));
//run
$this->dispatch();
View
2  tests/application/modules/Content/models/Field/Content_Model_Field_ServiceTest.php
@@ -19,7 +19,7 @@ class Content_Model_Field_ServiceTest extends PHPUnit_Framework_TestCase {
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
$this->contentInstaller = new Content_Installer();
View
2  tests/application/modules/Content/models/Section/Content_Model_Section_ManagerTest.php
@@ -18,7 +18,7 @@ class Content_Model_Section_ManagerTest extends PHPUnit_Framework_TestCase {
*/
protected function setUp() {
$this->object = new Content_Model_Section_Manager;
- $installer = new Installer();
+ $installer = new Core_Installer();
$installer->installTest();
$installer->loginAsSuperAdmin();
}
View
2  tests/application/modules/Core/models/Acl/Core_Model_Acl_ManagerTest.php
@@ -19,7 +19,7 @@ class Core_Model_Acl_ManagerTest extends PHPUnit_Framework_TestCase {
*/
protected function setUp() {
- $this->installer = new Installer();
+ $this->installer = new Core_Installer();
$this->installer->installTest();
//$uService = new Core_Model_User_Service();
View
10 tests/application/modules/Core/models/Reflection/Core_Model_Reflection_ServiceTest.php
@@ -1,7 +1,5 @@
<?php
-require_once dirname(__FILE__) . '/../../../../application/models/Reflection/Service.php';
-
/**
* Test class for Core_Model_Reflection_Service.
* Generated by PHPUnit on 2011-09-19 at 01:14:28.
@@ -96,14 +94,14 @@ public function testGetActionsByModuleController() {
public function testGetThemes() {
$array = $this->object->getThemes();
- var_dump($array);
+
$this->assertTrue(is_array($array));
$this->assertTrue(in_array('default', $array));
}
public function testGetLayouts() {
$array = $this->object->getLayouts('default');
- var_dump($array);
+
$this->assertTrue(is_array($array));
$this->assertTrue(in_array('header', $array));
$this->assertTrue(in_array('footer', $array));
@@ -120,6 +118,4 @@ public function testGetTemplateInstaller() {
);
}
-}
-
-?>
+}
Please sign in to comment.
Something went wrong with that request. Please try again.