Skip to content

Commit 94480d8

Browse files
committed
tests: add runtime helper API coverage across sphinx2 and manticore
1 parent 6ca6877 commit 94480d8

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

‎tests/SphinxQL/HelperTest.php‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ public function testCreateFunction()
181181
$this->conn->query('SELECT MY_UDF()')->getStored()
182182
);
183183
$this->createHelper()->dropFunction('my_udf')->execute();
184+
185+
$this->expectException(Foolz\SphinxQL\Exception\DatabaseException::class);
186+
$this->conn->query('SELECT MY_UDF()');
184187
}
185188

186189
/**
@@ -245,4 +248,50 @@ public function testMiscellaneous()
245248
$query = $this->createHelper()->flushRamchunk('rt');
246249
$this->assertEquals('FLUSH RAMCHUNK rt', $query->compile()->getCompiled());
247250
}
251+
252+
public function testShowWarningsAndStatusExecution()
253+
{
254+
$warnings = $this->createHelper()->showWarnings()->execute()->getStored();
255+
if (is_int($warnings)) {
256+
$this->assertGreaterThanOrEqual(0, $warnings);
257+
} else {
258+
$this->assertIsArray($warnings);
259+
}
260+
261+
$status = $this->createHelper()->showStatus()->execute()->getStored();
262+
$this->assertNotEmpty($status);
263+
$this->assertArrayHasKey('Value', $status[0]);
264+
}
265+
266+
public function testShowIndexStatusExecution()
267+
{
268+
$statusRows = $this->createHelper()->showIndexStatus('rt')->execute()->getStored();
269+
$this->assertNotEmpty($statusRows);
270+
271+
$found = false;
272+
foreach ($statusRows as $row) {
273+
if (($row['Variable_name'] ?? null) === 'index_type') {
274+
$found = true;
275+
$this->assertSame('rt', (string) ($row['Value'] ?? ''));
276+
break;
277+
}
278+
}
279+
280+
$this->assertTrue($found);
281+
}
282+
283+
public function testFlushAndOptimizeExecution()
284+
{
285+
$result = $this->createHelper()->flushRamchunk('rt')->execute()->getStored();
286+
$this->assertIsInt($result);
287+
$this->assertGreaterThanOrEqual(0, $result);
288+
289+
$result = $this->createHelper()->flushRtIndex('rt')->execute()->getStored();
290+
$this->assertIsInt($result);
291+
$this->assertGreaterThanOrEqual(0, $result);
292+
293+
$result = $this->createHelper()->optimizeIndex('rt')->execute()->getStored();
294+
$this->assertIsInt($result);
295+
$this->assertGreaterThanOrEqual(0, $result);
296+
}
248297
}

0 commit comments

Comments
 (0)