- 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$
2009-04-26 16:30:28 +00:00
/**
* @file
* Tests for the block module
*/
- 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
class BlockTestCase extends DrupalWebTestCase {
2008-12-16 23:57:33 +00:00
protected $regions;
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(
'name' => t('Block functionality'),
'description' => t('Add, edit and delete custom block. Configure and move a module-defined block.'),
'group' => t('Block'),
);
}
function setUp() {
parent::setUp();
// Create and login user
2009-03-20 19:18:11 +00:00
$admin_user = $this->drupalCreateUser(array('administer blocks', 'administer filters', 'access administration pages'));
- 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->drupalLogin($admin_user);
2008-12-16 23:57:33 +00:00
2008-12-30 16:43:20 +00:00
// Define the existing regions
2008-12-16 23:57:33 +00:00
$this->regions = array();
$this->regions[] = array('name' => 'header', 'id' => 'header-region');
$this->regions[] = array('name' => 'left', 'id' => 'sidebar-left');
$this->regions[] = array('name' => 'content', 'id' => 'center');
$this->regions[] = array('name' => 'right', 'id' => 'sidebar-right');
$this->regions[] = array('name' => 'footer');
- 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
}
/**
* 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.'));
2009-05-28 11:31:20 +00:00
$bid = db_query("SELECT bid FROM {box} WHERE info = :info", array(':info' => $box['info']))->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
// Check to see if the box was created by checking that it's in the database..
$this->assertNotNull($bid, t('Box found in database'));
2008-12-16 23:57:33 +00:00
// Check if the block can be moved to all availble regions.
$box['module'] = 'block';
$box['delta'] = $bid;
foreach ($this->regions as $region) {
$this->moveBlockToRegion($box, $region);
}
- 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
// Delete the created box & verify that it's been deleted and no longer appearing on the page.
2009-02-11 03:38:46 +00:00
$this->clickLink(t('delete'));
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.'));
}
2008-11-07 05:58:51 +00:00
/**
* Test creating custom block (i.e. box) using Full HTML.
*/
function testBoxFormat() {
// 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'] = '<h1>Full HTML</h1>';
$box['body_format'] = 2;
$this->drupalPost('admin/build/block/add', $box, t('Save block'));
// Set the created box to a specific region.
2009-05-28 11:31:20 +00:00
$bid = db_query("SELECT bid FROM {box} WHERE info = :info", array(':info' => $box['info']))->fetchField();
2008-11-07 05:58:51 +00:00
$edit = array();
$edit['block_' . $bid . '[region]'] = 'left';
$this->drupalPost('admin/build/block', $edit, t('Save blocks'));
2009-01-21 16:58:42 +00:00
// Confirm that the box is being displayed using configured text format.
2008-11-07 05:58:51 +00:00
$this->assertRaw('<h1>Full HTML</h1>', t('Box successfully being displayed using Full HTML.'));
2009-05-24 07:13:12 +00:00
// Confirm that a user without access to Full HTML can not see the body field,
// but can still submit the form without errors.
$block_admin = $this->drupalCreateUser(array('administer blocks'));
$this->drupalLogin($block_admin);
$this->drupalGet('admin/build/block/configure/block/' . $bid);
$this->assertNoText(t('Block body'));
$this->drupalPost('admin/build/block/configure/block/' . $bid, array(), t('Save block'));
$this->assertNoText(t('Please ensure that each block description is unique.'));
// Confirm that the box is still being displayed using configured text format.
$this->assertRaw('<h1>Full HTML</h1>', t('Box successfully being displayed using Full HTML.'));
2008-11-07 05:58:51 +00:00
}
- 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
/**
* Test configuring and moving a module-define block to specific regions.
*/
function testBlock() {
// Select the Navigation block to be configured and moved.
$block = array();
2009-03-20 19:18:11 +00:00
$block['module'] = 'system';
$block['delta'] = 'management';
- 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
$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.'));
2009-05-28 11:31:20 +00:00
$bid = db_query("SELECT bid FROM {block} WHERE module = :module AND delta = :delta", array(
':module' => $block['module'],
':delta' => $block['delta'],
))->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
// Check to see if the block was created by checking that it's in the database.
$this->assertNotNull($bid, t('Block found in database'));
2008-12-16 23:57:33 +00:00
// Check if the block can be moved to all availble regions.
foreach ($this->regions as $region) {
$this->moveBlockToRegion($block, $region);
}
- 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
// 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.'));
2008-12-16 23:57:33 +00:00
// Confirm that the regions xpath is not availble
$xpath = '//div[@id="block-block-' . $bid . '"]/*';
2009-04-26 16:30:28 +00:00
$this->assertNoFieldByXPath($xpath, FALSE, t('Box found in no regions.'));
2008-12-16 23:57:33 +00:00
- 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
// 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'));
2008-12-16 23:57:33 +00:00
$this->assertText(t('The block settings have been updated.'), t('Block successfully move to left region.'));
- 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
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.'));
}
2008-09-14 20:37:28 +00:00
2008-12-16 23:57:33 +00:00
function moveBlockToRegion($block, $region) {
// If an id for an region hasn't been specified, we assume it's the same as the name.
if (!(isset($region['id']))) {
$region['id'] = $region['name'];
}
// Set the created block to a specific region.
$edit = array();
$edit[$block['module'] . '_' . $block['delta'] . '[region]'] = $region['name'];
$this->drupalPost('admin/build/block', $edit, t('Save blocks'));
// Confirm that the block was moved to the proper region.
2009-04-26 16:30:28 +00:00
$this->assertText(t('The block settings have been updated.'), t('Block successfully moved to %region_name region.', array( '%region_name' => $region['name'])));
2008-12-16 23:57:33 +00:00
// Confirm that the block is being displayed.
$this->assertText(t($block['title']), t('Block successfully being displayed on the page.'));
// Confirm that the box was found at the proper region.
$xpath = '//div[@id="' . $region['id'] . '"]//div[@id="block-' . $block['module'] . '-' . $block['delta'] . '"]/*';
$this->assertFieldByXPath($xpath, FALSE, t('Box found in %region_name region.', array('%region_name' => $region['name'])));
}
2008-09-14 20:37:28 +00:00
}
class NonDefaultBlockAdmin extends DrupalWebTestCase {
2009-03-31 01:49:55 +00:00
public static function getInfo() {
2008-09-14 20:37:28 +00:00
return array(
'name' => t('Non default theme admin'),
'description' => t('Check the administer page for non default theme.'),
'group' => t('Block'),
);
}
/**
* Test non-default theme admin.
*/
2009-01-07 21:41:13 +00:00
function testNonDefaultBlockAdmin() {
2008-09-14 20:37:28 +00:00
$admin_user = $this->drupalCreateUser(array('administer blocks', 'administer site configuration'));
$this->drupalLogin($admin_user);
2009-03-14 16:41:30 +00:00
$this->drupalPost('admin/build/themes', array('status[stark]' => 1), t('Save configuration'));
$this->drupalGet('admin/build/block/list/stark');
$this->assertRaw('stark/layout.css', t('Stark CSS found'));
2008-09-14 20:37:28 +00:00
}
- 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
}
2009-05-31 06:31:00 +00:00
2009-05-31 07:46:54 +00:00
/**
* Test blocks correctly initialized when picking a new default theme.
*/
class NewDefaultThemeBlocks extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('New default theme blocks'),
'description' => t('Checks that the new default theme gets blocks.'),
'group' => t('Block'),
);
}
/**
* Check the enabled Garland blocks are correctly copied over.
*/
function testNewDefaultThemeBlocks() {
// Create administrative user.
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
$this->drupalLogin($admin_user);
// Ensure no other theme's blocks are in the block table yet.
$count = db_query_range("SELECT 1 FROM {block} WHERE theme != 'garland'", 0, 1)->fetchField();
$this->assertFalse($count, t('Only Garland has blocks.'));
// Populate list of all blocks for matching against new theme.
$blocks = array();
$result = db_query('SELECT * FROM {block}');
foreach ($result as $block) {
// $block->theme and $block->bid will not match, so remove them.
unset($block->theme, $block->bid);
$blocks[$block->module][$block->delta] = $block;
}
// Turn on the Stark theme and ensure that it contains all of the blocks
// that Garland did.
$this->drupalPost('admin/build/themes', array('theme_default' => 'stark'), t('Save configuration'));
$result = db_query("SELECT * FROM {block} WHERE theme='stark'");
foreach ($result as $block) {
unset($block->theme, $block->bid);
$this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block matched'));
}
}
}
2009-05-31 06:31:00 +00:00
/**
* Test the block system with admin themes.
*/
class BlockAdminThemeTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => t('Admin theme block admin accessibility'),
'description' => t("Check whether the block administer page for a disabled theme acccessible if and only if it's the admin theme."),
'group' => t('Block'),
);
}
/**
* Check for the accessibility of the admin theme on the block admin page.
*/
function testAdminTheme() {
// Create administrative user.
$admin_user = $this->drupalCreateUser(array('administer blocks', 'administer site configuration'));
$this->drupalLogin($admin_user);
// Ensure that access to block admin page is denied when theme is disabled.
$this->drupalGet('admin/build/block/list/stark');
$this->assertResponse(403, t('The block admin page for a disabled theme can not be accessed'));
// Enable admin theme and confirm that tab is accessible.
$edit['admin_theme'] = 'stark';
$this->drupalPost('admin/build/themes', $edit, t('Save configuration'));
$this->drupalGet('admin/build/block/list/stark');
$this->assertResponse(200, t('The block admin page for the admin theme can be accessed'));
}
}