Here is a patch to upgrade Simpletest to 5.x. Now makes use of 5.x version of FAPI.

Still TO DO:
work on Simpletest results to display inside of a themed page - currently being displayed on their own page.
Upgrade tests to actually test Drupal 5.x. Several tests still test only version 4.6 (testing old style forms).
place simpletest in appropriate place in the new administer menu structure.

These can be opened as seperate issues.
I'm also including one updated test that will pass on Drupal 5.x.

andre

Comments

coupet’s picture

great! we need this.

andremolnar’s picture

StatusFileSize
new7.71 KB

A little CVS mixup on my end. This to patch against head.
I have commented out the calls to DrupalReporter and defaulting back to the simpletest reporting since the drupal reporer isn't producing output at this point. This is certainly a 'to do' to have the report wrapped in a themed page.

Once again, upgrading the module to use Drupal 5.x FAPI and including two patched tests. Also including proper .info file.

andre

Thomas Ilsche’s picture

Version: 4.7.x-1.x-dev » 6.x-1.x-dev

I will try to get the drupal_reporter working again. However in the meantime for the HTMLReporter it is necesary to uncomment the " exit;" in function, otherwise it will fail to display output under certain buffering circumstances.

Thomas Ilsche’s picture

StatusFileSize
new3.77 KB

I have fixed simpletest.module to work with drupal_reporter again. Added default radio selection.

This is based on andres patch. I can also just commit it as initial 5.0 branch (if i can get to know how I do this with CVS)

Thomas Ilsche’s picture

P.S.: my last patch does not include info / tests, just simpletest.module

andremolnar’s picture

Thomas - couldn't apply your patch - but i applied by hand so i can test - your patch includes a call to an undefined function... simpletest_running_output($output); Was there supposed to be more to this patch?

andre

andremolnar’s picture

ugggg.... never mind - that's why you never patch by hand ;-) missed your added function...

Got this working Reporting looks better.

Though I might suggest the default test option is 'run selected tests' instead of 'all'.

I'm going to start using this as my base - and try to patch the test files as best I can.
andre

Thomas Ilsche’s picture

Sure, default option selected might be more useful. Change it at will :)

mfb’s picture

Hi, what's the current status of the simpletest module for drupal 5.x?
I was hoping to get it going and add some tests for some contrib modules..

Rok Žlender’s picture

StatusFileSize
new12.07 KB

Hi guys

I have joined all of the patches in this issue and added some of my code that fixes some tests. I still havent solved "[login] found name:" fail that happens in some test cases. Do any of you get this error?

I think after this problem is solved we can create a 5.0 release.

hadsie’s picture

I've been looking into the "[login] found name:" bug and I'm pretty sure it's cookie/session related.

One place I'm getting this error is when the page_creation.test calls the 'drupalLoginUser()' method. The page_view.test also calls drupalLoginUser() but doesn't fail. page_view has the line:

$html = $this->get(url("node/$node->nid/edit", NULL, NULL, TRUE));

If you follow this function, it sets up a connection and a cookie. There's nothing like this being done in page_creation prior to calling drupalLoginUser(). I tried hacking in some basic code that just sets up a cookie (using the simpletest code) and it seems to be working. But I'm definitely not doing this the Right Way.

Hopefully this helps a bit.

hadsie’s picture

To add to this... adding something like:

$this->setCookie('PHPSESSID', 'randomcookievalue');

Seems to make this error go away. I'm not really sure where to go from here though.

Souvent22’s picture

Assigned: Unassigned » Souvent22
Priority: Normal » Critical
StatusFileSize
new16.61 KB

Updated patch. Could we perhaps get a Drupal-5-dev branch since 6 is in development, would help make the trees a bit more clearer.

Souvent22’s picture

Note: This patch also adds/fixes the following:

- Uses assertText instead of assertWantedText as the latter is now deprecated
- Adds the "HTTP-Auth" setting which allows one to get HTTP-Auth settings incase their evnrioment is behind a simple http-auth
- Fixes a lot of the taxonomy nodeapi issues in the taxonomy nodeapi test
- Fixes the user login test as the assertion was wrong, thus always Failing

Souvent22’s picture

Sorry, almost forgot,
in the taxonomy nodeapi test, the user_access vars were totally wrong.
They were like "create stories", etc.
This patch changes them to: $perm = array('access content', 'create story content', 'edit story content');
As they should be for D5

Rok Žlender’s picture

I did a quick review of your patch:

- version in info files is no longer needed http://drupal.org/node/152819
- settings menu should get "Simpletest settings" title
- I don't understand why did you change assertion in drupalLoginUser function to assertEqual($user->name, $user->name as I see it this will always be true because you compare variable to it self. The way it was before it checked if user was successfully logged in by looking for user name on loaded page. There are some problems probably with simpletest internal browser as hadsie discovered in #10 and #11

OK so maybe it would be better to split this patch. One part would fix simpletest module core and the other tests. Also as Souvent22 suggested we should create D5 dev branch.

moshe weitzman’s picture

thanks for working on this, everyone ... we'll create a drupal-5 branch once ths patch lands and all tests are fixed.

Souvent22’s picture

StatusFileSize
new30.02 KB

ALL tests run green with this latest patch. there are a LARGE number of fixes in this patch, i shall biefley list them here:

- fixed drupalModuleEnable, was not rebuilding module cache
- all gets now run trhoguh drupalGet
- multi-select form items are now handled correctly, they were handled wrong before
- removed depricated functions (e.g. assertWatnedText is now assertText, etc.)
- removed bad information msg check

I believe after this patch, its brancahble to a 5.0 dev tree (still in dev though, not stable of course).

Souvent22’s picture

StatusFileSize
new30.07 KB

Updated patch. Does a check for edit_multi variable to fix a warning

Rok Žlender’s picture

I've commited patch #19 to HEAD great work Souvent22 especially with taxonomy tests.

I made some slight modifications.

  • some cleanup of empty lines and spaces
  • included changes in my comment #16
  • your solution to found name problem does not solve it just covers it up. When logging in we get Page not found in loginUser function this is not OK. The only solution I know so far is what Scott described in his comments.
    $this->setCookie('PHPSESSID', 'randomcookievalue'); if you put this in loginUser function in drupal_test_case it solves the problem.

I will not mark this as fixed until we find a solution to this problem.

Souvent22’s picture

ah, i forgot to bring my code over from another function to the drupalLoginFunction. i'll update that and patch. here's what i did in my payflow tests that i didn't port over:

    $this->drupalGet( url("user", NULL, NULL, TRUE) );
    // Going to the page retrieves the cookie, as the browser should save it

    if ($user === NULL) {
      $user = $this->drupalCreateUserRolePerm();
    }

    $edit = array('name' => $user->name, 'pass' => $user->pass_raw);
    $this->drupalPostRequest('user', $edit, 'Log in');

    $this->assertNoText(t('The username %name has been blocked.', array('%name' => $user->name)), ' [login] not blocked');
    $this->assertNoText(t('The name %name is a reserved username.', array('%name' => $user->name)), ' [login] not reserved');
    $this->drupalGet( url("user", NULL, NULL, TRUE));
    $this->assertText( $user->name, ' [login] found name: ' . $user->name);

    return $user;

Basically, after logging in, when we go to the /user page, the username will be displayed on the page, if it was a bad login, then the username will not be shown, thus failed. i think this is a valid solution. Thoughts?

Souvent22’s picture

Note: Also, i don't like the idea of arbitrarily setting the cookie, as this by-passes the drupal/php session/user interaction; we want to be sure that is working also, so i'd rather get the cookie/session_id from drupal or some other means rather than arbitrarily setting it.

Rok Žlender’s picture

StatusFileSize
new1.63 KB

OK I've committed fix to login problem. The patch I committed is attached. Now all tests are green.

Rok Žlender’s picture

StatusFileSize
new6.52 KB

One more thing.
Upload_tests.test used its own loginUser function this patch fixes this. I think when this one goes in we can branch to DRUPAL-5.

Souvent22’s picture

StatusFileSize
new8.59 KB

Upload patch attached, should fix it, all green

Rok Žlender’s picture

Status: Needs review » Fixed

Committed to HEAD.

Souvent22 your patch did not clean up all unneeded functions so I committed patch under #24

Moshe I think now its time to create a Drupal 5 branch.

moshe weitzman’s picture

tagged, and release node created.

Anonymous’s picture

Status: Fixed » Closed (fixed)