/**
  * test add new message
  */
 public function testAdd()
 {
     $feedModel = new application_models_feeds();
     $currentDatetime = date('Y-m-d H:i:s');
     $this->model->add($feedModel->find(1)->current(), 'testmessage no 1');
     // error in feed set
     $this->assertEquals('1', $feedModel->find(1)->current()->error);
     // correct error message added
     $this->assertGreaterThan(0, $this->model->fetchAll()->count());
     $result = $this->model->fetchAll($this->model->select()->order('id DESC'))->current();
     $this->assertEquals($currentDatetime, $result->datetime);
     $this->assertEquals('testmessage no 1', $result->message);
     $this->assertEquals('1', $result->feed);
 }
 /**
  * show messages
  *
  * @return void
  */
 public function indexAction()
 {
     $offset = $this->getRequest()->getParam('offset', 0);
     // load latest errormessages
     $messagesModel = new application_models_messages();
     $messages = $messagesModel->fetchAll($messagesModel->select()->order('datetime DESC')->limit(Zend_Registry::get('config')->errormessages->length, $offset));
     // load feedname
     $this->view->messages = array();
     foreach ($messages as $message) {
         $msg = $message->toArray();
         $msg['feed'] = $message->findParentRow('application_models_feeds')->name;
         $this->view->messages[] = $msg;
     }
     $this->view->offset = $offset;
 }
 /**
  * test remove a feed
  */
 public function testRemove()
 {
     $this->model->remove(3);
     // feed really deleted
     $this->assertEquals(0, $this->model->find(3)->count());
     // all items deleted
     $itemModel = new application_models_items();
     $result = $itemModel->fetchAll($itemModel->select()->where('feed=?', 3));
     $this->assertEquals(0, $result->count());
     // no icon file
     $this->assertFalse(file_exists(Zend_Registry::get('config')->favicons->path . "4711.ico"));
     // no messages
     $messagesModel = new application_models_messages();
     $result = $messagesModel->fetchAll($messagesModel->select()->where('feed=?', 3));
     $this->assertEquals(0, $result->count());
     // check reorder
     $this->assertEquals('0', $this->model->find('1')->current()->position);
     // correct position
     $this->assertEquals('1', $this->model->find('2')->current()->position);
     // correct position
     // validation
     $this->assertTrue($this->model->remove(222) !== true);
 }