- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
<?php
// $Id$
class TriggerContentTestCase extends DrupalWebTestCase {
var $_cleanup_roles = array();
var $_cleanup_users = array();
2009-03-31 01:49:55 +00:00
public static function getInfo() {
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Trigger content (node) actions',
'description' => 'Perform various tests with content actions.' ,
'group' => 'Trigger',
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
);
}
function setUp() {
parent::setUp('trigger');
}
/**
* Various tests, all in one function to assure they happen in the right order.
*/
function testActionsContent() {
global $user;
$content_actions = array('node_publish_action', 'node_unpublish_action', 'node_make_sticky_action', 'node_make_unsticky_action', 'node_promote_action', 'node_unpromote_action');
foreach ($content_actions as $action) {
$hash = md5($action);
$info = $this->actionInfo($action);
// Test 1: Assign an action to a trigger, then pull the trigger, and make sure the actions fire.
$test_user = $this->drupalCreateUser(array('administer actions'));
$this->drupalLogin($test_user);
$edit = array('aid' => $hash);
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Create an unpublished node.
$web_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer nodes'));
$this->drupalLogin($web_user);
$edit = array();
2009-06-12 08:39:40 +00:00
$edit['title'] = '!SimpleTest test node! ' . $this->randomName(10);
2009-08-22 00:58:55 +00:00
$langcode = FIELD_LANGUAGE_NONE;
$edit["body[$langcode][0][value]"] = '!SimpleTest test body! ' . $this->randomName(32) . ' ' . $this->randomName(32);
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$edit[$info['property']] = !$info['expected'];
$this->drupalPost('node/add/page', $edit, t('Save'));
// Make sure the text we want appears.
2009-05-24 17:39:35 +00:00
$this->assertRaw(t('!post %title has been created.', array('!post' => 'Page', '%title' => $edit['title'])), t('Make sure the page has actually been created'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
// Action should have been fired.
2008-12-05 22:18:46 +00:00
$loaded_node = $this->drupalGetNodeByTitle($edit['title']);;
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertTrue($loaded_node->$info['property'] == $info['expected'], t('Make sure the @action action fired.', array('@action' => $info['name'])));
// Leave action assigned for next test
// Test 2: There should be an error when the action is assigned to the trigger twice.
$test_user = $this->drupalCreateUser(array('administer actions'));
$this->drupalLogin($test_user);
$edit = array('aid' => $hash);
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$edit = array('aid' => $hash);
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/trigger/node', $edit, t('Assign'));
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertRaw(t('The action you chose is already assigned to that trigger.'), t('Check to make sure an error occurs when assigning an action to a trigger twice.'));
// Test 3: The action should be able to be unassigned from a trigger.
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/trigger/unassign/node/presave/' . $hash, array(), t('Unassign'));
2008-06-02 17:39:12 +00:00
$this->assertRaw(t('Action %action has been unassigned.', array('%action' => ucfirst($info['name']))), t('Check to make sure the @action action can be unassigned from the trigger.', array('@action' => $info['name'])));
2009-07-28 19:18:08 +00:00
$assigned = db_query("SELECT COUNT(*) FROM {trigger_assignments} WHERE aid IN (:keys)", array(':keys' => $content_actions))->fetchField();
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
$this->assertFalse($assigned, t('Check to make sure unassign worked properly at the database level.'));
}
}
/**
* Helper function for testActionsContent(): returns some info about each of the content actions.
*
* @param $action
* The name of the action to return info about.
* @return
* An associative array of info about the action.
*/
function actionInfo($action) {
$info = array(
'node_publish_action' => array(
'property' => 'status',
'expected' => 1,
'name' => t('publish post'),
),
'node_unpublish_action' => array(
'property' => 'status',
'expected' => 0,
'name' => t('unpublish post'),
),
'node_make_sticky_action' => array(
'property' => 'sticky',
'expected' => 1,
'name' => t('make post sticky'),
),
'node_make_unsticky_action' => array(
'property' => 'sticky',
'expected' => 0,
'name' => t('make post unsticky'),
),
'node_promote_action' => array(
'property' => 'promote',
'expected' => 1,
'name' => t('promote post to front page'),
),
'node_unpromote_action' => array(
'property' => 'promote',
'expected' => 0,
'name' => t('remove post from front page'),
),
);
return $info[$action];
}
2008-12-05 22:18:46 +00:00
}
2009-05-27 16:29:05 +00:00
/**
* Test cron trigger.
*/
class TriggerCronTestCase extends DrupalWebTestCase {
2009-05-27 18:07:28 +00:00
public static function getInfo() {
2009-05-27 16:29:05 +00:00
return array(
2009-07-13 21:51:42 +00:00
'name' => 'Trigger cron (system) actions',
'description' => 'Perform various tests with cron trigger.' ,
'group' => 'Trigger',
2009-05-27 16:29:05 +00:00
);
}
function setUp() {
parent::setUp('trigger', 'trigger_test');
}
/**
2009-05-31 03:12:19 +00:00
* Test assigning multiple actions to the cron trigger.
*
* This test ensures that both simple and multiple complex actions
* succeed properly. This is done in the cron trigger test because
* cron allows passing multiple actions in at once.
2009-05-27 16:29:05 +00:00
*/
function testActionsCron() {
2009-05-31 03:12:19 +00:00
// Create an administrative user.
2009-05-27 16:29:05 +00:00
$test_user = $this->drupalCreateUser(array('administer actions'));
$this->drupalLogin($test_user);
2009-05-31 03:12:19 +00:00
// Assign a non-configurable action to the cron run trigger.
$edit = array('aid' => md5('trigger_test_system_cron_action'));
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/trigger/cron', $edit, t('Assign'));
2009-05-31 03:12:19 +00:00
// Assign a configurable action to the cron trigger.
$hash = md5('trigger_test_system_cron_conf_action');
$action_description = $this->randomName();
$edit = array(
'actions_description' => $action_description,
'subject' => $action_description,
);
$this->drupalPost('admin/settings/actions/configure/' . $hash, $edit, t('Save'));
$edit = array('aid' => md5('1'));
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/trigger/cron', $edit, t('Assign'));
2009-05-31 03:12:19 +00:00
// Add a second configurable action to the cron trigger.
$action_description = $this->randomName();
$edit = array(
'actions_description' => $action_description,
'subject' => $action_description,
);
$this->drupalPost('admin/settings/actions/configure/' . $hash, $edit, t('Save'));
$edit = array('aid' => md5('2'));
2009-07-20 18:51:36 +00:00
$this->drupalPost('admin/structure/trigger/cron', $edit, t('Assign'));
2009-05-31 03:12:19 +00:00
2009-05-27 16:29:05 +00:00
// Force a cron run.
drupal_cron_run();
2009-05-31 03:12:19 +00:00
// Make sure the non-configurable action has fired.
2009-05-27 16:29:05 +00:00
$action_run = variable_get('trigger_test_system_cron_action', FALSE);
$this->assertTrue($action_run, t('Check that the cron run triggered the test action.'));
2009-05-31 03:12:19 +00:00
// Make sure that both configurable actions have fired.
$action_run = variable_get('trigger_test_system_cron_conf_action', 0) == 2;
$this->assertTrue($action_run, t('Check that the cron run triggered both complex actions.'));
2009-05-27 16:29:05 +00:00
}
}