Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/1.1' into 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Simonas Šerlinskas committed Sep 13, 2016
2 parents 5bef7fb + 0f20ea9 commit a7f676c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Mapping/DocumentParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private function getDocumentType($document)
$reflectionClass = new \ReflectionClass($namespace);
$document = $this->getDocumentAnnotationData($reflectionClass);

return empty($document->type) ? $reflectionClass->getShortName() : $document->type;
return empty($document->type) ? Caser::snake($reflectionClass->getShortName()) : $document->type;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Profiler/ElasticsearchProfiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private function handleRecords($route, $records)
private function addQuery($route, $record, $queryBody)
{
parse_str(parse_url($record['context']['uri'], PHP_URL_QUERY), $httpParameters);
$body = json_decode(trim($queryBody, " '\r\t\n"), true);
$body = json_decode(trim($queryBody, " '\r\t\n"));
$this->queries[$route][] = array_merge(
[
'body' => $body !== null ? json_encode($body, JSON_PRETTY_PRINT) : '',
Expand Down
20 changes: 20 additions & 0 deletions Tests/Functional/Profiler/ElasticsearchProfilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

use ONGR\ElasticsearchBundle\Profiler\ElasticsearchProfiler;
use ONGR\ElasticsearchBundle\Tests\app\fixture\Acme\BarBundle\Document\Product;
use ONGR\ElasticsearchDSL\Aggregation\GlobalAggregation;
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchBundle\Service\Repository;
use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase;
Expand Down Expand Up @@ -161,4 +163,22 @@ private function getCollector()

return $collector;
}

public function testMatchAllQuery()
{
$manager = $this->getManager();

$repository = $manager->getRepository('AcmeBarBundle:Product');
$search = $repository
->createSearch()
->addAggregation(new GlobalAggregation('g'));
$repository->execute($search);

$queries = $this->getCollector()->getQueries();
$lastQuery = end($queries[ElasticsearchProfiler::UNDEFINED_ROUTE]);
$this->checkQueryParameters($lastQuery);
$lastQuery['body'] = trim(preg_replace('/\s+/', '', $lastQuery['body']));

$this->assertEquals('{"aggregations":{"g":{"global":{}}}}', $lastQuery['body']);
}
}

0 comments on commit a7f676c

Please sign in to comment.