- 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 BlockTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Block functionality'),
|
|
|
|
'description' => t('Add, edit and delete custom block. Configure and move a module-defined block.'),
|
|
|
|
'group' => t('Block'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of setUp().
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// Create and login user
|
|
|
|
$admin_user = $this->drupalCreateUser(array('administer blocks'));
|
|
|
|
$this->drupalLogin($admin_user);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test creating custom block (i.e. box), moving it to a specific region and then deleting it.
|
|
|
|
*/
|
|
|
|
function testBox() {
|
|
|
|
// Add a new box by filling out the input form on the admin/build/block/add page.
|
|
|
|
$box = array();
|
|
|
|
$box['info'] = $this->randomName(8);
|
|
|
|
$box['title'] = $this->randomName(8);
|
|
|
|
$box['body'] = $this->randomName(32);
|
|
|
|
$this->drupalPost('admin/build/block/add', $box, t('Save block'));
|
|
|
|
|
|
|
|
// Confirm that the box has been created, and then query the created bid.
|
|
|
|
$this->assertText(t('The block has been created.'), t('Box successfully created.'));
|
|
|
|
$bid = db_result(db_query("SELECT bid FROM {boxes} WHERE info = '%s'", array($box['info'])));
|
|
|
|
|
|
|
|
// Check to see if the box was created by checking that it's in the database..
|
|
|
|
$this->assertNotNull($bid, t('Box found in database'));
|
|
|
|
|
|
|
|
// Set the created box to a specific region.
|
|
|
|
// TODO: Implement full region checking.
|
|
|
|
$edit = array();
|
2008-05-30 07:30:53 +00:00
|
|
|
$edit['block_' . $bid . '[region]'] = 'left';
|
- 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->drupalPost('admin/build/block', $edit, t('Save blocks'));
|
|
|
|
|
|
|
|
// Confirm that the box was moved to the proper region.
|
|
|
|
$this->assertText(t('The block settings have been updated.'), t('Box successfully moved to left region.'));
|
|
|
|
|
|
|
|
// Confirm that the box is being displayed.
|
|
|
|
$this->assertText(t($box['title']), t('Box successfully being displayed on the page.'));
|
|
|
|
|
|
|
|
// Delete the created box & verify that it's been deleted and no longer appearing on the page.
|
2008-05-30 07:30:53 +00:00
|
|
|
$this->drupalPost('admin/build/block/delete/' . $bid, array(), t('Delete'));
|
- 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 block %title has been removed.', array('%title' => $box['info'])), t('Box successfully deleted.'));
|
|
|
|
$this->assertNoText(t($box['title']), t('Box no longer appears on page.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test configuring and moving a module-define block to specific regions.
|
|
|
|
*/
|
|
|
|
function testBlock() {
|
|
|
|
// Select the Navigation block to be configured and moved.
|
|
|
|
$block = array();
|
|
|
|
$block['module'] = 'user';
|
|
|
|
$block['delta'] = 'navigation';
|
|
|
|
$block['title'] = $this->randomName(8);
|
|
|
|
|
|
|
|
// Set block title to confirm that interface works and override any custom titles.
|
2008-05-30 07:30:53 +00:00
|
|
|
$this->drupalPost('admin/build/block/configure/' . $block['module'] . '/' . $block['delta'], array('title' => $block['title']), t('Save block'));
|
- 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->assertText(t('The block configuration has been saved.'), t('Block title set.'));
|
|
|
|
$bid = db_result(db_query("SELECT bid FROM {blocks} WHERE module = '%s' AND delta = %d", array($block['module'], $block['delta'])));
|
|
|
|
|
|
|
|
// Check to see if the block was created by checking that it's in the database.
|
|
|
|
$this->assertNotNull($bid, t('Block found in database'));
|
|
|
|
|
|
|
|
// Set the created block to a specific region.
|
|
|
|
$edit = array();
|
2008-05-30 07:30:53 +00:00
|
|
|
$edit[$block['module'] . '_' . $block['delta'] . '[region]'] = 'left';
|
- 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->drupalPost('admin/build/block', $edit, t('Save blocks'));
|
|
|
|
|
|
|
|
// Confirm that the block was moved to the proper region.
|
|
|
|
// TODO: Implement full region checking.
|
|
|
|
$this->assertText(t('The block settings have been updated.'), t('Block successfully moved to left region.'));
|
|
|
|
|
|
|
|
// Confirm that the block is being displayed.
|
|
|
|
$this->assertText(t($block['title']), t('Block successfully being displayed on the page.'));
|
|
|
|
|
|
|
|
// Set the block to the disabled region.
|
|
|
|
$edit = array();
|
2008-05-30 07:30:53 +00:00
|
|
|
$edit[$block['module'] . '_' . $block['delta'] . '[region]'] = '-1';
|
- 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->drupalPost('admin/build/block', $edit, t('Save blocks'));
|
|
|
|
|
|
|
|
// Confirm that the block was moved to the proper region.
|
|
|
|
$this->assertText(t('The block settings have been updated.'), t('Block successfully move to disabled region.'));
|
|
|
|
$this->assertNoText(t($block['title']), t('Block no longer appears on page.'));
|
|
|
|
|
|
|
|
// For convenience of developers, put the navigation block back.
|
|
|
|
$edit = array();
|
2008-05-30 07:30:53 +00:00
|
|
|
$edit[$block['module'] . '_' . $block['delta'] . '[region]'] = 'left';
|
- 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->drupalPost('admin/build/block', $edit, t('Save blocks'));
|
|
|
|
$this->assertText(t('The block settings have been updated.'), t('Block successfully move to disabled region.'));
|
|
|
|
|
2008-05-30 07:30:53 +00:00
|
|
|
$this->drupalPost('admin/build/block/configure/' . $block['module'] . '/' . $block['delta'], array('title' => 'Navigation'), t('Save block'));
|
- 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->assertText(t('The block configuration has been saved.'), t('Block title set.'));
|
|
|
|
}
|
|
|
|
}
|