On request from chx based on http://code.google.com/p/google-highly-open-participation-drupal/issues/...

Drupal 6 supports content (node) translation out of the box with the included
content translation module. This task is to write unit tests to ensure this
functionality works.

The Simpletest module provides a framework for running automated unit
tests in Drupal. Unit testing involves taking a small portion of code, a
unit, and subjecting it to programmatic tests to prove its correctness.
This can be extremely useful to help insure that new code does not
introduce bugs into existing functionality. Thus, having a full suite of
unit tests for Drupal 6.x core functionality using the Simpletest module
would be a major step forward for the project and would help insure that
only high-quality code is committed. In addition to helping developers
test their code, new tests for core Drupal functionality will be used for
automated testing by http://testing.drupal.org.

For this task, you need to first install and familiarize yourself with the
simpletest module (use the cvs HEAD version with Drupal HEAD/6.x RC):
http://drupal.org/project/simpletest
http://drupal.org/simpletest
http://www.lullabot.com/articles/introduction-unit-testing

The main work for this task is to write a small suite of tests to check
the functionality of translation module with a test site setup to have at
least two languages and both locale and translation module enabled. The
test case should:
* set the Story content type to be multilanguage enabled with translation
* create a story in one of the languages
* submit a translation of the story in one of the other languages
* update the original story and mark the translation outdated
* update the translation and mark it as up-to-date

Proper validation of your new tests will ideally include changing the
Drupal core code to break the tested functionality and then confirming
that your tests report a failure. Ideally, post each such change as a
patch to help the reviewers.

This suite should be written as a single .test file and should achieve
RTBC status in the Simpletest module issue queue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Title: Write Simpletest tests for Content translation module » GHOP task #130: Write Simpletest tests for Content translation module
aclight’s picture

The official GHOP task related to this issue can be found at:
http://code.google.com/p/google-highly-open-participation-drupal/issues/...

webchick’s picture

Project: Google Highly Open Participation Contest (GHOP) » SimpleTest
Version: » 6.x-1.x-dev
Component: Task idea » Code

Moving to SimpleTest queue.

boombatower’s picture

Status: Active » Needs review
FileSize
4.76 KB
881 bytes

After having a few problems I was able to come up with a solution, in part thanks to figuring out what wasn't causing it with cwgordon7 in IRC. To complete my task I created a patch for the drupal_test_case.php file.

I believe the submission meets all the requirements, but I am not sure if there is a way to do it without the patch.

Rok Žlender’s picture

Status: Needs review » Needs work

As always you have produced a great test. My comments:

  • you can use $this->assertTrue(TRUE, "") to output a log msg, your way works too its just harder to read. I tested it and it worked.
  • On line 107 and 131 of your test file you complicate things a bit too much. You can simply do $this->assertTrue($node, 'Node found in database.'); if node is not found it will be set to false and this assertions will catch it
  • I'd like to see more assertions, after every drupalPostRequest drupal output some sort of notice please use $this->assertText() to see if that is really the case i.e. after creating node $this->assertText("Story $title has been created.") it is much easier to find errrors if there are more assertions and log msgs.

I've put your drupalGet change into its own issue so it doesn't get overlooked. I'll commit it together with your test when you fix ^^.

boombatower’s picture

Status: Needs work » Needs review
FileSize
5.72 KB

I believe I fixed everything you requested.

I didn't use $this->assertText() since I used the t() around the messages since they are core messages are translated depending on the environment. t() adds HTML so I used $this->assertWantedRaw().

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Some comments:

- code looks good
- there are some coding stye mistakes (dots and whitespace; comments should start with capital letters and end in a dot)
- "create store in english" :)
- after you edit the translation, let's check the translations tab and see whether it shows that the translation was marked outdated, this is quite important functionality to validate
- You use t() like t('The language %lang has been created and can now be used.', ...) but my quick grep did not show and such string in Drupal 6. I found t('The language %language has been created and can now be used. More information is available on the help screen.', ...) though. When you use t(), if you intend to actually get a translation, you should use the exact same string, or your test will fail unless it runs on an English interface. (Looks like your test does not make sure it runs on an English site, rightly so :) Note that I did not check all strings but this caught my attention.

boombatower’s picture

Status: Needs work » Needs review
FileSize
6.06 KB

I believe I fixed all the requested items.

  • Fixed comments.
  • Check that the translation was market as outdated.
  • Fixed partial interface text.

Just as a note the accompanying patch is located here: http://drupal.org/node/209297.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

There are still coding style issues in the test (just run coder module on it), but otherwise looks good to me on review. As far as I see, just fix the style issues and then get this RTBC.

boombatower’s picture

Status: Needs work » Needs review

I downloaded and ran the Coder module on my test case and it returned the following results.

No Problems Found

So I am not sure what I need to fix.

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Stuff like $this->drupalPostRequest('node/' . $node->nid . '/edit', $edit, 'Save'); is not comformant to our coding style, please use coder module's more sensitive checking (which is not enabled by default AFAIR).

boombatower’s picture

Status: Needs work » Needs review
FileSize
6.06 KB

I fixed the small appending dot style issues.

Gábor Hojtsy’s picture

I did not have the opportunity to test, but otherwise this all looks good to me now. Thanks for your work!

Rok Žlender’s picture

Committed. Thanks boombatower for your code and thanks Gabor for your reviews.

Rok Žlender’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.