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.
In EntityTranslationTestCase
there is a drupal_static_reset('locale_url_outbound_alter');
, this means in any subsequent drupalGet()
/drupalPost()
calls to the sandbox, locale_language_url_rewrite_url()
will prepend to the requested URL the prefix from the host system (ie. $language_url->prefix
).
This as the $language_url
global has not been reset and still contains the language object from the URL on the host system, instead of that of the sandbox.
Examples:
- Tests are run from
en/admin/config/development/testing
and configured prefix for english is 'en' on the host system =>drupalGet('node/add/page')
does a call toen/node/add/page
=> unexpected 404 ensues as english doesn't have a prefix on the sandbox system. - Tests are run from
nl/admin/config/development/testing
, configured prefix for Dutch is 'nl' on the host system =>drupalGet('node/add/page')
does a call tonl/node/add/page
=> unexpected 404 ensues as there is no language with anl
prefix enabled on the sandbox system.
Comment | File | Size | Author |
---|---|---|---|
#8 | entity_translation-2284727-brokentest-8.patch | 426 bytes | stefan.r |
#6 | entity_translation-2284727-brokentest-6.patch | 517 bytes | stefan.r |
#2 | entity_translation-2284727-brokentest-1.patch | 425 bytes | stefan.r |
Comments
Comment #1
stefan.r CreditAttribution: stefan.r commentedComment #2
stefan.r CreditAttribution: stefan.r commentedReloading the
$language_url
global with adrupal_language_initialize()
fixes things :)Comment #3
stefan.r CreditAttribution: stefan.r commentedComment #4
stefan.r CreditAttribution: stefan.r commentedComment #6
stefan.r CreditAttribution: stefan.r commentedComment #8
stefan.r CreditAttribution: stefan.r commentedComment #9
stefan.r CreditAttribution: stefan.r commented.
Comment #10
stefan.r CreditAttribution: stefan.r commentedHad accidently edited this issue instead of posting a new one...
Comment #11
Stevel CreditAttribution: Stevel commentedI believe this problem occurs in more modules than just Entity Translation. I submitted a patch for drupal core to fix this in a more general way: #2724773: Translation tests fail on site with english language prefix (global $language_url is not reset in tests).
Comment #12
Stevel CreditAttribution: Stevel commentedThis should be working properly now, since $language_url is now reset during testing.
Comment #13
plachThanks!