-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtripal_test.test
108 lines (90 loc) · 3.24 KB
/
tripal_test.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* START TESTING CHADO SCHEMA V1.11, V1.2, V1.3
*
* TO TEST THIS APPLICATION YOU NEED TO:
* 1) Install PHP cURL: sudo apt-get install php5-curl or install php-curl
* 2) Enable the simpletest module: drush pm-enable simpletest
* 3) Run the test: drush test-run TripalCoreTest
* Tutorial: https://www.drupal.org/simpletest-tutorial-drupal7
*/
class Tripal_test extends DrupalWebTestCase {
protected $privileged_user;
/** home/vunda/PhpstormProjects/tripal2
* To make the test available to the Simpletest testing interface, we
* implement getInfo(). This provides the user interface information
* that will show up on the simpletest page of our site.
*/
public static function getInfo() {
return array(
'name' => 'Tripal Core unit tests',
'description' => 'Tests the functionality of the Tripal core module is
working correctly. WARNING: this test should only be used on an
freshly installed Drupal site without data.',
'group' => 'tripal_test',
);
}
/**
* Implements DrupalUnitTestCase::setUp().
*/
function setUp() {
// Enable modules required for the test.
$modules = array('ctools', 'views', 'tripal_core');
parent::setUp($modules);
}
function removeChado() {
// drop current chado and chado-related schema
if (chado_dbschema_exists('genetic_code')) {
print "Dropping existing 'genetic_code' schema\n";
db_query("drop schema genetic_code cascade");
}
if (chado_dbschema_exists('so')) {
print "Dropping existing 'so' schema\n";
db_query("drop schema so cascade");
}
if (chado_dbschema_exists('frange')) {
print "Dropping existing 'frange' schema\n";
db_query("drop schema frange cascade");
}
if (chado_dbschema_exists('chado')) {
print "Dropping existing 'chado' schema\n";
db_query("drop schema chado cascade");
}
}
/**
* Implements DrupalUnitTestCase::tearDown().
*/
function tearDown() {
// We need to remove the FK constraints on the tables before tearing
// them down or we get errors.
$result = db_query("ALTER TABLE {tripal_custom_tables} DROP CONSTRAINT tripal_custom_tables_fk1 CASCADE");
$this->assertTrue($result, "The constraint, tripal_custom_tables_fk1, could not be dropped");
// Now call the parent tearDown() function.
parent::tearDown();
}
// Note: The following test functions are executed in the order they appear.
/**
* Tests the Chado Schema API functions and related non API functions.
*/
function testTripal_test_Core() {
// The chado schema should NOT exist. If it does remove it
$result = chado_dbschema_exists('chado');
if ($result) {
$this->removeChado();
print_r('<pre>' . print_r($result, TRUE) . '</pre>');
// Install Chado v1.11 first
debug("Install Chado v1.3.");
tripal_core_install_chado('Install Chado v1.3');
print "Install of Chado v1.3 successful!\n";
//chado_query($vsql, array(':version' => '1.11'));
$this->removeChado();
}
tripal_core_install_chado('Install Chado v1.11');
print "Install of Chado v1.11 successful!\n";
tripal_core_install_chado('Upgrade Chado v1.11 to v1.2');
print "Install of Chado v1.2 successful";
$this->removeChado();
tripal_core_install_chado('Install Chado v1.3');
print "Install Chado v1.3 successful";
}
}