- 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
|
|
|
|
|
2009-04-22 15:53:00 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2011-02-04 18:42:22 +00:00
|
|
|
* Tests for path.module.
|
2009-04-22 15:53:00 +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
|
|
|
class PathTestCase extends DrupalWebTestCase {
|
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' => 'Path alias functionality',
|
|
|
|
'description' => 'Add, edit, delete, and change alias and verify its consistency in the database.',
|
|
|
|
'group' => 'Path',
|
- 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('path');
|
2009-04-22 09:57:10 +00:00
|
|
|
|
|
|
|
// Create test user and login.
|
|
|
|
$web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases'));
|
- 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($web_user);
|
|
|
|
}
|
|
|
|
|
2009-05-16 19:07:02 +00:00
|
|
|
/**
|
|
|
|
* Test the path cache.
|
|
|
|
*/
|
|
|
|
function testPathCache() {
|
|
|
|
// Create test node.
|
|
|
|
$node1 = $this->drupalCreateNode();
|
|
|
|
|
|
|
|
// Create alias.
|
|
|
|
$edit = array();
|
2009-10-15 17:53:34 +00:00
|
|
|
$edit['source'] = 'node/' . $node1->nid;
|
|
|
|
$edit['alias'] = $this->randomName(8);
|
2010-01-21 04:20:08 +00:00
|
|
|
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
|
2009-05-16 19:07:02 +00:00
|
|
|
|
|
|
|
// Visit the system path for the node and confirm a cache entry is
|
|
|
|
// created.
|
|
|
|
cache_clear_all('*', 'cache_path', TRUE);
|
2009-10-15 17:53:34 +00:00
|
|
|
$this->drupalGet($edit['source']);
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertTrue(cache_get($edit['source'], 'cache_path'), t('Cache entry was created.'));
|
2009-05-16 19:07:02 +00:00
|
|
|
|
|
|
|
// Visit the alias for the node and confirm a cache entry is created.
|
|
|
|
cache_clear_all('*', 'cache_path', TRUE);
|
2009-10-15 17:53:34 +00:00
|
|
|
$this->drupalGet($edit['alias']);
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertTrue(cache_get($edit['source'], 'cache_path'), t('Cache entry was created.'));
|
2009-05-16 19:07:02 +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 alias functionality through the admin interfaces.
|
|
|
|
*/
|
|
|
|
function testAdminAlias() {
|
2009-04-22 09:57:10 +00:00
|
|
|
// Create test node.
|
2009-01-09 07:44:00 +00:00
|
|
|
$node1 = $this->drupalCreateNode();
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Create alias.
|
- 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();
|
2009-10-15 17:53:34 +00:00
|
|
|
$edit['source'] = 'node/' . $node1->nid;
|
|
|
|
$edit['alias'] = $this->randomName(8);
|
2010-01-21 04:20:08 +00:00
|
|
|
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Confirm that the alias works.
|
2009-10-15 17:53:34 +00:00
|
|
|
$this->drupalGet($edit['alias']);
|
2010-01-09 21:54:01 +00:00
|
|
|
$this->assertText($node1->title, 'Alias works.');
|
2009-12-09 19:22:04 +00:00
|
|
|
$this->assertResponse(200);
|
- 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
|
|
|
|
2010-01-29 22:40:41 +00:00
|
|
|
// Change alias to one containing "exotic" characters.
|
2009-10-15 17:53:34 +00:00
|
|
|
$pid = $this->getPID($edit['alias']);
|
- 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-10-15 17:53:34 +00:00
|
|
|
$previous = $edit['alias'];
|
2010-01-29 22:40:41 +00:00
|
|
|
$edit['alias'] = "- ._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
|
|
|
|
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
|
|
|
|
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
|
2010-01-21 04:20:08 +00:00
|
|
|
$this->drupalPost('admin/config/search/path/edit/' . $pid, $edit, t('Save'));
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Confirm that the alias works.
|
2009-10-15 17:53:34 +00:00
|
|
|
$this->drupalGet($edit['alias']);
|
2010-01-09 21:54:01 +00:00
|
|
|
$this->assertText($node1->title, 'Changed alias works.');
|
2009-12-09 19:22:04 +00:00
|
|
|
$this->assertResponse(200);
|
- 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-10-15 17:53:34 +00:00
|
|
|
drupal_static_reset('drupal_lookup_path');
|
2008-04-25 18:26:02 +00:00
|
|
|
// Confirm that previous alias no longer works.
|
- 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->drupalGet($previous);
|
|
|
|
$this->assertNoText($node1->title, 'Previous alias no longer works.');
|
|
|
|
$this->assertResponse(404);
|
|
|
|
|
2008-04-25 18:26:02 +00:00
|
|
|
// Create second test node.
|
2009-01-09 07:44:00 +00:00
|
|
|
$node2 = $this->drupalCreateNode();
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Set alias to second test node.
|
2009-10-15 17:53:34 +00:00
|
|
|
$edit['source'] = 'node/' . $node2->nid;
|
|
|
|
// leave $edit['alias'] the same
|
2010-01-21 04:20:08 +00:00
|
|
|
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Confirm no duplicate was created.
|
2009-10-15 17:53:34 +00:00
|
|
|
$this->assertRaw(t('The alias %alias is already in use in this language.', array('%alias' => $edit['alias'])), 'Attempt to move alias was rejected.');
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Delete alias.
|
2010-01-21 04:20:08 +00:00
|
|
|
$this->drupalPost('admin/config/search/path/edit/' . $pid, array(), t('Delete'));
|
|
|
|
$this->drupalPost(NULL, array(), t('Confirm'));
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Confirm that the alias no longer works.
|
2009-10-15 17:53:34 +00:00
|
|
|
$this->drupalGet($edit['alias']);
|
- 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->assertNoText($node1->title, 'Alias was successfully deleted.');
|
2009-12-07 06:07:19 +00:00
|
|
|
$this->assertResponse(404);
|
- 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 alias functionality through the node interfaces.
|
|
|
|
*/
|
|
|
|
function testNodeAlias() {
|
2008-04-25 18:26:02 +00:00
|
|
|
// Create test node.
|
2009-01-09 07:44:00 +00:00
|
|
|
$node1 = $this->drupalCreateNode();
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Create alias.
|
- 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();
|
2009-10-20 01:24:34 +00:00
|
|
|
$edit['path[alias]'] = $this->randomName(8);
|
- 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('node/' . $node1->nid . '/edit', $edit, t('Save'));
|
|
|
|
|
2008-04-25 18:26:02 +00:00
|
|
|
// Confirm that the alias works.
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->drupalGet($edit['path[alias]']);
|
2010-01-09 21:54:01 +00:00
|
|
|
$this->assertText($node1->title, 'Alias works.');
|
2009-12-09 19:22:04 +00:00
|
|
|
$this->assertResponse(200);
|
- 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
|
|
|
|
2010-01-29 22:40:41 +00:00
|
|
|
// Change alias to one containing "exotic" characters.
|
2009-10-20 01:24:34 +00:00
|
|
|
$previous = $edit['path[alias]'];
|
2010-01-29 22:40:41 +00:00
|
|
|
$edit['path[alias]'] = "- ._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
|
|
|
|
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
|
|
|
|
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
|
- 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('node/' . $node1->nid . '/edit', $edit, t('Save'));
|
|
|
|
|
2008-04-25 18:26:02 +00:00
|
|
|
// Confirm that the alias works.
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->drupalGet($edit['path[alias]']);
|
2010-01-09 21:54:01 +00:00
|
|
|
$this->assertText($node1->title, 'Changed alias works.');
|
2009-12-09 19:22:04 +00:00
|
|
|
$this->assertResponse(200);
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Make sure that previous alias no longer works.
|
- 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->drupalGet($previous);
|
2010-01-09 21:54:01 +00:00
|
|
|
$this->assertNoText($node1->title, 'Previous alias no longer works.');
|
- 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->assertResponse(404);
|
|
|
|
|
2008-04-25 18:26:02 +00:00
|
|
|
// Create second test node.
|
2009-01-09 07:44:00 +00:00
|
|
|
$node2 = $this->drupalCreateNode();
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Set alias to second test node.
|
2009-10-20 01:24:34 +00:00
|
|
|
// Leave $edit['path[alias]'] the same.
|
- 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('node/' . $node2->nid . '/edit', $edit, t('Save'));
|
|
|
|
|
2008-04-25 18:26:02 +00:00
|
|
|
// Confirm that the alias didn't make a duplicate.
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->assertText(t('The alias is already in use.'), 'Attempt to moved alias was rejected.');
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Delete alias.
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->drupalPost('node/' . $node1->nid . '/edit', array('path[alias]' => ''), t('Save'));
|
- 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-04-25 18:26:02 +00:00
|
|
|
// Confirm that the alias no longer works.
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->drupalGet($edit['path[alias]']);
|
- 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->assertNoText($node1->title, 'Alias was successfully deleted.');
|
2009-12-07 06:07:19 +00:00
|
|
|
$this->assertResponse(404);
|
- 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-10-15 17:53:34 +00:00
|
|
|
function getPID($alias) {
|
|
|
|
return db_query("SELECT pid FROM {url_alias} WHERE alias = :alias", array(':alias' => $alias))->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
|
|
|
}
|
|
|
|
}
|
2008-10-13 20:57:19 +00:00
|
|
|
|
2009-10-20 01:24:34 +00:00
|
|
|
/**
|
|
|
|
* Test URL aliases for taxonomy terms.
|
|
|
|
*/
|
|
|
|
class PathTaxonomyTermTestCase extends DrupalWebTestCase {
|
|
|
|
public static function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => 'Taxonomy term URL aliases',
|
|
|
|
'description' => 'Tests URL aliases for taxonomy terms.',
|
|
|
|
'group' => 'Path',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp('path', 'taxonomy');
|
|
|
|
|
|
|
|
// Create and login user.
|
|
|
|
$web_user = $this->drupalCreateUser(array('administer url aliases', 'administer taxonomy', 'access administration pages'));
|
|
|
|
$this->drupalLogin($web_user);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test alias functionality through the admin interfaces.
|
|
|
|
*/
|
|
|
|
function testTermAlias() {
|
|
|
|
// Create a term in the default 'Tags' vocabulary with URL alias.
|
2010-03-25 11:53:25 +00:00
|
|
|
$vocabulary = taxonomy_vocabulary_load(1);
|
2010-08-05 23:53:39 +00:00
|
|
|
$description = $this->randomName();;
|
2009-10-20 01:24:34 +00:00
|
|
|
$edit = array();
|
|
|
|
$edit['name'] = $this->randomName();
|
2010-03-07 23:14:20 +00:00
|
|
|
$edit['description[value]'] = $description;
|
2009-10-20 01:24:34 +00:00
|
|
|
$edit['path[alias]'] = $this->randomName();
|
2010-03-25 11:53:25 +00:00
|
|
|
$this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save'));
|
2009-10-20 01:24:34 +00:00
|
|
|
|
|
|
|
// Confirm that the alias works.
|
|
|
|
$this->drupalGet($edit['path[alias]']);
|
2010-03-07 23:14:20 +00:00
|
|
|
$this->assertText($description, 'Term can be accessed on URL alias.');
|
2009-10-20 01:24:34 +00:00
|
|
|
|
|
|
|
// Change the term's URL alias.
|
|
|
|
$tid = db_query("SELECT tid FROM {taxonomy_term_data} WHERE name = :name", array(':name' => $edit['name']))->fetchField();
|
|
|
|
$edit2 = array();
|
|
|
|
$edit2['path[alias]'] = $this->randomName();
|
|
|
|
$this->drupalPost('taxonomy/term/' . $tid . '/edit', $edit2, t('Save'));
|
|
|
|
|
|
|
|
// Confirm that the changed alias works.
|
|
|
|
$this->drupalGet($edit2['path[alias]']);
|
2010-03-07 23:14:20 +00:00
|
|
|
$this->assertText($description, 'Term can be accessed on changed URL alias.');
|
2009-10-20 01:24:34 +00:00
|
|
|
|
|
|
|
// Confirm that the old alias no longer works.
|
|
|
|
$this->drupalGet($edit['path[alias]']);
|
2010-03-07 23:14:20 +00:00
|
|
|
$this->assertNoText($description, 'Old URL alias has been removed after altering.');
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->assertResponse(404, 'Old URL alias returns 404.');
|
|
|
|
|
|
|
|
// Remove the term's URL alias.
|
|
|
|
$edit3 = array();
|
|
|
|
$edit3['path[alias]'] = '';
|
|
|
|
$this->drupalPost('taxonomy/term/' . $tid . '/edit', $edit3, t('Save'));
|
|
|
|
|
|
|
|
// Confirm that the alias no longer works.
|
|
|
|
$this->drupalGet($edit2['path[alias]']);
|
2010-03-07 23:14:20 +00:00
|
|
|
$this->assertNoText($description, 'Old URL alias has been removed after altering.');
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->assertResponse(404, 'Old URL alias returns 404.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-13 20:57:19 +00:00
|
|
|
class PathLanguageTestCase extends DrupalWebTestCase {
|
2009-03-31 01:49:55 +00:00
|
|
|
public static function getInfo() {
|
2008-10-13 20:57:19 +00:00
|
|
|
return array(
|
2009-07-13 21:51:42 +00:00
|
|
|
'name' => 'Path aliases with translated nodes',
|
|
|
|
'description' => 'Confirm that paths work with translated nodes',
|
|
|
|
'group' => 'Path',
|
2008-10-13 20:57:19 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp('path', 'locale', 'translation');
|
|
|
|
|
|
|
|
// Create and login user.
|
2010-07-30 01:52:54 +00:00
|
|
|
$this->web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'translate content', 'access administration pages'));
|
|
|
|
$this->drupalLogin($this->web_user);
|
2008-10-13 20:57:19 +00:00
|
|
|
|
|
|
|
// Enable French language.
|
|
|
|
$edit = array();
|
|
|
|
$edit['langcode'] = 'fr';
|
|
|
|
|
2009-08-21 14:28:52 +00:00
|
|
|
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
2008-10-13 20:57:19 +00:00
|
|
|
|
2010-07-30 01:52:54 +00:00
|
|
|
// Enable URL language detection and selection.
|
|
|
|
$edit = array('language[enabled][locale-url]' => 1);
|
|
|
|
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
2008-10-13 20:57:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test alias functionality through the admin interfaces.
|
|
|
|
*/
|
|
|
|
function testAliasTranslation() {
|
|
|
|
// Set 'page' content type to enable translation.
|
|
|
|
variable_set('language_content_type_page', 2);
|
|
|
|
|
2009-01-09 07:44:00 +00:00
|
|
|
$english_node = $this->drupalCreateNode(array('type' => 'page'));
|
2010-07-30 01:52:54 +00:00
|
|
|
$english_alias = $this->randomName();
|
2009-01-09 07:44:00 +00:00
|
|
|
|
|
|
|
// Edit the node to set language and path.
|
2008-10-13 20:57:19 +00:00
|
|
|
$edit = array();
|
|
|
|
$edit['language'] = 'en';
|
2010-07-30 01:52:54 +00:00
|
|
|
$edit['path[alias]'] = $english_alias;
|
2009-01-09 07:44:00 +00:00
|
|
|
$this->drupalPost('node/' . $english_node->nid . '/edit', $edit, t('Save'));
|
2008-10-13 20:57:19 +00:00
|
|
|
|
|
|
|
// Confirm that the alias works.
|
2010-07-30 01:52:54 +00:00
|
|
|
$this->drupalGet($english_alias);
|
2010-01-09 21:54:01 +00:00
|
|
|
$this->assertText($english_node->title, 'Alias works.');
|
2008-10-13 20:57:19 +00:00
|
|
|
|
|
|
|
// Translate the node into French.
|
|
|
|
$this->drupalGet('node/' . $english_node->nid . '/translate');
|
|
|
|
$this->clickLink(t('add translation'));
|
|
|
|
$edit = array();
|
2010-01-09 21:54:01 +00:00
|
|
|
$edit["title"] = $this->randomName();
|
2010-07-30 01:52:54 +00:00
|
|
|
$edit["body[fr][0][value]"] = $this->randomName();
|
|
|
|
$french_alias = $this->randomName();
|
|
|
|
$edit['path[alias]'] = $french_alias;
|
2008-10-13 20:57:19 +00:00
|
|
|
$this->drupalPost(NULL, $edit, t('Save'));
|
|
|
|
|
|
|
|
// Clear the path lookup cache.
|
|
|
|
drupal_lookup_path('wipe');
|
|
|
|
|
|
|
|
// Ensure the node was created.
|
2010-01-09 21:54:01 +00:00
|
|
|
$french_node = $this->drupalGetNodeByTitle($edit["title"]);
|
2008-10-13 20:57:19 +00:00
|
|
|
$this->assertTrue(($french_node), 'Node found in database.');
|
|
|
|
|
|
|
|
// Confirm that the alias works.
|
2009-10-20 01:24:34 +00:00
|
|
|
$this->drupalGet('fr/' . $edit['path[alias]']);
|
2010-01-09 21:54:01 +00:00
|
|
|
$this->assertText($french_node->title, 'Alias for French translation works.');
|
2008-10-13 20:57:19 +00:00
|
|
|
|
|
|
|
// Confirm that the alias is returned by url().
|
2009-10-16 02:04:44 +00:00
|
|
|
drupal_static_reset('language_list');
|
2010-10-09 17:38:41 +00:00
|
|
|
drupal_static_reset('locale_url_outbound_alter');
|
2008-10-13 20:57:19 +00:00
|
|
|
$languages = language_list();
|
|
|
|
$url = url('node/' . $french_node->nid, array('language' => $languages[$french_node->language]));
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertTrue(strpos($url, $edit['path[alias]']), t('URL contains the path alias.'));
|
2010-07-30 01:52:54 +00:00
|
|
|
|
|
|
|
// Confirm that the alias works even when changing language negotiation
|
|
|
|
// options. Enable User language detection and selection over URL one.
|
|
|
|
$edit = array(
|
|
|
|
'language[enabled][locale-user]' => 1,
|
|
|
|
'language[weight][locale-user]' => -9,
|
|
|
|
'language[enabled][locale-url]' => 1,
|
|
|
|
'language[weight][locale-url]' => -8,
|
|
|
|
);
|
|
|
|
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
|
|
|
|
|
|
|
// Change user language preference.
|
|
|
|
$edit = array('language' => 'fr');
|
|
|
|
$this->drupalPost("user/{$this->web_user->uid}/edit", $edit, t('Save'));
|
|
|
|
|
|
|
|
// Check that the English alias works. In this situation French is the
|
|
|
|
// current UI and content language, while URL language is English (since we
|
|
|
|
// do not have a path prefix we fall back to the site's default language).
|
|
|
|
// We need to ensure that the user language preference is not taken into
|
|
|
|
// account while determining the path alias language, because if this
|
|
|
|
// happens we have no way to check that the path alias is valid: there is no
|
|
|
|
// path alias for French matching the english alias. So drupal_lookup_path()
|
|
|
|
// needs to use the URL language to check whether the alias is valid.
|
|
|
|
$this->drupalGet($english_alias);
|
|
|
|
$this->assertText($english_node->title, 'Alias for English translation works.');
|
|
|
|
|
|
|
|
// Check that the French alias works.
|
|
|
|
$this->drupalGet("fr/$french_alias");
|
|
|
|
$this->assertText($french_node->title, 'Alias for French translation works.');
|
|
|
|
|
|
|
|
// Disable URL language negotiation.
|
|
|
|
$edit = array('language[enabled][locale-url]' => FALSE);
|
|
|
|
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
|
|
|
|
|
|
|
// Check that the English alias still works.
|
|
|
|
$this->drupalGet($english_alias);
|
|
|
|
$this->assertText($english_node->title, 'Alias for English translation works.');
|
|
|
|
|
|
|
|
// Check that the French alias is not available. We check the unprefixed
|
|
|
|
// alias because we disabled URL language negotiation above. In this
|
|
|
|
// situation only aliases in the default language and language neutral ones
|
|
|
|
// should keep working.
|
|
|
|
$this->drupalGet($french_alias);
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertResponse(404, t('Alias for French translation is unavailable when URL language negotiation is disabled.'));
|
2010-07-31 04:10:30 +00:00
|
|
|
|
|
|
|
// drupal_lookup_path() has an internal static cache. Check to see that
|
|
|
|
// it has the appropriate contents at this point.
|
|
|
|
drupal_lookup_path('wipe');
|
|
|
|
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path works.'));
|
2010-07-31 04:10:30 +00:00
|
|
|
// Second call should return the same path.
|
|
|
|
$french_node_path = drupal_lookup_path('source', $french_alias, $french_node->language);
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertEqual($french_node_path, 'node/' . $french_node->nid, t('Normal path is the same.'));
|
2010-07-31 04:10:30 +00:00
|
|
|
|
|
|
|
// Confirm that the alias works.
|
|
|
|
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertEqual($french_node_alias, $french_alias, t('Alias works.'));
|
2010-07-31 04:10:30 +00:00
|
|
|
// Second call should return the same alias.
|
|
|
|
$french_node_alias = drupal_lookup_path('alias', 'node/' . $french_node->nid, $french_node->language);
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertEqual($french_node_alias, $french_alias, t('Alias is the same.'));
|
2008-10-13 20:57:19 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-26 12:37:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests the user interface for creating path aliases, with languages.
|
|
|
|
*/
|
|
|
|
class PathLanguageUITestCase extends DrupalWebTestCase {
|
|
|
|
public static function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => 'Path aliases with languages',
|
|
|
|
'description' => 'Confirm that the Path module user interface works with languages.',
|
|
|
|
'group' => 'Path',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp('path', 'locale');
|
|
|
|
|
|
|
|
// Create and login user.
|
|
|
|
$web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages'));
|
|
|
|
$this->drupalLogin($web_user);
|
|
|
|
|
|
|
|
// Enable French language.
|
|
|
|
$edit = array();
|
|
|
|
$edit['langcode'] = 'fr';
|
|
|
|
|
|
|
|
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
|
|
|
|
2010-07-30 01:52:54 +00:00
|
|
|
// Enable URL language detection and selection.
|
|
|
|
$edit = array('language[enabled][locale-url]' => 1);
|
|
|
|
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
2010-03-26 12:37:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that a language-neutral URL alias works.
|
|
|
|
*/
|
|
|
|
function testLanguageNeutralURLs() {
|
|
|
|
$name = $this->randomName(8);
|
|
|
|
$edit = array();
|
|
|
|
$edit['source'] = 'admin/config/search/path';
|
|
|
|
$edit['alias'] = $name;
|
|
|
|
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
|
|
|
|
|
|
|
|
$this->drupalGet($name);
|
|
|
|
$this->assertText(t('Filter aliases'), 'Language-neutral URL alias works');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that a default language URL alias works.
|
|
|
|
*/
|
|
|
|
function testDefaultLanguageURLs() {
|
|
|
|
$name = $this->randomName(8);
|
|
|
|
$edit = array();
|
|
|
|
$edit['source'] = 'admin/config/search/path';
|
|
|
|
$edit['alias'] = $name;
|
|
|
|
$edit['language'] = 'en';
|
|
|
|
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
|
|
|
|
|
|
|
|
$this->drupalGet($name);
|
|
|
|
$this->assertText(t('Filter aliases'), 'English URL alias works');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that a non-default language URL alias works.
|
|
|
|
*/
|
|
|
|
function testNonDefaultURLs() {
|
|
|
|
$name = $this->randomName(8);
|
|
|
|
$edit = array();
|
|
|
|
$edit['source'] = 'admin/config/search/path';
|
|
|
|
$edit['alias'] = $name;
|
|
|
|
$edit['language'] = 'fr';
|
|
|
|
$this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
|
|
|
|
|
|
|
|
$this->drupalGet('fr/' . $name);
|
|
|
|
$this->assertText(t('Filter aliases'), 'Foreign URL alias works');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2010-08-05 08:08:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests that paths are not prefixed on a monolingual site.
|
|
|
|
*/
|
|
|
|
class PathMonolingualTestCase extends DrupalWebTestCase {
|
|
|
|
public static function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => 'Paths on non-English monolingual sites',
|
|
|
|
'description' => 'Confirm that paths are not changed on monolingual non-English sites',
|
|
|
|
'group' => 'Path',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
global $language;
|
|
|
|
parent::setUp('path', 'locale', 'translation');
|
|
|
|
|
|
|
|
// Create and login user.
|
|
|
|
$web_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
|
|
|
|
$this->drupalLogin($web_user);
|
|
|
|
|
|
|
|
// Enable French language.
|
|
|
|
$edit = array();
|
|
|
|
$edit['langcode'] = 'fr';
|
|
|
|
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
|
|
|
|
|
|
|
|
// Make French the default language.
|
|
|
|
$edit = array('site_default' => 'fr');
|
|
|
|
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
|
|
|
|
|
|
|
|
// Disable English.
|
|
|
|
$edit = array('enabled[en]' => FALSE);
|
|
|
|
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
|
|
|
|
|
|
|
|
// Verify that French is the only language.
|
2010-08-05 23:53:39 +00:00
|
|
|
$this->assertFalse(drupal_multilingual(), t('Site is mono-lingual'));
|
|
|
|
$this->assertEqual(language_default('language'), 'fr', t('French is the default language'));
|
2010-08-05 08:08:43 +00:00
|
|
|
|
|
|
|
// Set language detection to URL.
|
|
|
|
$edit = array('language[enabled][locale-url]' => TRUE);
|
|
|
|
$this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
|
|
|
|
|
|
|
|
// Force languages to be initialized.
|
|
|
|
drupal_language_initialize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verifies that links do not have language prefixes in them.
|
|
|
|
*/
|
|
|
|
function testPageLinks() {
|
|
|
|
// Navigate to 'admin/config' path.
|
|
|
|
$this->drupalGet('admin/config');
|
|
|
|
|
|
|
|
// Verify that links in this page do not have a 'fr/' prefix.
|
|
|
|
$this->assertNoLinkByHref('/fr/', 'Links do not contain language prefix');
|
|
|
|
|
|
|
|
// Verify that links in this page can be followed and work.
|
|
|
|
$this->clickLink(t('Languages'));
|
|
|
|
$this->assertResponse(200, 'Clicked link results in a valid page');
|
|
|
|
$this->assertText(t('Add language'), 'Page contains the add language text');
|
|
|
|
}
|
|
|
|
}
|