Error testing code from Simpletest Tutorial (mymodule.test) in Drupal 7 HEAD

Created on 4 September 2009, over 15 years ago
Updated 19 March 2025, 19 days ago

Running test from http://drupal.org/node/395012 (I downloaded mymodule.drupal7.tgz) against Drupal 7 HEAD gave me this error:

An error has occurred.
Please continue to the error page
An error occurred.
Path: drupal/batch?id=4&op=do
Message:
Fatal error: Unsupported operand types in D:\www\drupal\modules\simpletest\drupal_web_test_case.php on line 733

I took a look at node.test and it turns out we need language as array key in Drupal 7. For example in create testMymoduleCreate what was:

    $edit = array(
      'title' => $this->randomName(32),
      'body[0][value]' => $this->randomName(64),
    );

should be something like:

    $langcode = FIELD_LANGUAGE_NONE;
    $edit = array(
      'title' => $this->randomName(32),
      "body[$langcode][0][value]" => $this->randomName(64),
    );

After this change test went trough as it should.

Miki

🐛 Bug report
Status

Closed: outdated

Component

Correction/Clarification

Created by

🇷🇸Serbia mikispeed

Live updates comments and jobs are added and updated live.
  • testing

    Used for Documentation issues related to testing and test development

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024