- 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$
|
|
|
|
|
2008-09-24 02:59:42 +00:00
|
|
|
class TaxonomyVocabularyLoadTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Loading taxonomy vocabularies'),
|
|
|
|
'description' => t('Test loading vocabularies under various conditions.'),
|
|
|
|
'group' => t('Taxonomy'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of setUp() {
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp('taxonomy');
|
|
|
|
$admin_user = $this->drupalCreateUser(array('administer taxonomy'));
|
|
|
|
$this->drupalLogin($admin_user);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure that when an invalid vocabulary vid is loaded, it is possible
|
|
|
|
* to load the same vid successfully if it subsequently becomes valid.
|
|
|
|
*/
|
|
|
|
function testTaxonomyVocabularyLoadReturnFalse() {
|
|
|
|
// Load a vocabulary that doesn't exist.
|
|
|
|
$vocabularies = taxonomy_get_vocabularies();
|
|
|
|
$vid = count($vocabularies) + 1;
|
|
|
|
$vocabulary = taxonomy_vocabulary_load($vid);
|
|
|
|
// This should not return an object because no such vocabulary exists.
|
|
|
|
$this->assertTrue(!is_object($vocabulary), t('No object loaded.'));
|
|
|
|
|
|
|
|
// Create a new vocabulary.
|
|
|
|
$edit = array(
|
|
|
|
'name' => $this->randomName(),
|
|
|
|
'description' => $this->randomName(),
|
|
|
|
'help' => '',
|
|
|
|
'weight' => 0,
|
|
|
|
);
|
|
|
|
$this->drupalPost('admin/content/taxonomy/add/vocabulary', $edit, t('Save'));
|
|
|
|
|
|
|
|
// Load the vocabulary with the same $vid from earlier.
|
|
|
|
// This should return a vocabulary object since it now matches a real vid.
|
|
|
|
$vocabulary = taxonomy_vocabulary_load($vid);
|
|
|
|
$this->assertTrue(is_object($vocabulary), t('Vocabulary is an object'));
|
|
|
|
$this->assertTrue($vocabulary->vid == $vid, t('Valid vocabulary vid is the same as our previously invalid one.'));
|
|
|
|
}
|
2008-09-24 18:42:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure that the vocabulary static reset works correctly.
|
|
|
|
*/
|
|
|
|
function testTaxonomyVocabularyLoadStaticReset() {
|
|
|
|
// Load the first available vocabulary.
|
|
|
|
$original_vocabulary = taxonomy_vocabulary_load(1);
|
2008-11-05 12:47:23 +00:00
|
|
|
$this->assertTrue(is_object($original_vocabulary));
|
2008-09-24 18:42:00 +00:00
|
|
|
|
|
|
|
// Change the name and description.
|
2008-11-05 12:47:23 +00:00
|
|
|
$vocabulary = $original_vocabulary;
|
|
|
|
$vocabulary->name = $this->randomName();
|
|
|
|
$vocabulary->description = $this->randomName();
|
|
|
|
taxonomy_vocabulary_save($vocabulary);
|
2008-09-24 18:42:00 +00:00
|
|
|
|
|
|
|
// Load the vocabulary with $reset TRUE.
|
|
|
|
$new_vocabulary = taxonomy_vocabulary_load($original_vocabulary->vid, TRUE);
|
2008-11-05 12:47:23 +00:00
|
|
|
$this->assertEqual($new_vocabulary->name, $vocabulary->name);
|
|
|
|
$this->assertEqual($new_vocabulary->name, $vocabulary->name);
|
2008-09-24 18:42:00 +00:00
|
|
|
}
|
2008-09-24 02:59:42 +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 TaxonomyVocabularyFunctionsTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Vocabulary functions'),
|
2008-09-24 02:59:42 +00:00
|
|
|
'description' => t('Test loading, saving, and deleting vocabularies.'),
|
- 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
|
|
|
'group' => t('Taxonomy')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2008-09-24 02:59:42 +00:00
|
|
|
/**
|
|
|
|
* Implementation of setUp().
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp('taxonomy');
|
|
|
|
}
|
|
|
|
|
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
|
|
|
/**
|
|
|
|
* Create/Edit/Delete vocabulary and assert that all fields were properly saved.
|
|
|
|
*/
|
|
|
|
function testVocabularyFunctions() {
|
|
|
|
//preparing data
|
|
|
|
$vid = 0;
|
|
|
|
$name = $this->randomName(200);
|
|
|
|
$description = $this->randomName(200);
|
|
|
|
$help = $this->randomName(200);
|
|
|
|
$hierarchy = rand(0,2); // Hierarchy 0,1,2
|
|
|
|
$multiple = rand(0,1); // multiple 0,1
|
|
|
|
$required = rand(0,1); // required 0,1
|
|
|
|
$relations = rand(0,1);
|
|
|
|
$tags = rand(0,1);
|
|
|
|
$weight = rand(-9,9);
|
|
|
|
$module = 'taxonomy';
|
|
|
|
$nodesList = array_keys(node_get_types());
|
|
|
|
$maxNodes = rand(1, count($nodesList));
|
|
|
|
$nodes = array();
|
|
|
|
for($i = 0; $i < $maxNodes; $i++) {
|
|
|
|
$nodes[$nodesList[$i]] = $nodesList[$i];
|
|
|
|
$nodesBak[$nodesList[$i]] = $nodesList[$i];
|
|
|
|
}
|
|
|
|
$_t = array('vid', 'name', 'description', 'help', 'relations', 'hierarchy', 'multiple',
|
|
|
|
'required', 'tags', 'module', 'weight', 'nodes');
|
|
|
|
$edit = array();
|
|
|
|
foreach($_t as $key)
|
|
|
|
$edit[$key] = $$key;
|
|
|
|
|
|
|
|
// Exec save function.
|
2008-11-05 12:47:23 +00:00
|
|
|
$vocabulary = (object) $edit;
|
|
|
|
taxonomy_vocabulary_save($vocabulary);
|
- 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
|
|
|
// After save we use $nodesBak.
|
|
|
|
ksort($nodesBak);
|
|
|
|
$edit['nodes'] = $nodesBak;
|
|
|
|
$vocabularies = taxonomy_get_vocabularies();
|
|
|
|
foreach($vocabularies as $voc) {
|
|
|
|
if ($voc->name == $name) {
|
|
|
|
$vid = $voc->vid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$edit['vid'] = $vid;
|
|
|
|
// Get data using function.
|
|
|
|
$getEdit = taxonomy_vocabulary_load($vid);
|
|
|
|
foreach($getEdit as $key => $value ) {
|
|
|
|
$this->assertEqual($value, $edit[$key], t('Checking value of @key.', array('@key' => $key)));
|
|
|
|
}
|
|
|
|
|
2008-11-05 12:47:23 +00:00
|
|
|
// Delete vocabulary.
|
|
|
|
taxonomy_vocabulary_delete($vid);
|
- 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
|
|
|
// Checking if we deleted voc.
|
|
|
|
$vocabularies = taxonomy_get_vocabularies();
|
|
|
|
$vid = 0;
|
|
|
|
foreach($vocabularies as $voc) {
|
|
|
|
if ($voc->name == $name) {
|
|
|
|
$vid = $voc->vid;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->assertEqual($vid, 0, t('Deleted vocabulary (@vid)', array('@vid' => $vid)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class TaxonomyTermFunctionsTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
2008-09-08 21:37:21 +00:00
|
|
|
'name' => t('Term no hierarchy'),
|
|
|
|
'description' => t('Testing save/update/delete terms without a hierarchy.'),
|
- 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
|
|
|
'group' => t('Taxonomy')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test term related functions.
|
|
|
|
*/
|
|
|
|
function testTermsFunctions() {
|
|
|
|
// Preparing data: vocabulary, hierarchy -> disabled, related terms = on.
|
|
|
|
$edit = array();
|
|
|
|
$_t = array('vid', 'name', 'description', 'help', 'relations', 'hierarchy', 'multiple',
|
|
|
|
'required', 'tags', 'module', 'weight', 'nodes');
|
|
|
|
foreach($_t as $key ) {
|
|
|
|
$edit[$key] = 0;
|
|
|
|
}
|
|
|
|
$name = $this->randomName(20);
|
|
|
|
$relation = 1;
|
|
|
|
$edit['name'] = $name;
|
2008-11-05 12:47:23 +00:00
|
|
|
$vocabulary = (object) $edit;
|
|
|
|
taxonomy_vocabulary_save($vocabulary);
|
|
|
|
$edit['vid'] = $vocabulary->vid;
|
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
|
|
|
|
|
|
|
// Create term.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$termdesc = $this->randomName(200);
|
|
|
|
$termweight = rand(-9, 9);
|
|
|
|
$randSyn = rand(0, 9);
|
|
|
|
$synonyms = array();
|
|
|
|
for($i = 0; $i < $randSyn; $i++) {
|
|
|
|
$synonyms[] = $this->randomName(20);
|
|
|
|
}
|
|
|
|
$termsyn = implode("\n", $synonyms);
|
|
|
|
$data = array('name' => $termname, 'description' => $termdesc, 'weight' => $termweight, 'synonyms' => $termsyn, 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
|
|
|
|
// Retrieve term and check all fields.
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$getTerm = $_tArray[0];
|
|
|
|
$checkField = array('name', 'description', 'weight', 'vid');
|
|
|
|
foreach($checkField as $v) {
|
|
|
|
$this->assertEqual($data[$v], $getTerm->$v, t('Checking value of the term (@v).', array('@v' => $v)));
|
|
|
|
}
|
|
|
|
$getSynonyms = taxonomy_get_synonyms($getTerm->tid);
|
|
|
|
$this->assertEqual(sort($synonyms), sort($getSynonyms), 'Checking synonyms');
|
|
|
|
|
|
|
|
// Creating related terms.
|
|
|
|
$relations = array();
|
|
|
|
$staryTid = $getTerm->tid;
|
|
|
|
$relations[] = $staryTid;
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => 0, 'vid' => $edit['vid'], 'tid' => 0, 'relations' => array($staryTid));
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$getTerm = $_tArray[0];
|
|
|
|
$relations[] = $getTerm->tid;
|
|
|
|
|
|
|
|
// Creating another term related to 2 terms above.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => 0, 'vid' => $edit['vid'], 'tid' => 0, 'relations' => array($staryTid, $getTerm->tid));
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$getTerm = $_tArray[0];
|
|
|
|
|
|
|
|
// Check related terms.
|
|
|
|
$related = taxonomy_get_related($getTerm->tid);
|
|
|
|
foreach($relations as $rTid) {
|
|
|
|
$this->assertTrue(array_key_exists($rTid, $related), t('Checking relations (@rTid).', array('@rTid' => $rTid)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete vocabulary.
|
2008-11-05 12:47:23 +00:00
|
|
|
taxonomy_vocabulary_delete($edit['vid']);
|
- 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-09-08 21:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class TaxonomyTermSingleTestCase extends DrupalWebTestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Term single hierarchy'),
|
|
|
|
'description' => t('Testing save/update/delete terms in a single hierarchy.'),
|
|
|
|
'group' => t('Taxonomy')
|
|
|
|
);
|
|
|
|
}
|
- 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 single hierarchy terms.
|
|
|
|
*/
|
|
|
|
function testTermsFunctionsSingleHierarchy() {
|
|
|
|
// Preparing data: vocabulary hierarchy->single.
|
|
|
|
$edit = array();
|
|
|
|
$_t = array('vid', 'name', 'description', 'help', 'relations', 'hierarchy', 'multiple',
|
|
|
|
'required', 'tags', 'module', 'weight', 'nodes');
|
|
|
|
foreach($_t as $key ) {
|
|
|
|
$edit[$key] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create vocab.
|
|
|
|
$name = $this->randomName(20);
|
|
|
|
$edit['hierarchy'] = 1;
|
|
|
|
$edit['name'] = $name;
|
2008-11-05 12:47:23 +00:00
|
|
|
$vocabulary = (object) $edit;
|
|
|
|
taxonomy_vocabulary_save($vocabulary);
|
|
|
|
$edit['vid'] = $vocabulary->vid;
|
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
|
|
|
|
|
|
|
// Create 1st term.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$parent = $_tArray[0];
|
|
|
|
|
|
|
|
// Create 2nd term as a child.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0, 'parent' => array($parent->tid));
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$children = $_tArray[0];
|
|
|
|
|
|
|
|
// Check hierarchy.
|
|
|
|
$getChildren = taxonomy_get_children($parent->tid);
|
|
|
|
$getParent = taxonomy_get_parents($children->tid);
|
|
|
|
$this->assertEqual($parent,$getParent[$parent->tid], t('Checking parents.'));
|
|
|
|
$this->assertEqual($children,$getChildren[$children->tid], t('Checking children.'));
|
|
|
|
|
|
|
|
// Delete vocabulary.
|
2008-11-05 12:47:23 +00:00
|
|
|
taxonomy_vocabulary_delete($edit['vid']);
|
- 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-09-08 21:37:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class TaxonomyTermMultipleTestCase extends DrupalWebTestCase {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Term multiple hierarchy'),
|
|
|
|
'description' => t('Testing save/update/delete terms in a multiple hierarchy.'),
|
|
|
|
'group' => t('Taxonomy')
|
|
|
|
);
|
|
|
|
}
|
- 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 multiple hierarchy terms.
|
|
|
|
*/
|
|
|
|
function testTermsFunctionsMultipleHierarchy() {
|
|
|
|
// Preparing data: vocabulary hierarchy->single.
|
|
|
|
$edit = array();
|
|
|
|
$_t = array('vid', 'name', 'description', 'help', 'relations', 'hierarchy', 'multiple',
|
|
|
|
'required', 'tags', 'module', 'weight', 'nodes');
|
|
|
|
foreach($_t as $key )
|
|
|
|
$edit[$key] = 0;
|
|
|
|
|
|
|
|
$name = $this->randomName(20);
|
|
|
|
$edit['hierarchy'] = 1;
|
|
|
|
$edit['name'] = $name;
|
2008-11-05 12:47:23 +00:00
|
|
|
$vocabulary = (object) $edit;
|
|
|
|
taxonomy_vocabulary_save($vocabulary);
|
|
|
|
$edit['vid'] = $vocabulary->vid;
|
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
|
|
|
|
|
|
|
// Create 1st term.
|
|
|
|
$parent = array();
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$parent[] = $_tArray[0]->tid;
|
|
|
|
|
|
|
|
// Create 2nd term.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$parent[] = $_tArray[0]->tid;
|
|
|
|
|
|
|
|
// Create 3rd term as a child.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $edit['vid'], 'tid' => 0, 'relations' => 0, 'parent' => array($parent));
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$children = $_tArray[0];
|
|
|
|
|
|
|
|
$getParent = taxonomy_get_parents($children->tid);
|
|
|
|
foreach($parent as $p) {
|
|
|
|
$this->assertTrue(array_key_exists($p, $getParent), t('Checking parents (@p)', array('@p' => $p)));
|
|
|
|
//$this->assertEqual($parent,$getParent[$parent->tid], 'Checking parents');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete vocabulary.
|
2008-11-05 12:47:23 +00:00
|
|
|
taxonomy_vocabulary_delete($edit['vid']);
|
- 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-09-11 19:47:40 +00:00
|
|
|
class TaxonomyAdminTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Administration interface'),
|
|
|
|
'description' => t('Test the vocabulary administration interface.'),
|
|
|
|
'group' => t('Taxonomy'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of setUp().
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->taxonomy_admin = $this->drupalCreateUser(array('administer taxonomy'));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Visit the various admin pages for the default 'Tags' vocabulary.
|
|
|
|
*/
|
|
|
|
function testTaxonomyAdminPages() {
|
|
|
|
$this->drupalLogin($this->taxonomy_admin);
|
|
|
|
$this->drupalGet('admin/content/taxonomy');
|
|
|
|
$this->assertResponse('200');
|
|
|
|
$this->assertText(t('Article'), t('Article vocabulary found.'));
|
|
|
|
$this->clickLink(t('edit vocabulary'));
|
|
|
|
$this->assertResponse('200');
|
|
|
|
$this->drupalGet('admin/content/taxonomy');
|
|
|
|
$this->clickLink(t('list terms'));
|
|
|
|
$this->assertResponse('200');
|
|
|
|
$this->clickLink(t('Add term'));
|
|
|
|
$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
|
|
|
class TaxonomyTestNodeApiTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Taxonomy nodeapi'),
|
|
|
|
'description' => t('Save & edit a node and assert that taxonomy terms are saved/loaded properly.'),
|
2008-09-11 19:47:40 +00:00
|
|
|
'group' => t('Taxonomy'),
|
- 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
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save & edit a node and assert that taxonomy terms are saved/loaded properly.
|
|
|
|
*/
|
|
|
|
function testTaxonomyNode() {
|
|
|
|
// Preparing data: vocabulary hierarchy->single, multiple -> on.
|
|
|
|
$edit = array();
|
|
|
|
$_t = array('vid', 'name', 'description', 'help', 'relations', 'hierarchy', 'multiple',
|
|
|
|
'required', 'tags', 'module', 'weight', 'nodes');
|
|
|
|
foreach($_t as $key) {
|
|
|
|
$edit[$key] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$name = $this->randomName(20);
|
2008-11-05 12:47:23 +00:00
|
|
|
$vocabulary->hierarchy = 1;
|
|
|
|
$vocabulary->multiple = 1;
|
|
|
|
$vocabulary->name = $name;
|
|
|
|
$vocabulary->nodes = array('article' => 'article');
|
|
|
|
taxonomy_vocabulary_save($vocabulary);
|
|
|
|
$vid = $vocabulary->vid;
|
|
|
|
|
- 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
|
|
|
|
|
|
|
$parent = array();
|
|
|
|
$patternArray = array();
|
|
|
|
|
|
|
|
// Create 1st term.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $vid, 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$parent[$_tArray[0]->tid] = $_tArray[0]->tid;
|
|
|
|
$patternArray['term name 1'] = $termname;
|
|
|
|
|
|
|
|
// Create 2nd term.
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $vid, 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$parent[$_tArray[0]->tid] = $_tArray[0]->tid;
|
|
|
|
$patternArray['term name 2'] = $termname;
|
|
|
|
|
|
|
|
// Create test user and login.
|
|
|
|
$perm = array('access content', 'create article content', 'edit own article content', 'delete own article content');
|
|
|
|
$account = $this->drupalCreateUser($perm);
|
|
|
|
$this->drupalLogin($account);
|
|
|
|
|
|
|
|
// Why is this printing out the user profile page?
|
|
|
|
// Go to node/add/article.
|
|
|
|
// Try to create article.
|
|
|
|
$title = $this->randomName();
|
|
|
|
$body = $this->randomName(100);
|
|
|
|
$edit = array('title' => $title, 'body' => $body, "taxonomy[$vid][]" => $parent);
|
|
|
|
|
|
|
|
$this->drupalPost('node/add/article', $edit, t('Save'));
|
|
|
|
|
|
|
|
$patternArray['body text'] = $body;
|
|
|
|
$patternArray['title'] = $title;
|
|
|
|
|
|
|
|
$node = node_load(array('title' => $title));
|
|
|
|
|
|
|
|
$this->drupalGet("node/$node->nid");
|
|
|
|
foreach($patternArray as $name => $termPattern) {
|
|
|
|
$this->assertText($termPattern, "Checking $name");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checking database fields.
|
|
|
|
$result = db_query('SELECT tid FROM {term_node} WHERE nid = %d', $node->nid);
|
|
|
|
while ($nodeRow = db_fetch_array($result)) {
|
|
|
|
$this->assertTrue(in_array($nodeRow['tid'], $parent), 'Checking database record');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ok, lets create new terms, and change this node.
|
|
|
|
array_pop($parent);
|
|
|
|
|
|
|
|
// create 1st term
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $vid, 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$parent[] = $_tArray[0]->tid;
|
|
|
|
$patternArray['term name 2'] = $termname;
|
|
|
|
|
|
|
|
// create 2nd term
|
|
|
|
$termname = $this->randomName(20);
|
|
|
|
$data = array('name' => $termname, 'description' => '', 'weight' => 0, 'synonyms' => '', 'vid' => $vid, 'tid' => 0, 'relations' => 0);
|
|
|
|
taxonomy_save_term($data);
|
|
|
|
$_tArray = taxonomy_get_term_by_name($termname);
|
|
|
|
$parent[] = $_tArray[0]->tid;
|
|
|
|
$patternArray['term name 3'] = $termname;
|
|
|
|
|
|
|
|
$edit = array('title' => $title, 'body' => $body, "taxonomy[$vid][]" => $parent);
|
|
|
|
|
2008-05-30 07:30:53 +00:00
|
|
|
$this->drupalPost('node/' . $node->nid . '/edit', $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
|
|
|
|
|
|
|
// TODO Do a MUCH better check here of the information msg.
|
|
|
|
$patternArray['information message'] = 'been updated';
|
|
|
|
foreach($patternArray as $name => $termPattern) {
|
|
|
|
$this->assertText($termPattern, t('Checking @name.', array('@name' => $name)));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Checking database fields.
|
|
|
|
$node = node_load(array('title' => $title));
|
|
|
|
$result = db_query('SELECT tid FROM {term_node} WHERE vid = %d', $node->vid);
|
|
|
|
while ($nodeRow = db_fetch_array($result)) {
|
|
|
|
$this->assertTrue(in_array($nodeRow['tid'], $parent), t('Checking database field.'));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Delete node through browser.
|
2008-05-30 07:30:53 +00:00
|
|
|
$this->drupalPost('node/' . $node->nid . '/delete', 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
|
|
|
// Checking after delete.
|
2008-05-30 07:30:53 +00:00
|
|
|
$this->drupalGet("node/" . $node->nid);
|
- 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($termname, t('Checking if node exists'));
|
|
|
|
// Checking database fields.
|
|
|
|
$num_rows = db_result(db_query('SELECT COUNT(*) FROM {term_node} WHERE nid = %d', $node->nid));
|
|
|
|
$this->assertEqual($num_rows, 0, t('Checking database field after deletion'));
|
|
|
|
|
2008-11-05 12:47:23 +00:00
|
|
|
// Delete vocabulary.
|
|
|
|
taxonomy_vocabulary_delete($vid);
|
- 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-09-11 19:47:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test term edit form to ensure terms can be edited from administration page
|
|
|
|
* and that term name and description are saved.
|
|
|
|
*/
|
|
|
|
class TermEditTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => 'Term edit test',
|
|
|
|
'description' => t('Ensure terms can be edited from administration page
|
|
|
|
and that term name and description are saved.'),
|
|
|
|
'group' => t('Taxonomy'));
|
|
|
|
}
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-09-11 19:47:40 +00:00
|
|
|
/**
|
|
|
|
* Implementation of setUp().
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
// Prepare a user to do the tests.
|
|
|
|
$web_user = $this->drupalCreateUser(array('administer taxonomy'));
|
|
|
|
$this->drupalLogin($web_user);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save and edit a term and assert that the name and description are correct.
|
|
|
|
*/
|
|
|
|
function testTermEdit() {
|
|
|
|
$edit = array(
|
|
|
|
'name' => $this->randomName(12),
|
|
|
|
'description' => $this->randomName(100),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Create the term to edit (adding to the default 'Tags' vocabulary).
|
2008-09-19 20:25:03 +00:00
|
|
|
$this->drupalPost('admin/content/taxonomy/1/add/', $edit, t('Save'));
|
2008-09-11 19:47:40 +00:00
|
|
|
|
|
|
|
$term = taxonomy_get_term_by_name($edit['name']);
|
|
|
|
$this->assertNotNull($term, t('Term found in database'));
|
|
|
|
|
|
|
|
// Submitting a term takes us to the add page; we need the List page.
|
2008-09-19 20:25:03 +00:00
|
|
|
$this->drupalGet('admin/content/taxonomy/1/list');
|
2008-09-11 19:47:40 +00:00
|
|
|
|
|
|
|
// Test edit link as accessed from Taxonomy administration pages.
|
|
|
|
// Because Simpletest creates its own database when running tests, we know
|
|
|
|
// the first edit link found on the listing page is to our term.
|
|
|
|
$this->clickLink(t('edit'));
|
|
|
|
|
|
|
|
// This failed inexplicably with assertText, so used assertRaw. @TODO: Why?
|
2008-09-19 20:25:03 +00:00
|
|
|
$this->assertText($edit['name'], t('The randomly generated term name is present.'));
|
2008-09-11 19:47:40 +00:00
|
|
|
$this->assertText($edit['description'], t('The randomly generated term description is present.'));
|
|
|
|
|
|
|
|
$edit = array(
|
|
|
|
'name' => $this->randomName(14),
|
|
|
|
'description' => $this->randomName(102),
|
|
|
|
);
|
|
|
|
|
|
|
|
// Edit the term.
|
2008-09-19 20:25:03 +00:00
|
|
|
$this->drupalPost('taxonomy/term/' . $term[0]->tid . '/edit', $edit, t('Save'));
|
2008-09-11 19:47:40 +00:00
|
|
|
|
|
|
|
// View the term and check that it is correct.
|
2008-09-19 20:25:03 +00:00
|
|
|
$this->drupalGet('taxonomy/term/' . $term[0]->tid);
|
2008-09-11 19:47:40 +00:00
|
|
|
$this->assertText($edit['name'], t('The randomly generated term name is present.'));
|
|
|
|
$this->assertText($edit['description'], t('The randomly generated term description is present.'));
|
|
|
|
}
|
2008-09-15 20:48:10 +00:00
|
|
|
}
|