public function testGetGroupedResults()
 {
     $expectedString = 'expected';
     $firstClass = 'firstClass';
     $firstConfig = array('alias' => $firstClass);
     $firstLabel = 'first label';
     $firstIcon = 'first icon';
     $firstConfigEntity = $this->getConfigEntity($firstLabel, $firstIcon);
     $first = $this->getSearchResultEntity($firstConfig, $firstClass);
     $secondClass = 'secondClass';
     $secondConfig = array('alias' => $secondClass);
     $secondLabel = 'second label';
     $secondIcon = 'second icon';
     $second = $this->getSearchResultEntity($secondConfig, $secondClass);
     $secondConfigEntity = $this->getConfigEntity($secondLabel, $secondIcon);
     $map = array($firstClass => $firstConfigEntity, $secondClass => $secondConfigEntity);
     $this->configManager->expects($this->exactly(2))->method('getConfig')->will($this->returnCallback(function (EntityConfigId $entityConfigId) use($map) {
         return $map[$entityConfigId->getClassName()];
     }));
     $elements = array($second, $first, $first);
     $expected = array('' => array('count' => 3, 'class' => '', 'config' => array(), 'label' => '', 'icon' => ''), $firstClass => array('count' => 2, 'class' => $firstClass, 'config' => $firstConfig, 'label' => $firstLabel, 'icon' => $firstIcon), $secondClass => array('count' => 1, 'class' => $secondClass, 'config' => $secondConfig, 'label' => $secondLabel, 'icon' => $secondIcon));
     $this->search->expects($this->once())->method('getElements')->will($this->returnValue($elements));
     $this->translator->expects($this->exactly(2))->method('trans')->will($this->returnArgument(0));
     $actual = $this->target->getGroupedResults($expectedString);
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 /**
  * @param EntityManager       $em
  * @param ObjectMapper        $mapper
  * @param SecurityProvider    $securityProvider
  * @param Indexer             $indexer
  * @param ConfigManager       $configManager
  * @param TranslatorInterface $translator
  */
 public function __construct(EntityManager $em, ObjectMapper $mapper, SecurityProvider $securityProvider, Indexer $indexer, ConfigManager $configManager, TranslatorInterface $translator)
 {
     $this->em = $em;
     $this->mapper = $mapper;
     $this->securityProvider = $securityProvider;
     parent::__construct($indexer, $configManager, $translator);
 }