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() { | |
9d114ab6 TO |
15 | \Civi\Test::asPreInstall(function() { |
16 | \Civi\Test::schema()->truncateAll(); | |
17 | ||
18 | \Civi\Test::schema()->setStrict(FALSE); | |
19 | ||
20 | // Ensure that when we populate the database it is done in utf8 mode | |
d10ba6cb | 21 | \Civi\Test::execute('SET NAMES utf8mb4'); |
9d114ab6 TO |
22 | $sqlDir = dirname(dirname(__DIR__)) . "/sql"; |
23 | ||
c0d84418 TO |
24 | if (!isset(\Civi\Test::$statics['locale_data'])) { |
25 | $schema = new \CRM_Core_CodeGen_Schema(\Civi\Test::codeGen()); | |
26 | \Civi\Test::$statics['locale_data'] = $schema->generateLocaleDataSql('en_US'); | |
27 | } | |
28 | ||
29 | $query2 = \Civi\Test::$statics['locale_data']["civicrm_data.mysql"]; | |
9d114ab6 TO |
30 | $query3 = file_get_contents("$sqlDir/test_data.mysql"); |
31 | $query4 = file_get_contents("$sqlDir/test_data_second_domain.mysql"); | |
32 | if (\Civi\Test::execute($query2) === FALSE) { | |
33 | throw new RuntimeException("Cannot load civicrm_data.mysql. Aborting."); | |
34 | } | |
35 | if (\Civi\Test::execute($query3) === FALSE) { | |
36 | throw new RuntimeException("Cannot load test_data.mysql. Aborting."); | |
37 | } | |
38 | if (\Civi\Test::execute($query4) === FALSE) { | |
39 | throw new RuntimeException("Cannot load test_data.mysql. Aborting."); | |
40 | } | |
41 | ||
42 | unset($query, $query2, $query3); | |
43 | ||
44 | \Civi\Test::schema()->setStrict(TRUE); | |
45 | }); | |
728bbd5b | 46 | |
d071a643 SL |
47 | civicrm_api('setting', 'create', ['installed' => 1, 'domain_id' => 'all', 'version' => 3]); |
48 | ||
728bbd5b | 49 | // Rebuild triggers |
c64f69d9 | 50 | civicrm_api('system', 'flush', ['version' => 3, 'triggers' => 1]); |
728bbd5b | 51 | |
c64f69d9 | 52 | \CRM_Core_BAO_ConfigSetting::setEnabledComponents([ |
728bbd5b TO |
53 | 'CiviEvent', |
54 | 'CiviContribute', | |
55 | 'CiviMember', | |
56 | 'CiviMail', | |
57 | 'CiviReport', | |
58 | 'CiviPledge', | |
c64f69d9 | 59 | ]); |
728bbd5b TO |
60 | |
61 | return TRUE; | |
62 | } | |
63 | ||
64 | } |