/**
  * test flags (add + clear + deleted)
  */
 public function testAddAndClearFlags()
 {
     $message = $this->_sendMessage();
     $inboxBefore = $this->_getFolder('INBOX');
     $this->_json->addFlags($message['id'], Zend_Mail_Storage::FLAG_SEEN);
     // check if unread count got decreased
     $inboxAfter = $this->_getFolder('INBOX');
     $this->assertTrue($inboxBefore->cache_unreadcount - 1 == $inboxAfter->cache_unreadcount, 'wrong cache unreadcount');
     $message = $this->_json->getMessage($message['id']);
     $this->assertTrue(in_array(Zend_Mail_Storage::FLAG_SEEN, $message['flags']), 'seen flag not set');
     // try with a filter
     $filter = array(array('field' => 'id', 'operator' => 'in', array($message['id'])));
     $this->_json->clearFlags($filter, Zend_Mail_Storage::FLAG_SEEN);
     $message = $this->_json->getMessage($message['id']);
     $this->assertFalse(in_array(Zend_Mail_Storage::FLAG_SEEN, $message['flags']), 'seen flag should not be set');
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $this->_json->addFlags(array($message['id']), Zend_Mail_Storage::FLAG_DELETED);
     $this->_json->getMessage($message['id']);
 }