- π©πͺGermany Anybody Porta Westfalica
Just ran into this at π The migration tests are currently not running Postponed
- πΊπ¦Ukraine pingwin4eg Zaporizhia πΊπ¦
I also encountered the "container was serialized" issue with a migration test in Style Switcher module with D 9.5.11, PHP 8.1, PHPUnits 8.5.31 (local) and 9.5.28 (DrupalCI):
1) Drupal\Tests\styleswitcher\Kernel\Migrate\d7\MigrateVariablesTest::testVariablesMigration PHPUnit\Framework\Exception: PHP Fatal error: Uncaught AssertionError: The container was serialized. in /var/www/html/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php:99 Stack trace: #0 /var/www/html/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php(99): assert(false, 'The container w...') #1 [internal function]: Drupal\Core\DependencyInjection\ContainerBuilder->__sleep() #2 Standard input code(89): serialize(Array) #3 Standard input code(123): __phpunit_run_isolated_test() #4 {main} thrown in /var/www/html/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php on line 99
When I switched PHP to 7.3 locally I saw the actual error:
1) Drupal\Tests\styleswitcher\Kernel\Migrate\d7\MigrateVariablesTest::testVariablesMigration PHPUnit\Framework\Exception: PHP Fatal error: Uncaught LogicException: The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in /app/core/lib/Drupal/Core/Database/Connection.php:2042 Stack trace: #0 [internal function]: Drupal\Core\Database\Connection->__sleep() #1 Standard input code(80): serialize(Array) #2 Standard input code(112): __phpunit_run_isolated_test() #3 {main} thrown in /app/core/lib/Drupal/Core/Database/Connection.php on line 2042
The workaround was to call
$this->startCollectingMessages();
before$this->executeMigrations(...)
.