Skip to content

Commit a7f676c

Browse files
author
Simonas Šerlinskas
committed
Merge remote-tracking branch 'remotes/upstream/1.1' into 1.2
2 parents 5bef7fb + 0f20ea9 commit a7f676c

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Mapping/DocumentParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ private function getDocumentType($document)
378378
$reflectionClass = new \ReflectionClass($namespace);
379379
$document = $this->getDocumentAnnotationData($reflectionClass);
380380

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

384384
/**

Profiler/ElasticsearchProfiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private function handleRecords($route, $records)
173173
private function addQuery($route, $record, $queryBody)
174174
{
175175
parse_str(parse_url($record['context']['uri'], PHP_URL_QUERY), $httpParameters);
176-
$body = json_decode(trim($queryBody, " '\r\t\n"), true);
176+
$body = json_decode(trim($queryBody, " '\r\t\n"));
177177
$this->queries[$route][] = array_merge(
178178
[
179179
'body' => $body !== null ? json_encode($body, JSON_PRETTY_PRINT) : '',

Tests/Functional/Profiler/ElasticsearchProfilerTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use ONGR\ElasticsearchBundle\Profiler\ElasticsearchProfiler;
1515
use ONGR\ElasticsearchBundle\Tests\app\fixture\Acme\BarBundle\Document\Product;
16+
use ONGR\ElasticsearchDSL\Aggregation\GlobalAggregation;
17+
use ONGR\ElasticsearchDSL\Query\MatchAllQuery;
1618
use ONGR\ElasticsearchDSL\Query\TermQuery;
1719
use ONGR\ElasticsearchBundle\Service\Repository;
1820
use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase;
@@ -161,4 +163,22 @@ private function getCollector()
161163

162164
return $collector;
163165
}
166+
167+
public function testMatchAllQuery()
168+
{
169+
$manager = $this->getManager();
170+
171+
$repository = $manager->getRepository('AcmeBarBundle:Product');
172+
$search = $repository
173+
->createSearch()
174+
->addAggregation(new GlobalAggregation('g'));
175+
$repository->execute($search);
176+
177+
$queries = $this->getCollector()->getQueries();
178+
$lastQuery = end($queries[ElasticsearchProfiler::UNDEFINED_ROUTE]);
179+
$this->checkQueryParameters($lastQuery);
180+
$lastQuery['body'] = trim(preg_replace('/\s+/', '', $lastQuery['body']));
181+
182+
$this->assertEquals('{"aggregations":{"g":{"global":{}}}}', $lastQuery['body']);
183+
}
164184
}

0 commit comments

Comments
 (0)