]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/PHPUnit/Util/Log/Database/SQLite3.sql
Added unit tests.
[Github/sugarcrm.git] / tests / PHPUnit / Util / Log / Database / SQLite3.sql
1 --
2 -- PHPUnit
3 --
4 -- Copyright (c) 2002-2009, Sebastian Bergmann <sb@sebastian-bergmann.de>.
5 -- All rights reserved.
6 --
7 -- Redistribution and use in source and binary forms, with or without
8 -- modification, are permitted provided that the following conditions
9 -- are met:
10 --
11 --   * Redistributions of source code must retain the above copyright
12 --     notice, this list of conditions and the following disclaimer.
13 --
14 --   * Redistributions in binary form must reproduce the above copyright
15 --     notice, this list of conditions and the following disclaimer in
16 --     the documentation and/or other materials provided with the
17 --     distribution.
18 --
19 --   * Neither the name of Sebastian Bergmann nor the names of his
20 --     contributors may be used to endorse or promote products derived
21 --     from this software without specific prior written permission.
22 --
23 -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 -- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 -- COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 -- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 -- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 -- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 -- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 -- POSSIBILITY OF SUCH DAMAGE.
35 --
36
37 --
38
39 CREATE TABLE IF NOT EXISTS run(
40   run_id      INTEGER PRIMARY KEY AUTOINCREMENT,
41   timestamp   INTEGER,
42   revision    INTEGER,
43   information STRING,
44   completed   INTEGER DEFAULT 0
45 );
46
47 CREATE TABLE IF NOT EXISTS test(
48   run_id              INTEGER,
49   test_id             INTEGER PRIMARY KEY AUTOINCREMENT,
50   test_name           TEXT,
51   test_result         INTEGER DEFAULT 0,
52   test_message        TEXT    DEFAULT "",
53   test_execution_time REAL    DEFAULT 0,
54   code_method_id      INTEGER,
55   node_root           INTEGER,
56   node_left           INTEGER,
57   node_right          INTEGER,
58   node_is_leaf        INTEGER DEFAULT 0
59 );
60
61 CREATE INDEX IF NOT EXISTS test_run_id         ON test (run_id);
62 CREATE INDEX IF NOT EXISTS test_result         ON test (test_result);
63 CREATE INDEX IF NOT EXISTS test_code_method_id ON test (code_method_id);
64 CREATE INDEX IF NOT EXISTS test_node_root      ON test (node_root);
65 CREATE INDEX IF NOT EXISTS test_node_left      ON test (node_left);
66 CREATE INDEX IF NOT EXISTS test_node_right     ON test (node_right);
67
68 CREATE TABLE IF NOT EXISTS code_file(
69   code_file_id   INTEGER PRIMARY KEY AUTOINCREMENT,
70   code_file_name TEXT,
71   code_file_md5  TEXT,
72   revision       INTEGER
73 );
74
75 CREATE TABLE IF NOT EXISTS code_function(
76   code_file_id             INTEGER,
77   code_function_id         INTEGER PRIMARY KEY AUTOINCREMENT,
78   code_function_name       TEXT,
79   code_function_start_line INTEGER,
80   code_function_end_line   INTEGER
81 );
82
83 CREATE INDEX IF NOT EXISTS code_file_id ON code_function (code_file_id);
84
85 CREATE TABLE IF NOT EXISTS code_class(
86   code_file_id          INTEGER,
87   code_class_id         INTEGER PRIMARY KEY AUTOINCREMENT,
88   code_class_parent_id  INTEGER,
89   code_class_name       TEXT,
90   code_class_start_line INTEGER,
91   code_class_end_line   INTEGER
92 );
93
94 CREATE INDEX IF NOT EXISTS code_file_id ON code_class (code_file_id);
95
96 CREATE TABLE IF NOT EXISTS code_method(
97   code_class_id          INTEGER,
98   code_method_id         INTEGER PRIMARY KEY AUTOINCREMENT,
99   code_method_name       TEXT,
100   code_method_start_line INTEGER,
101   code_method_end_line   INTEGER
102 );
103
104 CREATE INDEX IF NOT EXISTS code_class_id ON code_method (code_class_id);
105
106 CREATE TABLE IF NOT EXISTS code_line(
107   code_file_id      INTEGER,
108   code_line_id      INTEGER PRIMARY KEY AUTOINCREMENT,
109   code_line_number  INTEGER,
110   code_line         TEXT,
111   code_line_covered INTEGER
112 );
113
114 CREATE INDEX IF NOT EXISTS code_line_code_file_id ON code_line (code_file_id);
115
116 CREATE TABLE IF NOT EXISTS code_coverage(
117   test_id      INTEGER,
118   code_line_id INTEGER
119 );
120
121 CREATE UNIQUE INDEX IF NOT EXISTS code_coverage_test_id_code_line_id ON code_coverage (test_id, code_line_id);
122
123 CREATE TABLE IF NOT EXISTS metrics_project(
124   run_id                  INTEGER,
125   metrics_project_cls     INTEGER,
126   metrics_project_clsa    INTEGER,
127   metrics_project_clsc    INTEGER,
128   metrics_project_roots   INTEGER,
129   metrics_project_leafs   INTEGER,
130   metrics_project_interfs INTEGER,
131   metrics_project_maxdit  INTEGER
132 );
133
134 CREATE INDEX IF NOT EXISTS run_id ON metrics_project (run_id);
135
136 CREATE TABLE IF NOT EXISTS metrics_file(
137   run_id                      INTEGER,
138   code_file_id                INTEGER,
139   metrics_file_coverage       REAL,
140   metrics_file_loc            INTEGER,
141   metrics_file_cloc           INTEGER,
142   metrics_file_ncloc          INTEGER,
143   metrics_file_loc_executable INTEGER,
144   metrics_file_loc_executed   INTEGER
145 );
146
147 CREATE INDEX IF NOT EXISTS run_id ON metrics_file (run_id);
148 CREATE INDEX IF NOT EXISTS code_file_id ON metrics_file (code_file_id);
149
150 CREATE TABLE IF NOT EXISTS metrics_function(
151   run_id                          INTEGER,
152   code_function_id                INTEGER,
153   metrics_function_coverage       REAL,
154   metrics_function_loc            INTEGER,
155   metrics_function_loc_executable INTEGER,
156   metrics_function_loc_executed   INTEGER,
157   metrics_function_ccn            INTEGER,
158   metrics_function_crap           REAL,
159   metrics_function_npath          INTEGER
160 );
161
162 CREATE INDEX IF NOT EXISTS run_id ON metrics_function (run_id);
163 CREATE INDEX IF NOT EXISTS code_function_id ON metrics_function (code_function_id);
164
165 CREATE TABLE IF NOT EXISTS metrics_class(
166   run_id                       INTEGER,
167   code_class_id                INTEGER,
168   metrics_class_coverage       REAL,
169   metrics_class_loc            INTEGER,
170   metrics_class_loc_executable INTEGER,
171   metrics_class_loc_executed   INTEGER,
172   metrics_class_aif            REAL,
173   metrics_class_ahf            REAL,
174   metrics_class_cis            INTEGER,
175   metrics_class_csz            INTEGER,
176   metrics_class_dit            INTEGER,
177   metrics_class_impl           INTEGER,
178   metrics_class_mif            REAL,
179   metrics_class_mhf            REAL,
180   metrics_class_noc            INTEGER,
181   metrics_class_pf             REAL,
182   metrics_class_vars           INTEGER,
183   metrics_class_varsnp         INTEGER,
184   metrics_class_varsi          INTEGER,
185   metrics_class_wmc            INTEGER,
186   metrics_class_wmcnp          INTEGER,
187   metrics_class_wmci           INTEGER
188 );
189
190 CREATE INDEX IF NOT EXISTS run_id ON metrics_class (run_id);
191 CREATE INDEX IF NOT EXISTS code_class_id ON metrics_class (code_class_id);
192
193 CREATE TABLE IF NOT EXISTS metrics_method(
194   run_id                        INTEGER,
195   code_method_id                INTEGER,
196   metrics_method_coverage       REAL,
197   metrics_method_loc            INTEGER,
198   metrics_method_loc_executable INTEGER,
199   metrics_method_loc_executed   INTEGER,
200   metrics_method_ccn            INTEGER,
201   metrics_method_crap           REAL,
202   metrics_method_npath          INTEGER
203 );
204
205 CREATE INDEX IF NOT EXISTS run_id ON metrics_method (run_id);
206 CREATE INDEX IF NOT EXISTS code_method_id ON metrics_method (code_method_id);