Posted by dasjo on October 17, 2010 at 1:09pm
4 followers
| 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
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
#5
#6
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()
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()
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
#8
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
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
#10
+++ 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 :)
#12
#13
I think your problem here is in your test case, the function tearDown() needs to call
parent::tearDown().#14
@dave reid: thanks for the hint for teatDown(), but this doesn't affect the issue / the behaviour of links being executed within the test.