Skip to content

Commit

Permalink
The method attachTags was raising a Notice error, fix it and adds a t…
Browse files Browse the repository at this point in the history
…est for this situation.
  • Loading branch information
ricardosdl committed Dec 9, 2012
1 parent 2420b7a commit f20fb3f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/SemanticScuttle/Service/Bookmark2Tag.php
Expand Up @@ -97,12 +97,13 @@ public function attachTags(


$tags_count = is_array($tags)?count($tags):0;

foreach($tags as $i => $tag) {
$tags[$i] = trim(utf8_strtolower($tags[$i]));
if ($fromApi) {
include_once 'SemanticScuttle/functions.php';
$tags[$i] = convertTag($tags[$i], 'in');
if (is_array($tags)) {
foreach($tags as $i => $tag) {
$tags[$i] = trim(utf8_strtolower($tags[$i]));
if ($fromApi) {
include_once 'SemanticScuttle/functions.php';
$tags[$i] = convertTag($tags[$i], 'in');
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions tests/Bookmark2TagTest.php
Expand Up @@ -88,6 +88,21 @@ public function testAttachTagsWithArrayWithEmptyStringAddsSystemUnfiled()
$this->b2ts->getTagsForBookmark($bid, true)
);
}

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);
}



Expand Down

0 comments on commit f20fb3f

Please sign in to comment.