Skip to content

Commit 859a612

Browse files
committed
Adjust index datastore alter test
1 parent 4da4675 commit 859a612

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

modules/datastore/tests/src/Unit/DataDictionary/AlterTableQuery/MySQLQueryTest.php

+27-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public function testExecute(): void {
122122
$this->assertEquals("ALTER TABLE {" . $table . "} MODIFY COLUMN foo TEXT COMMENT 'Foo', " .
123123
"MODIFY COLUMN bar DECIMAL(10, 5) COMMENT 'Bar', " .
124124
"MODIFY COLUMN baz DATE COMMENT 'Baz', " .
125-
"ADD INDEX index1 (foo (12), bar, baz) COMMENT 'Fizz', " .
126-
"ADD FULLTEXT INDEX index2 (foo (6), baz) COMMENT '';", $query);
125+
"ADD INDEX index1 (foo (12), bar, baz) COMMENT 'Fizz';", $query);
127126
}
128127

129128

@@ -141,6 +140,32 @@ public function testExecuteWithTooLargeDecimal(): void {
141140
$mysql_query->execute();
142141
}
143142

143+
public functon testFulltextIndexes(): void {
144+
$connection_chain = $this->buildConnectionChain();
145+
$table = 'datastore_' . uniqid();
146+
$mysql_query = $this->buildMySQLQuery($connection_chain->getMock(), $table);
147+
148+
// Extract return value and generate queries for validation.
149+
$return = $mysql_query->execute();
150+
$update_query = \Drupal::state()->get('update_query');
151+
$query = $connection_chain->getStoredInput('prepare')[0];
152+
153+
// Validate return value and generated queries.
154+
$this->assertNull($return);
155+
$this->assertEquals([
156+
'field' => 'baz',
157+
'expression' => 'STR_TO_DATE(baz, :date_format)',
158+
'arguments' => [
159+
':date_format' => ''
160+
],
161+
], $update_query);
162+
163+
$this->assertEquals("ALTER TABLE {" . $table . "} MODIFY COLUMN foo TEXT COMMENT 'Foo', " .
164+
"MODIFY COLUMN bar DECIMAL(10, 5) COMMENT 'Bar', " .
165+
"MODIFY COLUMN baz DATE COMMENT 'Baz', " .
166+
"ADD INDEX index1 (foo (12), bar, baz) COMMENT 'Fizz';", $query);
167+
}
168+
144169
public function baseTypeProvider() {
145170
return [
146171
'string' => ['string', 'TEXT'],

0 commit comments

Comments
 (0)