Skip to content

Commit

Permalink
The hasTag was always returning false, which probably is a bug. Fixed…
Browse files Browse the repository at this point in the history
… it and added a test to catch it.
  • Loading branch information
ricardosdl committed Dec 11, 2012
1 parent f20fb3f commit e32c6fb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/SemanticScuttle/Service/Bookmark2Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,13 +627,14 @@ function hasTag($bookmarkid, $tag) {
message_die(GENERAL_ERROR, 'Could not find tag', '', __LINE__, __FILE__, $query, $this->db);
return false;
}


$output = false;
if ($row =& $this->db->sql_fetchrow($dbresult)) {
if ($row['tCount'] > 0) {
$output = true;
}
}
$output = false;

$this->db->sql_freeresult($dbresult);
return $output;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/Bookmark2TagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,5 +667,15 @@ public function testGetContactTagsBeginsWith()
$this->assertContains(array('tag' => 'usertag1', 'bCount' => '1'), $arTags);
$this->assertContains(array('tag' => 'usable', 'bCount' => '2'), $arTags);
}

public function testHasTag() {
$bid = $this->addBookmark(null, null, 0, array('foo'));

$this->assertTrue($this->b2ts->hasTag($bid, 'foo'));
//this test is because we are using the utf8_general_ci encoding,
//which removes all accents
$this->assertTrue($this->b2ts->hasTag($bid, 'fóo'));

}
}
?>

0 comments on commit e32c6fb

Please sign in to comment.