/**
  * test automatic generation of uncategorized cat
  * setUp will not insert the uncategrized cat
  */
 public function testCheckUncategorized()
 {
     $this->assertEquals(0, $this->model->find(-1)->count());
     $this->model->checkUncategorized();
     $this->assertEquals(1, $this->model->find(-1)->count());
     $this->model->checkUncategorized();
     $this->assertEquals(1, $this->model->find(-1)->count());
     // dont add it twice
 }
 /**
  * set feedlist data for the current view
  *
  * @return void
  */
 protected function feedlistData()
 {
     // check whether uncategorized exists or not (add it if not)
     $categoriesModel = new application_models_categories();
     $categoriesModel->checkUncategorized();
     // categories and feeds (target template param)
     $this->view->categories = array();
     // load unread items
     $itemCounter = Zend_Controller_Action_HelperBroker::getStaticHelper('itemcounter');
     $unreadCategory = $itemCounter->unreadItemsCategories();
     $unreadFeed = $itemCounter->unreadItemsFeeds();
     // get open categories
     if (Zend_Registry::get('session')->saveOpenCategories == 1) {
         $open = explode(',', Zend_Registry::get('session')->openCategories);
     } else {
         $open = array();
     }
     // load categories
     $categoriesDb = $categoriesModel->fetchAll($categoriesModel->select()->order('position ASC'));
     $feedPositions = Zend_Controller_Action_HelperBroker::getStaticHelper('icon')->getFeedsIconPosition();
     // read feeds and count items of the loaded categories
     $feedsModel = new application_models_feeds();
     foreach ($categoriesDb as $cat) {
         $newcat = $cat->toArray();
         // get feeds of cat
         $feedRowset = $cat->findDependentRowset('application_models_feeds', null, $feedsModel->select()->order('position ASC'));
         $newcat['feeds'] = array();
         foreach ($feedRowset as $feed) {
             $newfeed = $feed->toArray();
             $newfeed['unread'] = isset($unreadFeed[$feed->id]) ? $unreadFeed[$feed->id] : 0;
             $newfeed['iconposition'] = $feedPositions[$feed->id];
             $newcat['feeds'][] = $newfeed;
         }
         // get unread items of cat
         $newcat['unread'] = isset($unreadCategory[$cat->id]) ? $unreadCategory[$cat->id] : 0;
         // set open (feeds visible) or not
         if (in_array($cat->id, $open)) {
             $newcat['open'] = true;
         } else {
             $newcat['open'] = false;
         }
         // append category
         $this->view->categories[] = $newcat;
     }
     // count starred items
     $this->view->starred = $itemCounter->starredItems();
     // count unread items
     $this->view->unread = $unreadCategory[0];
     // count all items
     $this->view->all = $itemCounter->allItems();
     // count read items
     $this->view->read = $this->view->all - $this->view->unread;
     // count feeds
     $this->view->amountfeeds = $feedsModel->count(Zend_Registry::get('session')->currentPriorityStart, Zend_Registry::get('session')->currentPriorityEnd, Zend_Registry::get('session')->view);
 }