Skip to content

Commit

Permalink
Merge 388bd56 into 9856091
Browse files Browse the repository at this point in the history
  • Loading branch information
bramcordie committed Jan 13, 2017
2 parents 9856091 + 388bd56 commit 4ddc3a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/CultureFeed/Cdb/Item/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,11 +675,12 @@ public function deleteKeyword($keyword)
$keyword = $keyword->getValue();
}

if (!isset($this->keywords[$keyword])) {
throw new Exception('Trying to remove a non-existing keyword.');
}

unset($this->keywords[$keyword]);
$this->keywords = array_filter(
$this->keywords,
function (CultureFeed_Cdb_Data_Keyword $itemKeyword) use ($keyword) {
return strcmp(mb_strtolower($itemKeyword->getValue(), 'UTF-8'), mb_strtolower($keyword, 'UTF-8')) !== 0;
}
);
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/CultureFeed/Cdb/Item/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ public function testDeleteKeywordObjects()
{
$this->event->addKeyword(new CultureFeed_Cdb_Data_Keyword('foo'));
$this->event->addKeyword(new CultureFeed_Cdb_Data_Keyword('bar'));
$this->event->addKeyword(new CultureFeed_Cdb_Data_Keyword('BAR'));

$this->event->deleteKeyword(new CultureFeed_Cdb_Data_Keyword('bar'));

Expand Down

0 comments on commit 4ddc3a5

Please sign in to comment.