Make sqlite-specific test more robust

This commit is contained in:
Timothy Warren 2020-04-17 14:58:42 -04:00
parent c67fabd1f7
commit 2821a2d4e1

View File

@ -47,51 +47,12 @@ use Query\Tests\BaseQueryBuilderTest;
->get('create_test', 2, 1); ->get('create_test', 2, 1);
$res = $query->fetchAll(PDO::FETCH_ASSOC); $res = $query->fetchAll(PDO::FETCH_ASSOC);
$actualDetail = $res[0]['detail'];
$this->assertTrue(is_string($actualDetail));
$expectedPossibilities = []; $expectedPossibilities = [
'TABLE create_test USING PRIMARY KEY',
$expectedPossibilities[] = [ 'SEARCH TABLE create_test USING INTEGER PRIMARY KEY (rowid>? AND rowid<?)',
[
'order' => '0',
'from' => '0',
'detail' => 'TABLE create_test USING PRIMARY KEY',
]
];
$expectedPossibilities[] = [
[
'selectid' => '0',
'order' => '0',
'from' => '0',
'detail' => 'SEARCH TABLE create_test USING INTEGER PRIMARY KEY (rowid>? AND rowid<?) (~60000 rows)',
],
];
$expectedPossibilities[] = [
[
'selectid' => '0',
'order' => '0',
'from' => '0',
'detail' => 'SEARCH TABLE create_test USING INTEGER PRIMARY KEY (rowid>? AND rowid<?)',
],
];
$expectedPossibilities[] = [
[
'selectid' => '0',
'order' => '0',
'from' => '0',
'detail' => 'SEARCH TABLE create_test USING INTEGER PRIMARY KEY (rowid>? AND rowid<?) (~62500 rows)',
],
];
$expectedPossibilities[] = [
[
'id' => '6',
'parent' => '0',
'notused' => '0',
'detail' => 'SEARCH TABLE create_test USING INTEGER PRIMARY KEY (rowid>? AND rowid<?)',
],
]; ];
$passed = FALSE; $passed = FALSE;
@ -99,9 +60,8 @@ use Query\Tests\BaseQueryBuilderTest;
// Check for a matching possibility // Check for a matching possibility
foreach($expectedPossibilities as $ep) foreach($expectedPossibilities as $ep)
{ {
if ($res === $ep) if (stripos($actualDetail, $ep) !== FALSE)
{ {
$this->assertTrue(TRUE);
$passed = TRUE; $passed = TRUE;
} }
} }
@ -110,8 +70,9 @@ use Query\Tests\BaseQueryBuilderTest;
if ( ! $passed) if ( ! $passed)
{ {
var_export($res); var_export($res);
$this->assertTrue(FALSE);
} }
$this->assertTrue($passed);
} }
public function testInsertReturning(): void public function testInsertReturning(): void