Skip to content

Commit 9fc2d25

Browse files
authored
Fix testCreateTableIndexWithWhere to look up the query by content (#1085)
The test was hardcoding queries[2] to find the CREATE UNIQUE INDEX output. The dryrun message buffer now contains additional phinxlog setup messages before the create-index call, so the position drifted and the test failed locally. Look the query up by its expected prefix instead, which makes the test robust to ordering changes around it.
1 parent 0ed971d commit 9fc2d25

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎tests/TestCase/Db/Adapter/SqliteAdapterTest.php‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,13 @@ public function testCreateTableIndexWithWhere(): void
378378
->addIndex($index)
379379
->save();
380380
$queries = $this->out->messages();
381-
$indexQuery = $queries[2];
381+
$indexQuery = '';
382+
foreach ($queries as $query) {
383+
if (str_contains($query, 'CREATE UNIQUE INDEX "table1_email_index"')) {
384+
$indexQuery = $query;
385+
break;
386+
}
387+
}
382388
$this->assertStringContainsString('CREATE UNIQUE INDEX "table1_email_index"', $indexQuery);
383389
$this->assertStringContainsString('("email" ASC) WHERE is_verified = true', $indexQuery);
384390
}

0 commit comments

Comments
 (0)