public function test_rename() { global $table_prefix; // uses auth, so we set up the mock/stub // to allow reading first forum $this->auth->expects($this->once())->method('acl_getf')->with($this->equalTo('f_read'))->willReturn(array(1 => array('f_read' => true))); $sql_array = array('tag' => 'tag1'); $result = $this->db->sql_query('SELECT COUNT(*) as count FROM ' . $table_prefix . tables::TAGS . ' WHERE ' . $this->db->sql_build_array('SELECT', $sql_array)); $count = $this->db->sql_fetchfield('count'); $this->assertEquals(1, $count); $sql_array = array('tag' => 'newtagname'); $result = $this->db->sql_query('SELECT COUNT(*) as count FROM ' . $table_prefix . tables::TAGS . ' WHERE ' . $this->db->sql_build_array('SELECT', $sql_array)); $count = $this->db->sql_fetchfield('count'); $this->assertEquals(0, $count); $tag_id = 1; $new_name_clean = "newtagname"; $assigned_count = $this->tags_manager->rename($tag_id, $new_name_clean); $this->assertEquals(1, $assigned_count); $sql_array = array('tag' => 'tag1'); $result = $this->db->sql_query('SELECT COUNT(*) as count FROM ' . $table_prefix . tables::TAGS . ' WHERE ' . $this->db->sql_build_array('SELECT', $sql_array)); $count = $this->db->sql_fetchfield('count'); $this->assertEquals(0, $count); $sql_array = array('tag' => 'newtagname'); $result = $this->db->sql_query('SELECT COUNT(*) as count FROM ' . $table_prefix . tables::TAGS . ' WHERE ' . $this->db->sql_build_array('SELECT', $sql_array)); $count = $this->db->sql_fetchfield('count'); $this->assertEquals(1, $count); }