The main work for this task is to write a small suite of tests to check the basic functionality of Actions associated with changes to site content. This suite should be written as a single .test file.

Suggested tests:

1. admin/build/actions/assign/node Assign an action. Trigger the action and make sure it fires.
2. admin/build/actions/assign/node Attempt to assign the same action twice. Confirm error.
3. admin/build/actions/assign/node Remove an assigned action. Make sure it no longer fires.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

Title: GHOP : Write Simpletest tests for Actions for content » GHOP #112: Write Simpletest tests for Actions for content
cwgordon7’s picture

Assigned: Unassigned » cwgordon7
Status: Active » Needs review
FileSize
2.83 KB

File attached as a .txt. If anything fails it's because it's a critical Drupal core issue, not because anything's wrong with this file.

snufkin’s picture

using chx's patch from http://drupal.org/node/203509 and enabling trigger the test runs, without fail. Coding style looks good, strings in t().

Testing an error situation with reverting the patch mentioned above gives me a nice error, so does running it without trigger enabled, so it indeed functions well.

cwgordon7’s picture

FileSize
6.03 KB

Thanks for the review, pwolanin. Test rerolled.

pwolanin’s picture

note - in IRC I suggested writing the aid as md5(callback) for readability, testing all 6 actions, and comparing $node->status, etc to an int rather than a string.

pwolanin’s picture

Status: Needs review » Needs work

This code comment needs fixing:

// Set action id to "publish post".

Also, there is a random $i in various calls like:

 $node->body      = $this->randomName(32 + $i)
cwgordon7’s picture

Status: Needs work » Needs review
FileSize
6.01 KB

Thanks, test file rerolled.

pwolanin’s picture

Status: Needs review » Needs work

why $action rather than $this->actionName($action)? you shouldn't concat like that in t()
t('Check to make sure the "'. $action .'" action is fired.'));
look at your code below: t('Action %action has been unassigned.', array('%action' => $this->actionName($action)))

that's a better model

cwgordon7’s picture

FileSize
6.08 KB

Ok, rerolled. Except with @action.

pwolanin’s picture

      // Action should NOT work.
      $this->assertTrue(!$this->actionWorked($action, $node2)

why not:

     $this->assertFalse($this->actionWorked($action, $node2)
cwgordon7’s picture

Status: Needs work » Needs review
FileSize
6.09 KB

Ok, rerolled.

cwgordon7’s picture

FileSize
6.16 KB

Ok, rerolled (again).

cwgordon7’s picture

FileSize
3.57 KB

Ok, following our discussion on IRC, this patch is rerolled & shortened significantly.

pwolanin’s picture

There is something weird going on with trigger/actions when trying to sequentially run several sequentially. Also, we found this bug - need to patch to make this work on PHP4.4: http://drupal.org/node/203846

So - this issue demonstrates the value of this exercise - we turned up 2 core bugs! Thanks cwgordon7

cwgordon7’s picture

FileSize
3.47 KB

Rerolled

cwgordon7’s picture

FileSize
3.52 KB

Whoops. Rerolled.

kyl191’s picture

FileSize
3.09 KB

Hi,
took a look at the test, and everything seems fine - the test came back with 6 failures, but the failures don't look related to the test.
(Disclaimer: Not only am I a student who is taking part in GHOP, but I am also not an expert in simpletest. But the test still looks ok to me.)

The output of the test is attached if anyone's interested in it.

cwgordon7’s picture

Adding on to what kyl191 said: The tests kyl191 performed were without chx's patch, so failures were to be expected.

pwolanin’s picture

FileSize
648 bytes
731 bytes
689 bytes

some trivial patches that break the tests

pwolanin’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
3.95 KB

I did a quick fix on a couple of the error messages, and re-rolled this in patch form (diffed from the simpletest module directory). Looks good to me.

pwolanin’s picture

@cwgordon7: please post the final version to the GHOP queue

Rok Žlender’s picture

Status: Reviewed & tested by the community » Fixed

Committed thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

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