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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boombatower’s picture

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.

dasjo’s picture

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

dasjo’s picture

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

dasjo’s picture

Version: 6.x-2.9 » 6.x-2.11
dasjo’s picture

Status: Postponed (maintainer needs more info) » Active
dasjo’s picture

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

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

dasjo’s picture

Title: Links in translated site get corrupted » Simpletest links in translated site get corrupted
dasjo’s picture

Category: bug » support

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?

dasjo’s picture

Project: Internationalization » SimpleTest
Version: 6.x-1.7 » 6.x-2.x-dev
Status: Active » Needs review
Issue tags: +locale
FileSize
1008 bytes

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

klausi’s picture

Category: support » bug
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.

dasjo’s picture

yeah tanks, hope this one's better :)

dasjo’s picture

Status: Needs work » Needs review
Dave Reid’s picture

Status: Needs review » Needs work

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

dasjo’s picture

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.

kenorb’s picture

Status: Needs review » Reviewed & tested by the community

Tested and it works.

There is also the case, when links to the files are wrong, like: /en/files/simpletest/verbose/Index-1.html
but probably it's a different issue.
I've reported it here: #1844500: Path to files are prefixed with 'en' (en/files)

These two were working correctly in the previous versions (before back-porting from D7)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 11: simpletest_url_locale2.patch, failed testing.

kenorb’s picture

Priority: Normal » Minor
Issue summary: View changes
Lendude’s picture

Status: Needs work » Closed (outdated)

This version is not supported anymore.