$mockCategories->expects(self::once())->method('findAll')->with($id)->willReturn($types);
$client->getContainer()->set(BenefitCategoryRepository::class, $mockCategories);
$this->item->fulltext = addContent($this->item->fulltext,'<div>любой код</div>',5);
$this->item->fulltext = addContent($this->item->fulltext,'<div>любой код1</div>', 1, '</h2>');
$this->item->fulltext = addContent($this->item->fulltext,'<div>любой код2</div>', 1, '</h3>');
foreach($res as $line)
{
if(strlen($line) === 0 ) continue; //в лоб
if(!strripos($line, "<|>")) continue; //Но вот так наверно лучше будет.
$elem = explode("<|>",$line);
echo "<li><a href=".$elem[1]." target='_blank'>".$elem[2]."</a></li>";
}