/** * @dataProvider dataProviderGetGroupedItemsIdsByEntity * @param $expected * @param $items */ public function testGetGroupedItemsIdsByEntity($expected, $items) { $grouped_items = SearchApiEtHelper::getGroupedItemsIdsByEntity($items); $this->assertEquals($expected, $grouped_items); }
/** * Filters the given Item IDs to include only the ones handled by the Index. * * @param SearchApiIndex $index * The SearchAPI index to use * @param array $item_ids * A list of trackable ItemID (in the form "{id}/{language}) to filter * @return array * The filtered list of trackable ItemID */ protected function filterTrackableIds(SearchApiIndex $index, $item_ids) { if (empty($item_ids)) { return array(); } // Group the given ItemIds by their EntityId. $grouped_item_ids = SearchApiEtHelper::getGroupedItemsIdsByEntity($item_ids); if (empty($grouped_item_ids)) { return array(); } // Generate the list of candidate ItemIDs from the current EntityIDs $trackable_item_ids = $this->getTrackableItemIds($index, array_keys($grouped_item_ids)); // The $trackable_item_ids will contain all ItemIDs that should be indexed. // Additional translations, other than the one provided in $item_ids, will // be taken into account, to cover the case when a non-translatable field is // changed on one translation and such change must be reflected to all other // indexed translations. return $trackable_item_ids; }