Skip to content

Commit a9c9cad

Browse files
committed
Implemented some tests for the count
1 parent 2a958df commit a9c9cad

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Tests/Functional/Service/IndexServiceTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use ONGR\App\Entity\DummyDocumentInTheEntityDirectory;
1616
use ONGR\ElasticsearchBundle\Result\DocumentIterator;
1717
use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase;
18+
use ONGR\ElasticsearchDSL\Query\FullText\SimpleQueryStringQuery;
1819

1920
/**
2021
* Functional tests for orm manager.
@@ -120,4 +121,37 @@ public function testIndexConfigOverride()
120121

121122
$this->assertEquals(['localhost:9200'], $hosts);
122123
}
124+
125+
public function testCount()
126+
{
127+
$index = $this->getIndex(DummyDocument::class);
128+
129+
$search = $index->createSearch();
130+
$search->addQuery(new SimpleQueryStringQuery('foo'));
131+
132+
$count = $index->count($search);
133+
134+
$this->assertEquals(2, $count);
135+
}
136+
137+
public function testRawCount()
138+
{
139+
$index = $this->getIndex(DummyDocument::class);
140+
141+
$search = $index->createSearch();
142+
$search->addQuery(new SimpleQueryStringQuery('bar'));
143+
144+
$result = $index->count($search, [], true);
145+
146+
$this->assertEquals(1, $result['count']);
147+
}
148+
149+
public function testIndexDocumentCount()
150+
{
151+
$index = $this->getIndex(DummyDocument::class);
152+
153+
$count = $index->getIndexDocumentCount();
154+
155+
$this->assertEquals(3, $count);
156+
}
123157
}

0 commit comments

Comments
 (0)