Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
for ($i = 0; $i < 3; $i++) {
$language = new Language();
$language->id = $this->randomName(2);
$language->weight = -$i;
language_save($language);
}
If this generates a language id of 'en' or 'En' or 'eN' then this is going to fail!
* Drupal\language\Tests\LanguageFallbackTest (2 pass(es), 1 fail(s), and 1 exception(s))
- [fail] [Completion check] "The test did not complete due to a fatal error." in LanguageFallbackTest.php on line 43 of Drupal\language\Tests\LanguageFallbackTest->testCandidates().
- [exception] [Notice] "Undefined index: language.entity.eNDrupal\Core\Config\ConfigFactory->get('language.entity.eN')
Drupal\Core\Config\Entity\ConfigEntityStorage->has('eN', Object)
Drupal\Core\Entity\EntityStorageBase->save(Object)
Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object)
Drupal\Core\Entity\Entity->save()
language_save(Object)
Drupal\language\Tests\LanguageFallbackTest->setUp()
Drupal\simpletest\TestBase->run()
simpletest_script_run_one_test('451', 'Drupal\language\Tests\LanguageFallbackTest')
" in ConfigFactory.php on line 107 of Drupal\Core\Config\ConfigFactory->get().
Comment | File | Size | Author |
---|---|---|---|
#1 | 2291777.1.patch | 759 bytes | alexpott |
Comments
Comment #1
alexpottComment #2
martin107 CreditAttribution: martin107 commentedMakes perfect sense ... in this instance constrained random name generation is the only safe way.
Especially as it fits a similar pattern already in core.
see Drupal\language\Tests\LanguageConfigurationElementTest.
Comment #3
tstoecklerComment #5
catchCommitted/pushed to 8.x, thanks!