Skip to content
Snippets Groups Projects
Unverified Commit b4fb65d5 authored by Lucas Hedding's avatar Lucas Hedding
Browse files

combine test

parent 9f4ab939
No related branches found
No related tags found
1 merge request!6619#3106205 moved the system_update hook to 10202
...@@ -5,11 +5,8 @@ ...@@ -5,11 +5,8 @@
namespace Drupal\Tests\system\Functional\Update; namespace Drupal\Tests\system\Functional\Update;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\FunctionalTests\Update\UpdatePathTestBase; use Drupal\FunctionalTests\Update\UpdatePathTestBase;
// cspell:ignore mlid
/** /**
* Tests update of menu tree storage fields. * Tests update of menu tree storage fields.
* *
...@@ -38,29 +35,11 @@ protected function setUp(): void { ...@@ -38,29 +35,11 @@ protected function setUp(): void {
*/ */
protected function setDatabaseDumpFiles(): void { protected function setDatabaseDumpFiles(): void {
$this->databaseDumpFiles = [ $this->databaseDumpFiles = [
// Start with a bare install of Drupal 10.3.0. // Start with a bare installation of Drupal 10.3.0.
DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz', DRUPAL_ROOT . '/core/modules/system/tests/fixtures/update/drupal-10.3.0.bare.standard.php.gz',
]; ];
} }
/**
* Tests DB behavior in initial state.
*/
public function testSchemaLength(): void {
if (\Drupal::service('database')->databaseType() == 'sqlite') {
$this->markTestSkipped("This test does not support the SQLite database driver.");
}
$this->expectException(DatabaseExceptionWrapper::class);
$this->connection->update('menu_tree')
->fields([
'url' => $this->randomMachineName(300),
'route_param_key' => $this->randomMachineName(300),
])
->condition('mlid', 1)
->execute();
}
/** /**
* Tests DB behavior after update. * Tests DB behavior after update.
*/ */
...@@ -69,14 +48,25 @@ public function testSchemaLengthAfterUpdate(): void { ...@@ -69,14 +48,25 @@ public function testSchemaLengthAfterUpdate(): void {
$this->markTestSkipped("This test does not support the SQLite database driver."); $this->markTestSkipped("This test does not support the SQLite database driver.");
} }
$results = $this->connection->query('SELECT CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = :menu AND COLUMN_NAME IN ( :column_names[] )', [
':menu' => $this->connection->schema()->prefixNonTable('menu_tree'),
':column_names[]' => ['route_param_key', 'url']
])->fetchCol();
$this->assertNotEmpty($results);
foreach ($results as $result) {
self::assertEquals(255, $result);
}
$this->runUpdates(); $this->runUpdates();
$this->connection->update('menu_tree')
->fields([ $results = $this->connection->query('SELECT CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = :menu AND COLUMN_NAME IN ( :column_names[] )', [
'url' => $this->randomMachineName(300), ':menu' => $this->connection->schema()->prefixNonTable('menu_tree'),
'route_param_key' => $this->randomMachineName(300), ':column_names[]' => ['route_param_key', 'url']
]) ])->fetchCol();
->condition('mlid', 1) $this->assertNotEmpty($results);
->execute(); foreach ($results as $result) {
self::assertEquals(2048, $result);
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment