additional fixes
[civicrm-core.git] / Civi / Test / Data.php
CommitLineData
728bbd5b
TO
1<?php
2namespace Civi\Test;
3
4use RuntimeException;
5
6/**
7 * Class Data
8 */
9class Data {
10
11 /**
12 * @return bool
13 */
14 public function populate() {
15 \Civi\Test::schema()->truncateAll();
16
17 \Civi\Test::schema()->setStrict(FALSE);
18 $sqlDir = dirname(dirname(__DIR__)) . "/sql";
19
20 $query2 = file_get_contents("$sqlDir/civicrm_data.mysql");
21 $query3 = file_get_contents("$sqlDir/test_data.mysql");
22 $query4 = file_get_contents("$sqlDir/test_data_second_domain.mysql");
23 if (\Civi\Test::execute($query2) === FALSE) {
24 throw new RuntimeException("Cannot load civicrm_data.mysql. Aborting.");
25 }
26 if (\Civi\Test::execute($query3) === FALSE) {
27 throw new RuntimeException("Cannot load test_data.mysql. Aborting.");
28 }
29 if (\Civi\Test::execute($query4) === FALSE) {
30 throw new RuntimeException("Cannot load test_data.mysql. Aborting.");
31 }
32
33 unset($query, $query2, $query3);
34
35 \Civi\Test::schema()->setStrict(TRUE);
36
37 // Rebuild triggers
38 civicrm_api('system', 'flush', array('version' => 3, 'triggers' => 1));
39
40 \CRM_Core_BAO_ConfigSetting::setEnabledComponents(array(
41 'CiviEvent',
42 'CiviContribute',
43 'CiviMember',
44 'CiviMail',
45 'CiviReport',
46 'CiviPledge',
47 ));
48
49 return TRUE;
50 }
51
52}