From a3d70f50aacd5037d3f010406832c776fbd1c0d2 Mon Sep 17 00:00:00 2001 From: Benjamin Brahmer Date: Sat, 6 Aug 2022 14:00:11 +0200 Subject: Fix Test and adjust code Signed-off-by: Benjamin Brahmer --- lib/Db/Item.php | 2 +- tests/Unit/Db/ItemTest.php | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Db/Item.php b/lib/Db/Item.php index 06e1091f4..0ed9e9113 100644 --- a/lib/Db/Item.php +++ b/lib/Db/Item.php @@ -184,7 +184,7 @@ class Item extends Entity implements IAPI, \JsonSerializable if (is_null($value)) { $search_string .= ""; } else { - html_entity_decode($value); + $search_string .= html_entity_decode($value); } } diff --git a/tests/Unit/Db/ItemTest.php b/tests/Unit/Db/ItemTest.php index 68b7b5ab8..11620b33c 100644 --- a/tests/Unit/Db/ItemTest.php +++ b/tests/Unit/Db/ItemTest.php @@ -317,6 +317,18 @@ class ItemTest extends TestCase $this->assertEquals($expected, $item->getSearchIndex()); } + public function testSearchIndexNull() + { + $item = new Item(); + $item->setBody('somEthäng'); + $item->setUrl('http://link'); + $item->setAuthor(null); + $item->setTitle('tätle'); + $item->setCategories(['food', 'travel']); + $item->generateSearchIndex(); + $expected = 'somethängtätlefoodtravelhttp://link'; + $this->assertEquals($expected, $item->getSearchIndex()); + } public function testFromImport() { -- cgit v1.2.3