The method attachTags was raising a Notice error, fix it and adds a test for this situation.
This commit is contained in:
parent
3e2d817fc7
commit
2f865db513
2 changed files with 22 additions and 6 deletions
|
@ -97,12 +97,13 @@ class SemanticScuttle_Service_Bookmark2Tag extends SemanticScuttle_DbService
|
||||||
|
|
||||||
|
|
||||||
$tags_count = is_array($tags)?count($tags):0;
|
$tags_count = is_array($tags)?count($tags):0;
|
||||||
|
if (is_array($tags)) {
|
||||||
foreach($tags as $i => $tag) {
|
foreach($tags as $i => $tag) {
|
||||||
$tags[$i] = trim(utf8_strtolower($tags[$i]));
|
$tags[$i] = trim(utf8_strtolower($tags[$i]));
|
||||||
if ($fromApi) {
|
if ($fromApi) {
|
||||||
include_once 'SemanticScuttle/functions.php';
|
include_once 'SemanticScuttle/functions.php';
|
||||||
$tags[$i] = convertTag($tags[$i], 'in');
|
$tags[$i] = convertTag($tags[$i], 'in');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,21 @@ class Bookmark2TagTest extends TestBase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAttachTagsWithEmptyStringAddsSystemUnfiled()
|
||||||
|
{
|
||||||
|
$originalDisplayErros = ini_get('display_errors');
|
||||||
|
$originalErrorReporting = ini_get('error_reporting');
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
$bid = $this->addBookmark(null, null, 0, '');
|
||||||
|
$this->assertEquals(
|
||||||
|
array('system:unfiled'),
|
||||||
|
$this->b2ts->getTagsForBookmark($bid, true)
|
||||||
|
);
|
||||||
|
ini_set('display_errors', $originalDisplayErros);
|
||||||
|
error_reporting($originalErrorReporting);
|
||||||
|
}
|
||||||
|
|
||||||
public function testAttachTagsWithSomeEmptyTags()
|
public function testAttachTagsWithSomeEmptyTags()
|
||||||
{
|
{
|
||||||
$bid = $this->addBookmark(null, null, 0, array());
|
$bid = $this->addBookmark(null, null, 0, array());
|
||||||
|
|
Loading…
Reference in a new issue