Newer
Older
<?php
/**
* @file
* Database additions for language tests. Used in upgrade.language.test.
*
* This dump only contains data and schema components relevant for language
* functionality. The drupal-7.filled.database.php file is imported before
* this dump, so the two form the database structure expected in tests
* altogether.
*/
// Add blocks respective for language functionality.
db_delete('block')
->condition('module', 'locale')
->execute();
db_insert('block')->fields(array(
'module',
'delta',
'theme',
'status',
'weight',
'region',
'custom',
'visibility',
'pages',
'title',
'cache',
))
->values(array(
'module' => 'locale',
'delta' => 'language',
'theme' => 'bartik',
'status' => '1',
'region' => 'sidebar_first',
'custom' => '0',
'visibility' => '0',
'pages' => '',
'title' => '',
'cache' => '-1',
))
->values(array(
'module' => 'locale',
'delta' => 'language',
'theme' => 'seven',
'status' => '0',
'weight' => '0',
'region' => '-1',
'custom' => '0',
'visibility' => '0',
'pages' => '',
'title' => '',
'cache' => '-1',
))
->execute();
// Prefill languages table from locale.install with some default languages
// for testing.
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
db_insert('languages')->fields(array(
'language',
'name',
'native',
'direction',
'enabled',
'plurals',
'formula',
'domain',
'prefix',
'weight',
'javascript',
))
->values(array(
'language' => 'ca',
'name' => 'Catalan',
'native' => 'Català',
'direction' => '0',
'enabled' => '1',
'plurals' => '2',
'formula' => '($n>1)',
'domain' => '',
'prefix' => 'ca',
'weight' => '0',
'javascript' => '',
))
->values(array(
'language' => 'cv',
'name' => 'Chuvash',
'native' => 'Chuvash',
'direction' => '0',
'enabled' => '1',
'plurals' => '0',
'formula' => '',
'domain' => '',
'prefix' => 'cv',
'weight' => '0',
'javascript' => '',
))
Dries Buytaert
committed
->values(array(
'language' => 'hr',
'name' => 'Croatian',
'native' => 'Hrvatski',
'direction' => '0',
'enabled' => '1',
'plurals' => '3',
'formula' => '((($n%10)==1)&&(($n%100)!=11))?(0):((((($n%10)>=2)&&(($n%10)<=4))&&((($n%100)<10)||(($n%100)>=20)))?(1):2));',
'domain' => '',
'prefix' => '',
'weight' => '0',
'javascript' => '',
))
// Fill locales_source table from locale.install schema with some sample data
// for testing.
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
db_insert('locales_source')->fields(array(
'lid',
'location',
'textgroup',
'source',
'context',
'version',
))
->values(array(
'lid' => '1',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'An AJAX HTTP error occurred.',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '2',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'HTTP Result Code: !status',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '3',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'An AJAX HTTP request terminated abnormally.',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '4',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'Debugging information follows.',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '5',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'Path: !uri',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '6',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'StatusText: !statusText',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '7',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'ResponseText: !responseText',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '8',
'location' => 'misc/drupal.js',
'textgroup' => 'default',
'source' => 'ReadyState: !readyState',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '9',
'location' => 'modules/overlay/overlay-parent.js',
'textgroup' => 'default',
'source' => '@title dialog',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '10',
'location' => 'modules/contextual/contextual.js',
'textgroup' => 'default',
'source' => 'Configure',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '11',
'location' => 'modules/toolbar/toolbar.js',
'textgroup' => 'default',
'source' => 'Show shortcuts',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '12',
'location' => 'modules/toolbar/toolbar.js',
'textgroup' => 'default',
'source' => 'Hide shortcuts',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '13',
'location' => 'modules/overlay/overlay-child.js',
'textgroup' => 'default',
'source' => 'Loading',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '14',
'location' => 'modules/overlay/overlay-child.js',
'textgroup' => 'default',
'source' => '(active tab)',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '15',
'location' => 'misc/tabledrag.js',
'textgroup' => 'default',
'source' => 'Re-order rows by numerical weight instead of dragging.',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '16',
'location' => 'misc/tabledrag.js',
'textgroup' => 'default',
'source' => 'Show row weights',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '17',
'location' => 'misc/tabledrag.js',
'textgroup' => 'default',
'source' => 'Hide row weights',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '18',
'location' => 'misc/tabledrag.js',
'textgroup' => 'default',
'source' => 'Drag to re-order',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '19',
'location' => 'misc/tabledrag.js',
'textgroup' => 'default',
'source' => 'Changes made in this table will not be saved until the form is submitted.',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '20',
'location' => 'misc/collapse.js',
'textgroup' => 'default',
'source' => 'Hide',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '21',
'location' => 'misc/collapse.js',
'textgroup' => 'default',
'source' => 'Show',
'context' => '',
'version' => 'none',
))
Dries Buytaert
committed
->values(array(
'lid' => '22',
'location' => '',
'textgroup' => 'default',
'source' => '1 byte',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '23',
'location' => '',
'textgroup' => 'default',
'source' => '@count bytes',
'context' => '',
'version' => 'none',
))
->values(array(
'lid' => '24',
'location' => '',
'textgroup' => 'default',
'source' => '@count[2] bytes',
'context' => '',
'version' => 'none',
))
// Fill locales_target table from locale.install schema with some sample data
// for testing.
Dries Buytaert
committed
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
db_insert('locales_target')->fields(array(
'lid',
'translation',
'language',
'plid',
'plural',
))
->values(array(
'lid' => 22,
'translation' => '1 byte',
'language' => 'ca',
'plid' => 0,
'plural' => 0,
))
->values(array(
'lid' => 23,
'translation' => '@count bytes',
'language' => 'ca',
'plid' => 22,
'plural' => 1,
))
->values(array(
'lid' => 22,
'translation' => '@count bajt',
'language' => 'hr',
'plid' => 0,
'plural' => 0,
))
->values(array(
'lid' => 23,
'translation' => '@count bajta',
'language' => 'hr',
'plid' => 22,
'plural' => 1,
))
->values(array(
'lid' => 24,
'translation' => '@count[2] bajtova',
'language' => 'hr',
'plid' => 23,
'plural' => 2,
))
->execute();
// Set up variables needed for language support.
$deleted_variables = array(
'javascript_parsed',
'language_count',
'language_default',
'language_negotiation_language',
'language_negotiation_language_content',
'language_negotiation_language_url',
'language_types',
'locale_language_providers_weight_language',
'language_content_type_article',
);
db_delete('variable')
->condition('name', $deleted_variables, 'IN')
->execute();
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
db_insert('variable')->fields(array(
'name',
'value',
))
->values(array(
'name' => 'javascript_parsed',
'value' => 'a:16:{i:0;s:14:"misc/drupal.js";i:1;s:14:"misc/jquery.js";i:2;s:19:"misc/jquery.once.js";s:10:"refresh:ca";s:7:"waiting";i:3;s:29:"misc/ui/jquery.ui.core.min.js";i:4;s:21:"misc/jquery.ba-bbq.js";i:5;s:33:"modules/overlay/overlay-parent.js";i:6;s:32:"modules/contextual/contextual.js";i:7;s:21:"misc/jquery.cookie.js";i:8;s:26:"modules/toolbar/toolbar.js";i:9;s:32:"modules/overlay/overlay-child.js";i:10;s:19:"misc/tableheader.js";i:11;s:17:"misc/tabledrag.js";i:12;s:12:"misc/form.js";i:13;s:16:"misc/collapse.js";s:10:"refresh:cv";s:7:"waiting";}',
))
->values(array(
'name' => 'language_count',
'value' => 'i:3;',
))
->values(array(
'name' => 'language_default',
'value' => 'O:8:"stdClass":7:{s:8:"langcode";s:2:"ca";s:4:"name";s:7:"Catalan";s:9:"direction";i:0;s:7:"enabled";b:1;s:6:"weight";i:0;s:7:"default";b:1;s:6:"is_new";b:1;}',
))
->values(array(
'name' => 'language_negotiation_language',
'value' => 'a:5:{s:10:"locale-url";a:2:{s:9:"callbacks";a:3:{s:8:"language";s:24:"locale_language_from_url";s:8:"switcher";s:28:"locale_language_switcher_url";s:11:"url_rewrite";s:31:"locale_language_url_rewrite_url";}s:4:"file";s:19:"includes/locale.inc";}s:14:"locale-session";a:2:{s:9:"callbacks";a:3:{s:8:"language";s:28:"locale_language_from_session";s:8:"switcher";s:32:"locale_language_switcher_session";s:11:"url_rewrite";s:35:"locale_language_url_rewrite_session";}s:4:"file";s:19:"includes/locale.inc";}s:11:"locale-user";a:2:{s:9:"callbacks";a:1:{s:8:"language";s:25:"locale_language_from_user";}s:4:"file";s:19:"includes/locale.inc";}s:14:"locale-browser";a:3:{s:9:"callbacks";a:1:{s:8:"language";s:28:"locale_language_from_browser";}s:4:"file";s:19:"includes/locale.inc";s:5:"cache";i:0;}s:16:"language-default";a:1:{s:9:"callbacks";a:1:{s:8:"language";s:21:"language_from_default";}}}',
))
->values(array(
'name' => 'language_negotiation_language_content',
'value' => 'a:1:{s:16:"locale-interface";a:2:{s:9:"callbacks";a:1:{s:8:"language";s:30:"locale_language_from_interface";}s:4:"file";s:19:"includes/locale.inc";}}',
))
->values(array(
'name' => 'language_negotiation_language_url',
'value' => 'a:2:{s:10:"locale-url";a:2:{s:9:"callbacks";a:3:{s:8:"language";s:24:"locale_language_from_url";s:8:"switcher";s:28:"locale_language_switcher_url";s:11:"url_rewrite";s:31:"locale_language_url_rewrite_url";}s:4:"file";s:19:"includes/locale.inc";}s:19:"locale-url-fallback";a:2:{s:9:"callbacks";a:1:{s:8:"language";s:28:"locale_language_url_fallback";}s:4:"file";s:19:"includes/locale.inc";}}',
))
->values(array(
'name' => 'language_types',
'value' => 'a:3:{s:8:"language";b:1;s:16:"language_content";b:0;s:12:"language_url";b:0;}',
))
->values(array(
'name' => 'locale_language_providers_weight_language',
'value' => 'a:5:{s:10:"locale-url";s:2:"-8";s:14:"locale-session";s:2:"-6";s:11:"locale-user";s:2:"-4";s:14:"locale-browser";s:2:"-2";s:16:"language-default";s:2:"10";}',
))
Dries Buytaert
committed
->values(array(
'name' => 'language_content_type_article',
'value' => 's:1:"2";',
Dries Buytaert
committed
))
// Add sample nodes to test language assignment and translation functionality.
// The first node is also used for testing comment language functionality. This
// is a simple node with LANGUAGE_NOT_SPECIFIED as language code. The second
// node is a Catalan node (language code 'ca'). The third and fourth node are a
// translation set with an English source translation (language code 'en') and
// a Chuvash translation (language code 'cv').
Dries Buytaert
committed
db_insert('node')->fields(array(
'nid',
'vid',
'type',
'language',
'title',
'uid',
'status',
'created',
'changed',
'comment',
'promote',
'sticky',
'tnid',
'translate',
))
->values(array(
Dries Buytaert
committed
'nid' => '50',
'vid' => '70',
Dries Buytaert
committed
'type' => 'article',
'language' => 'und',
Dries Buytaert
committed
'title' => 'Node title 50',
Dries Buytaert
committed
'uid' => '6',
'status' => '1',
'created' => '1263769200',
'changed' => '1314997642',
'comment' => '2',
'promote' => '0',
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
))
->values(array(
Dries Buytaert
committed
'nid' => '51',
'vid' => '75',
'type' => 'article',
'language' => 'ca',
Dries Buytaert
committed
'title' => 'Node title 51',
'uid' => '6',
'status' => '1',
'created' => '1263769300',
'changed' => '1263769300',
'comment' => '0',
'promote' => '0',
'sticky' => '0',
'tnid' => '0',
'translate' => '0',
))
->values(array(
Dries Buytaert
committed
'nid' => '52',
'vid' => '80',
'type' => 'article',
'language' => 'en',
Dries Buytaert
committed
'title' => 'Node title 52',
'uid' => '6',
'status' => '1',
'created' => '1263769534',
'changed' => '1263769534',
'comment' => '0',
'promote' => '0',
'sticky' => '0',
Dries Buytaert
committed
'tnid' => '52',
'translate' => '0',
))
->values(array(
Dries Buytaert
committed
'nid' => '53',
'vid' => '85',
'type' => 'article',
'language' => 'cv',
Dries Buytaert
committed
'title' => 'Node title 53',
'uid' => '6',
'status' => '1',
'created' => '1263770064',
'changed' => '1263770064',
'comment' => '0',
'promote' => '0',
'sticky' => '0',
Dries Buytaert
committed
'tnid' => '52',
'translate' => '0',
))
Dries Buytaert
committed
->execute();
// Add node comment statistics for the first node.
Dries Buytaert
committed
db_insert('node_comment_statistics')->fields(array(
'nid',
'cid',
'last_comment_timestamp',
'last_comment_name',
'last_comment_uid',
'comment_count',
))
->values(array(
Dries Buytaert
committed
'nid' => '50',
Dries Buytaert
committed
'cid' => '0',
'last_comment_timestamp' => '1314997642',
'last_comment_name' => NULL,
'last_comment_uid' => '6',
'comment_count' => '1',
))
->execute();
// Add node revision information.
db_insert('node_revision')->fields(array(
'nid',
'vid',
'uid',
'title',
'log',
'timestamp',
'status',
'comment',
'promote',
'sticky',
))
->values(array(
Dries Buytaert
committed
'nid' => '50',
'vid' => '70',
Dries Buytaert
committed
'uid' => '6',
Dries Buytaert
committed
'title' => 'Node title 50',
'log' => 'Added a LANGUAGE_NOT_SPECIFIED node to comment on.',
Dries Buytaert
committed
'timestamp' => '1314997642',
'status' => '1',
'comment' => '2',
'promote' => '0',
'sticky' => '0',
))
->values(array(
Dries Buytaert
committed
'nid' => '51',
'vid' => '75',
'uid' => '6',
Dries Buytaert
committed
'title' => 'Node title 51',
'log' => 'Created a Catalan node.',
'timestamp' => '1263769300',
'status' => '1',
'comment' => '0',
'promote' => '0',
'sticky' => '0',
))
->values(array(
Dries Buytaert
committed
'nid' => '52',
'vid' => '80',
'uid' => '6',
Dries Buytaert
committed
'title' => 'Node title 52',
'log' => 'Created source translation in English.',
'timestamp' => '1263769534',
'status' => '1',
'comment' => '0',
'promote' => '0',
'sticky' => '0',
))
->values(array(
Dries Buytaert
committed
'nid' => '53',
'vid' => '85',
'uid' => '6',
Dries Buytaert
committed
'title' => 'Node title 53',
'log' => 'Created Chuvash translation.',
'timestamp' => '1263770064',
'status' => '1',
'comment' => '0',
'promote' => '0',
'sticky' => '0',
))
Dries Buytaert
committed
->execute();
// Add the body field value.
db_insert('field_data_body')->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'body_value',
'body_summary',
'body_format',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
Dries Buytaert
committed
'entity_id' => '50',
'revision_id' => '70',
Dries Buytaert
committed
'language' => 'und',
'delta' => '0',
'body_value' => 'Node body',
'body_summary' => 'Node body',
'body_format' => 'filtered_html',
))
->execute();
// Add revision information for the body field value.
db_insert('field_revision_body')->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'body_value',
'body_summary',
'body_format',
))
->values(array(
'entity_type' => 'node',
'bundle' => 'article',
'deleted' => '0',
Dries Buytaert
committed
'entity_id' => '50',
'revision_id' => '70',
Dries Buytaert
committed
'language' => 'und',
'delta' => '0',
'body_value' => 'Node body',
'body_summary' => 'Node body',
'body_format' => 'filtered_html',
))
->execute();
// Add two comments to the first node in a thread.
Dries Buytaert
committed
db_insert('comment')->fields(array(
'cid',
'pid',
'nid',
'uid',
'subject',
'hostname',
'created',
'changed',
'status',
'thread',
'name',
'mail',
'homepage',
'language',
))
->values(array(
'cid' => '1',
'pid' => '0',
Dries Buytaert
committed
'nid' => '50',
Dries Buytaert
committed
'uid' => '6',
'subject' => 'First test comment',
'hostname' => '127.0.0.1',
'created' => '1314997642',
'changed' => '1314997642',
'status' => '1',
'thread' => '01/',
'name' => 'test user 4',
'mail' => '',
'homepage' => '',
'language' => 'und',
))
->values(array(
'cid' => '2',
'pid' => '0',
Dries Buytaert
committed
'nid' => '50',
Dries Buytaert
committed
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
'uid' => '6',
'subject' => 'Reply to first test comment',
'hostname' => '127.0.0.1',
'created' => '1314997642',
'changed' => '1314997642',
'status' => '1',
'thread' => '01.00/',
'name' => 'test user 4',
'mail' => '',
'homepage' => '',
'language' => 'und',
))
->execute();
// Add both comment bodies.
db_insert('field_data_comment_body')->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'comment_body_value',
'comment_body_format',
))
->values(array(
'entity_type' => 'comment',
'bundle' => 'comment_node_article',
'deleted' => '0',
'entity_id' => '1',
'revision_id' => '1',
'language' => 'und',
'delta' => '0',
'comment_body_value' => 'Comment body',
'comment_body_format' => 'filtered_html',
))
->values(array(
'entity_type' => 'comment',
'bundle' => 'comment_node_article',
'deleted' => '0',
'entity_id' => '2',
'revision_id' => '2',
'language' => 'und',
'delta' => '0',
'comment_body_value' => 'Second comment body',
'comment_body_format' => 'filtered_html',
))
->execute();
// Add revisions for comment bodies.
db_insert('field_revision_comment_body')->fields(array(
'entity_type',
'bundle',
'deleted',
'entity_id',
'revision_id',
'language',
'delta',
'comment_body_value',
'comment_body_format',
))
->values(array(
'entity_type' => 'comment',
'bundle' => 'comment_node_article',
'deleted' => '0',
'entity_id' => '1',
'revision_id' => '1',
'language' => 'und',
'delta' => '0',
'comment_body_value' => 'Comment body',
'comment_body_format' => 'filtered_html',
))
->values(array(
'entity_type' => 'comment',
'bundle' => 'comment_node_article',
'deleted' => '0',
'entity_id' => '2',
'revision_id' => '2',
'language' => 'und',
'delta' => '0',
'comment_body_value' => 'Second comment body',
'comment_body_format' => 'filtered_html',
))
->execute();
// Add a managed file.
db_insert('file_managed')->fields(array(
'fid',
'uid',
'filename',
'uri',
'filemime',
'filesize',
'status',
'timestamp'
))
->values(array(
'fid' => '1',
'uid' => '1',
'filename' => 'foo.txt',
'uri' => 'public://foo.txt',
'filemime' => 'text/plain',
'filesize' => 0,
'status' => 1,
'timestamp' => '1314997642',
))
->execute();