Port Simpletest to 5.x

andremolnar - March 17, 2007 - 17:57
Project:SimpleTest
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:critical
Assigned:Souvent22
Status:closed
Description

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

AttachmentSize
simpletest_1.patch4.37 KB

#1

coupet - March 18, 2007 - 00:24

great! we need this.

#2

andremolnar - March 18, 2007 - 17:15

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

AttachmentSize
simpletest_2.patch7.71 KB

#3

Thomas Ilsche - March 19, 2007 - 16:21
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.

#4

Thomas Ilsche - March 20, 2007 - 16:41

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)

AttachmentSize
simpletest_0.patch3.77 KB

#5

Thomas Ilsche - March 20, 2007 - 16:43

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

#6

andremolnar - March 23, 2007 - 04:38

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

#7

andremolnar - March 23, 2007 - 04:49

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

#8

Thomas Ilsche - March 24, 2007 - 21:20

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

#9

mfb - May 1, 2007 - 00:31

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..

#10

Rok Žlender - June 1, 2007 - 13:16

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.

AttachmentSize
simpletest_3.patch12.07 KB

#11

hadsie - June 14, 2007 - 21:38

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.

#12

hadsie - June 14, 2007 - 22:03

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.

#13

Souvent22 - June 21, 2007 - 19:29
Priority:normal» critical
Assigned to:Anonymous» Souvent22

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.

AttachmentSize
simpletest_drupal5.patch16.61 KB

#14

Souvent22 - June 21, 2007 - 19:38

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

#15

Souvent22 - June 21, 2007 - 19:50

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

#16

Rok Žlender - June 22, 2007 - 09:43

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.

#17

moshe weitzman - June 22, 2007 - 14:36

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

#18

Souvent22 - June 22, 2007 - 19:39

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).

AttachmentSize
simpletest_drupal5_0.patch30.02 KB

#19

Souvent22 - June 22, 2007 - 20:05

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

AttachmentSize
simpletest_drupal5_1.patch30.07 KB

#20

Rok Žlender - June 23, 2007 - 10:16

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.

#21

Souvent22 - June 23, 2007 - 13:03

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?

#22

Souvent22 - June 23, 2007 - 13:23

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.

#23

Rok Žlender - June 24, 2007 - 08:13

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

AttachmentSize
simpletest.d5.patch1.63 KB

#24

Rok Žlender - June 24, 2007 - 08:15

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.

AttachmentSize
upload_tests.patch6.52 KB

#25

Souvent22 - June 24, 2007 - 13:29

Upload patch attached, should fix it, all green

AttachmentSize
simpletest_drupal5_2.patch8.59 KB

#26

Rok Žlender - June 25, 2007 - 07:45
Status:patch (code 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.

#27

moshe weitzman - June 25, 2007 - 13:52

tagged, and release node created.

#28

Anonymous - July 9, 2007 - 14:17
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.