Download & Extend

Simpletest links in translated site get corrupted

Project:SimpleTest
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Issue tags:locale

Issue Summary

hi,

i have the following code simpletest code snippet:

   
    //my site is multilingual, base = english, additional = german
    $this->drupalGet('apartments/vienna/test'); //opens a german-only node
    $this->clickLink(t('Send Request'));

this will open a link to http://example.com/de/de/xyz

the clicked link is generated via

l(t('Send Request'), 'xyz);

i don't really get, why this happens. any hints would be very appreciated!

thanks josef

Comments

#1

Status:active» postponed (maintainer needs more info)

I am not clear on what is going on, could you attempt to clarify the issue. Sorry, if I am missing something obvious.

Thanks.

#2

hi,

well as i explain above, i run a test on a multilingual site.

when executing clickLink within the test, it will open a corrupted URL, having the language-code double as "http://example.com/de/de/xyz".

outside the test, the clicked links work without any problem, so i guess that simpletest somehow causes the language system to inject the language code twice!?

i know this is hard to debug, but i really would like to see if this can be fixed...

thanks josef

#3

the same happens to me with this->drupalPost :(
any help would be appreciated

#4

Version:6.x-2.9» 6.x-2.11

#5

Status:postponed (maintainer needs more info)» active

#6

Project:SimpleTest» Internationalization
Version:6.x-2.11» 6.x-1.7

the problem seems to happen with the "path prefix with language fallback" option only

steps to reproduce:

* install drupal 6 + cck + i18n
* enable content + content translation + simpletest
* activate translation for page content type
* languages - add german, language negociation is "path prefix with language fallback"
* activate translation for page content type
* add "my page" in english and translate it to "meine seite" in german (node/2 and node/3 in my case)
* execute the following simpletest

<?php
class SimpleTestTest extends DrupalWebTestCase {

  public static function
getInfo() {
    return array(
     
'name' => 'SimpleTest i18n test',
     
'description' => '...',
     
'group' => 'SimpleTestTest',
    );
  }

   
//use live db
 
function setUp() {
   
$this->originalPrefix = $GLOBALS['db_prefix'];
  }
  function
tearDown() { }

  function
testLinks() {
   
$this->drupalGet('node/1');
   
$this->clickLink('Deutsch');
  }

}
?>

so here are the simpletest results:

GET http://worktest2/en/node/1 returned 200 (4.55 KB). Browser simpletest_test.test 20 SimpleTestTest->testLinks()
Valid HTML found on "http://worktest2/en/node/1" Browser simpletest_test.test 20 SimpleTestTest->testLinks()
$this->drupalGet('node/1'); worked, ok, but then...

Clicked link "Deutsch" (http://worktest2/en/de/node/2) from http://worktest2/en/node/1 Browser simpletest_test.test 21 SimpleTestTest->testLinks()
GET http://worktest2/en/de/node/2 returned 404 (2.71 KB). Browser simpletest_test.test 21 SimpleTestTest->testLinks()
Valid HTML found on "http://worktest2/en/de/node/2" Browser simpletest_test.test 21 SimpleTestTest->testLinks()
we see that with $this->clickLink('Deutsch'); wrong url is generated. after the domain name worktest, we have "/en/de/node/2" which means, that there is both an english + a german language code. therefore we encounter a 404 error and the test fails...

with language negotiation set to "none", the test will just work:

GET http://worktest2/node/1 returned 200 (4.53 KB). Browser simpletest_test.test 20 SimpleTestTest->testLinks()
Valid HTML found on "http://worktest2/node/1" Browser simpletest_test.test 20 SimpleTestTest->testLinks()
Clicked link "Deutsch" (http://worktest2/node/2) from http://worktest2/node/1 Browser simpletest_test.test 21 SimpleTestTest->testLinks()
GET http://worktest2/node/2 returned 200 (4.54 KB). Browser simpletest_test.test 21 SimpleTestTest->testLinks()
Valid HTML found on "http://worktest2/node/2" Browser simpletest_test.test 21 SimpleTestTest->testLinks()
Clicked link "English" (http://worktest2/node/1) from http://worktest2/node/2 Browser simpletest_test.test 22 SimpleTestTest->testLinks()
GET http://worktest2/node/1 returned 200 (4.53 KB). Browser simpletest_test.test 22 SimpleTestTest->testLinks()
Valid HTML found on "http://worktest2/node/1" Browser simpletest_test.test 22 SimpleTestTest->testLinks()




assigning this to the i18n queue now.
if you could provide me a hint how to avoid this issue, i would like to submit a patch

#7

Title:Links in translated site get corrupted » Simpletest links in translated site get corrupted

#8

Category:bug report» support request

debugging this->drupalLogin(...);

in drupal_web_test_case.php
...
$path = "/en/user";
call getAbsoluteUrl($path);
...
$path = url($path, $options);

now, $path is "/en/en/user"

not sure yet, how to avoid this?

#9

Project:Internationalization» SimpleTest
Version:6.x-1.7» 6.x-2.x-dev
Status:active» needs review

boombatower told me, that this problem is caused by simpletests url handling / the browser it uses.

the http://drupal.org/project/browser should help us overcome this for the future (incomplete d7 draft exists at the moment)

in order to address my specific issue with the language code being put twice in the url i wrote the following patch

AttachmentSizeStatusTest resultOperations
simpletest_url_locale.patch1008 bytesIdlePASSED: [[SimpleTest]]: [MySQL] 158 pass(es).View details | Re-test

#10

Category:support request» bug report
Status:needs review» needs work

+++ drupal_web_test_case.php 10 Nov 2010 00:32:15 -0000
@@ -1882,6 +1882,14 @@ class DrupalWebTestCase extends DrupalTe
+      if(substr($path, 0 , 3) == $language->language . "/") {
+      $path = substr($path, 3);
+      }

we use spaces instead of tabs

Powered by Dreditor.

#11

yeah tanks, hope this one's better :)

AttachmentSizeStatusTest resultOperations
simpletest_url_locale2.patch1.02 KBIdlePASSED: [[SimpleTest]]: [MySQL] 158 pass(es).View details | Re-test

#12

Status:needs work» needs review

#13

Status:needs review» needs work

I think your problem here is in your test case, the function tearDown() needs to call parent::tearDown().

#14

Status:needs work» needs review

@dave reid: thanks for the hint for teatDown(), but this doesn't affect the issue / the behaviour of links being executed within the test.

nobody click here