|
15 | 15 | use ONGR\App\Entity\DummyDocumentInTheEntityDirectory; |
16 | 16 | use ONGR\ElasticsearchBundle\Result\DocumentIterator; |
17 | 17 | use ONGR\ElasticsearchBundle\Test\AbstractElasticsearchTestCase; |
| 18 | +use ONGR\ElasticsearchDSL\Query\FullText\SimpleQueryStringQuery; |
18 | 19 |
|
19 | 20 | /** |
20 | 21 | * Functional tests for orm manager. |
@@ -120,4 +121,37 @@ public function testIndexConfigOverride() |
120 | 121 |
|
121 | 122 | $this->assertEquals(['localhost:9200'], $hosts); |
122 | 123 | } |
| 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 | + } |
123 | 157 | } |
0 commit comments