public function testAddTag() { $db = Zend_Registry::get('db'); $new_note_id = Zend_Registry::get('new_note_id'); $note = new Database_Notes($db); $note->load($new_note_id); // $tag_id = $note->createTag('new tag'); $tag_name = 'new new tag'; Zend_Registry::set('tag_name', $tag_name); //创建一个新tag $new_tag_id = $note->addTag($tag_name); //为调用tagIsExistInThisNote ,需要 reload $note->load($new_note_id); //断言刚添加tag的name $this->assertTrue($note->tagIsExistInThisNote($tag_name)); //检查tagNameToId和tagIdToname是否运转正确 $this->assertEquals($new_tag_id, $note->tagNameToId($tag_name)); $this->assertEquals($tag_name, $note->tagIdToname($new_tag_id)); $this->dispatch("/"); Zend_Registry::set('new_tag_id', $new_tag_id); }