/** * Create new post */ public function createAction() { $form = new Blog_Form_Post_Create(); if ($this->getRequest()->isPost() && $form->isValid($this->_getAllParams())) { $posts = new Blog_Model_Post_Table(); $post = $posts->createRow(); $post->setFromArray($form->getValues()); $post->save(); $this->_helper->flashMessenger->addMessage('Post created'); $this->_helper->redirector('index', null, null, array('alias' => $post->alias)); } $this->view->form = $form; }
public function testEditWithDataAction() { $table = new Blog_Model_Post_Table(); $manager = new Blog_Model_Category_Manager(); $rootCat = $manager->getRoot(); $cat = $manager->getDbTable()->createRow($this->_fixture['category']); $rootCat->addChild($cat); $post = $table->createRow($this->_fixture['post']); $post->save(); $this->_doLogin(); $this->request->setMethod('POST')->setPost(array('title' => 'tttttttt', 'body' => 'tttttttt', 'categoryId' => 93, 'status' => 'draft')); $this->dispatch('/blog/post/edit/alias/' . $this->_fixture['post']['alias']); $this->assertModule('blog'); $this->assertController('post'); $this->assertAction('edit'); $post->delete(); $cat->delete(); }