/**
  * @dataProvider balanceQuotesTestCases
  */
 public function testBalanceQuotes($input, $expected)
 {
     $escaper = new Escaper('en');
     // Language doesn't matter here
     $actual = $escaper->balanceQuotes($input);
     $this->assertEquals($expected, $actual);
 }
 /**
  * @param Escaper $escaper
  * @param SearchContext $context
  * @param string $value
  * @param bool $updateHighlightSourceRef
  * @param callable $fieldF
  * @return callable
  */
 private static function insourceOrIntitle($escaper, $context, $value, $updateHighlightSourceRef, $fieldF)
 {
     list($queryString, $fuzzyQuery) = $escaper->fixupWholeQueryString($escaper->fixupQueryStringPart($value));
     $field = $fieldF($queryString);
     $query = new \Elastica\Query\QueryString($queryString);
     $query->setFields(array($field));
     $query->setDefaultOperator('AND');
     $query->setAllowLeadingWildcard($escaper->getAllowLeadingWildcard());
     $query->setFuzzyPrefixLength(2);
     $query->setRewrite('top_terms_boost_1024');
     $wrappedQuery = $context->wrapInSaferIfPossible($query, false);
     $updateReferences = function (&$fuzzyQueryRef, &$filterDestinationRef, &$highlightSourceRef, &$searchContainedSyntaxRef) use($fuzzyQuery, $wrappedQuery, $updateHighlightSourceRef) {
         $fuzzyQueryRef = $fuzzyQuery;
         $filterDestinationRef[] = new \Elastica\Filter\Query($wrappedQuery);
         if ($updateHighlightSourceRef) {
             $highlightSourceRef[] = array('query' => $wrappedQuery);
         }
         $searchContainedSyntaxRef = true;
     };
     return $updateReferences;
 }