| 1 |
|
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
/* |
| 4 |
|
* @file |
| 5 |
|
* Base class for all biblio tests |
| 6 |
|
*/ |
| 7 |
|
class BiblioWebTestCase extends DrupalWebTestCase { |
| 8 |
|
public $kids = array(); //keep a list of all keyword id's created |
| 9 |
|
public $cids = array(); //keep a list of all contributor id's created |
| 10 |
|
public $nids = array(); //keep a list of all node id's created |
| 11 |
|
public $admin_user; |
| 12 |
|
|
| 13 |
|
function tearDown() { |
| 14 |
|
// remove any keywords created during the testing |
| 15 |
|
if(!empty($this->kids)){ |
| 16 |
|
db_delete('biblio_keyword') |
| 17 |
|
->condition('kid', $this->kids, 'IN') |
| 18 |
|
->execute(); |
| 19 |
|
|
| 20 |
|
db_delete('biblio_keyword_data') |
| 21 |
|
->condition('kid', $this->kids, 'IN') |
| 22 |
|
->execute(); |
| 23 |
|
|
| 24 |
|
} |
| 25 |
|
$this->kids = array(); |
| 26 |
|
|
| 27 |
|
foreach($this->nids as $nid) { |
| 28 |
|
node_delete($nid); |
| 29 |
|
} |
| 30 |
|
$this->nids = array(); |
| 31 |
|
|
| 32 |
|
foreach($this->cids as $cid) { |
| 33 |
|
biblio_delete_contributor($cid); |
| 34 |
|
} |
| 35 |
|
$this->cids = array(); |
| 36 |
|
|
| 37 |
|
parent::tearDown(); |
| 38 |
|
} |
| 39 |
|
|
| 40 |
|
function createNode() { |
| 41 |
|
$settings = array( |
| 42 |
|
'type' => 'biblio', // This replaces the default type |
| 43 |
|
'biblio_type' => 100, // This appends a new field. |
| 44 |
|
'biblio_year' => 2009, |
| 45 |
|
'biblio_contributors' => array() |
| 46 |
|
); |
| 47 |
|
$node = $this->drupalCreateNode($settings); |
| 48 |
|
$this->nids[] = $node->nid; |
| 49 |
|
|
| 50 |
|
return $node; |
| 51 |
|
|
| 52 |
|
} |
| 53 |
|
} |