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