]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/PHPUnit/Util/Log/Database/MySQL.sql
Added unit tests.
[Github/sugarcrm.git] / tests / PHPUnit / Util / Log / Database / MySQL.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 UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
41   timestamp   INTEGER UNSIGNED NOT NULL,
42   revision    INTEGER UNSIGNED NOT NULL,
43   information TEXT             NOT NULL,
44   completed   BOOLEAN          NOT NULL DEFAULT 0
45 ) ENGINE=InnoDB;
46
47 CREATE TABLE IF NOT EXISTS test(
48   run_id              INTEGER UNSIGNED NOT NULL REFERENCES run.run_id,
49   test_id             INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
50   test_name           CHAR(128)        NOT NULL,
51   test_result         TINYINT UNSIGNED NOT NULL DEFAULT 0,
52   test_message        TEXT             NOT NULL DEFAULT "",
53   test_execution_time FLOAT   UNSIGNED NOT NULL DEFAULT 0,
54   code_method_id      INTEGER UNSIGNED          REFERENCES code_method.code_method_id,
55   node_root           INTEGER UNSIGNED NOT NULL,
56   node_left           INTEGER UNSIGNED NOT NULL,
57   node_right          INTEGER UNSIGNED NOT NULL,
58   node_is_leaf        BOOLEAN          NOT NULL DEFAULT 0,
59
60   INDEX (run_id),
61   INDEX (test_result),
62   INDEX (code_method_id),
63   INDEX (node_root),
64   INDEX (node_left),
65   INDEX (node_right)
66 ) ENGINE=InnoDB;
67
68 CREATE TABLE IF NOT EXISTS code_file(
69   code_file_id   INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
70   code_file_name CHAR(255),
71   code_file_md5  CHAR(32),
72   revision       INTEGER UNSIGNED NOT NULL
73 ) ENGINE=InnoDB;
74
75 CREATE TABLE IF NOT EXISTS code_function(
76   code_file_id             INTEGER UNSIGNED NOT NULL REFERENCES code_file.code_file_id,
77   code_function_id         INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
78   code_function_name       CHAR(255),
79   code_function_start_line INTEGER UNSIGNED NOT NULL,
80   code_function_end_line   INTEGER UNSIGNED NOT NULL,
81
82   INDEX (code_file_id)
83 ) ENGINE=InnoDB;
84
85 CREATE TABLE IF NOT EXISTS code_class(
86   code_file_id          INTEGER UNSIGNED NOT NULL REFERENCES code_file.code_file_id,
87   code_class_id         INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
88   code_class_parent_id  INTEGER UNSIGNED REFERENCES code_class.code_class_id,
89   code_class_name       CHAR(255),
90   code_class_start_line INTEGER UNSIGNED NOT NULL,
91   code_class_end_line   INTEGER UNSIGNED NOT NULL,
92
93   INDEX (code_file_id)
94 ) ENGINE=InnoDB;
95
96 CREATE TABLE IF NOT EXISTS code_method(
97   code_class_id          INTEGER UNSIGNED NOT NULL REFERENCES code_class.code_class_id,
98   code_method_id         INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
99   code_method_name       CHAR(255),
100   code_method_start_line INTEGER UNSIGNED NOT NULL,
101   code_method_end_line   INTEGER UNSIGNED NOT NULL,
102
103   INDEX (code_class_id)
104 ) ENGINE=InnoDB;
105
106 CREATE TABLE IF NOT EXISTS code_line(
107   code_file_id      INTEGER UNSIGNED NOT NULL REFERENCES code_file.code_file_id,
108   code_line_id      INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
109   code_line_number  INTEGER UNSIGNED NOT NULL,
110   code_line         TEXT,
111   code_line_covered TINYINT          NOT NULL,
112
113   INDEX (code_file_id)
114 ) ENGINE=InnoDB;
115
116 CREATE TABLE IF NOT EXISTS code_coverage(
117   test_id      INTEGER UNSIGNED NOT NULL REFERENCES test.test_id,
118   code_line_id INTEGER UNSIGNED NOT NULL REFERENCES code_line.code_line_id,
119
120   PRIMARY KEY (test_id, code_line_id)
121 ) ENGINE=InnoDB;
122
123 CREATE TABLE IF NOT EXISTS metrics_project(
124   run_id                  INTEGER UNSIGNED NOT NULL,
125   metrics_project_cls     INTEGER UNSIGNED NOT NULL,
126   metrics_project_clsa    INTEGER UNSIGNED NOT NULL,
127   metrics_project_clsc    INTEGER UNSIGNED NOT NULL,
128   metrics_project_roots   INTEGER UNSIGNED NOT NULL,
129   metrics_project_leafs   INTEGER UNSIGNED NOT NULL,
130   metrics_project_interfs INTEGER UNSIGNED NOT NULL,
131   metrics_project_maxdit  INTEGER UNSIGNED NOT NULL,
132
133   INDEX (run_id)
134 ) ENGINE=InnoDB;
135
136 CREATE TABLE IF NOT EXISTS metrics_file(
137   run_id                      INTEGER UNSIGNED NOT NULL,
138   code_file_id                INTEGER UNSIGNED NOT NULL REFERENCES code_file.code_file_id,
139   metrics_file_coverage       FLOAT   UNSIGNED NOT NULL,
140   metrics_file_loc            INTEGER UNSIGNED NOT NULL,
141   metrics_file_cloc           INTEGER UNSIGNED NOT NULL,
142   metrics_file_ncloc          INTEGER UNSIGNED NOT NULL,
143   metrics_file_loc_executable INTEGER UNSIGNED NOT NULL,
144   metrics_file_loc_executed   INTEGER UNSIGNED NOT NULL,
145
146   INDEX (run_id),
147   INDEX (code_file_id)
148 ) ENGINE=InnoDB;
149
150 CREATE TABLE IF NOT EXISTS metrics_function(
151   run_id                          INTEGER UNSIGNED NOT NULL,
152   code_function_id                INTEGER UNSIGNED NOT NULL REFERENCES code_method.code_function_id,
153   metrics_function_coverage       FLOAT   UNSIGNED NOT NULL,
154   metrics_function_loc            INTEGER UNSIGNED NOT NULL,
155   metrics_function_loc_executable INTEGER UNSIGNED NOT NULL,
156   metrics_function_loc_executed   INTEGER UNSIGNED NOT NULL,
157   metrics_function_ccn            INTEGER UNSIGNED NOT NULL,
158   metrics_function_crap           FLOAT   UNSIGNED NOT NULL,
159   metrics_function_npath          INTEGER UNSIGNED NOT NULL,
160
161   INDEX (run_id),
162   INDEX (code_function_id)
163 ) ENGINE=InnoDB;
164
165 CREATE TABLE IF NOT EXISTS metrics_class(
166   run_id                       INTEGER UNSIGNED NOT NULL,
167   code_class_id                INTEGER UNSIGNED NOT NULL REFERENCES code_class.code_class_id,
168   metrics_class_coverage       FLOAT   UNSIGNED NOT NULL,
169   metrics_class_loc            INTEGER UNSIGNED NOT NULL,
170   metrics_class_loc_executable INTEGER UNSIGNED NOT NULL,
171   metrics_class_loc_executed   INTEGER UNSIGNED NOT NULL,
172   metrics_class_aif            FLOAT   UNSIGNED NOT NULL,
173   metrics_class_ahf            FLOAT   UNSIGNED NOT NULL,
174   metrics_class_cis            INTEGER UNSIGNED NOT NULL,
175   metrics_class_csz            INTEGER UNSIGNED NOT NULL,
176   metrics_class_dit            INTEGER UNSIGNED NOT NULL,
177   metrics_class_impl           INTEGER UNSIGNED NOT NULL,
178   metrics_class_mif            FLOAT   UNSIGNED NOT NULL,
179   metrics_class_mhf            FLOAT   UNSIGNED NOT NULL,
180   metrics_class_noc            INTEGER UNSIGNED NOT NULL,
181   metrics_class_pf             FLOAT   UNSIGNED NOT NULL,
182   metrics_class_vars           INTEGER UNSIGNED NOT NULL,
183   metrics_class_varsnp         INTEGER UNSIGNED NOT NULL,
184   metrics_class_varsi          INTEGER UNSIGNED NOT NULL,
185   metrics_class_wmc            INTEGER UNSIGNED NOT NULL,
186   metrics_class_wmcnp          INTEGER UNSIGNED NOT NULL,
187   metrics_class_wmci           INTEGER UNSIGNED NOT NULL,
188
189   INDEX (run_id),
190   INDEX (code_class_id)
191 ) ENGINE=InnoDB;
192
193 CREATE TABLE IF NOT EXISTS metrics_method(
194   run_id                        INTEGER UNSIGNED NOT NULL,
195   code_method_id                INTEGER UNSIGNED NOT NULL REFERENCES code_method.code_method_id,
196   metrics_method_coverage       FLOAT   UNSIGNED NOT NULL,
197   metrics_method_loc            INTEGER UNSIGNED NOT NULL,
198   metrics_method_loc_executable INTEGER UNSIGNED NOT NULL,
199   metrics_method_loc_executed   INTEGER UNSIGNED NOT NULL,
200   metrics_method_ccn            INTEGER UNSIGNED NOT NULL,
201   metrics_method_crap           FLOAT   UNSIGNED NOT NULL,
202   metrics_method_npath          INTEGER UNSIGNED NOT NULL,
203
204   INDEX (run_id),
205   INDEX (code_method_id)
206 ) ENGINE=InnoDB;