14 public function populate() {
15 \Civi\Test
::asPreInstall(function() {
16 \Civi\Test
::schema()->truncateAll();
18 \Civi\Test
::schema()->setStrict(FALSE);
20 // Ensure that when we populate the database it is done in utf8 mode
21 \Civi\Test
::execute('SET NAMES utf8mb4');
22 $sqlDir = dirname(dirname(__DIR__
)) . "/sql";
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');
29 $query2 = \Civi\Test
::$statics['locale_data']["civicrm_data.mysql"];
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.");
35 if (\Civi\Test
::execute($query3) === FALSE) {
36 throw new RuntimeException("Cannot load test_data.mysql. Aborting.");
38 if (\Civi\Test
::execute($query4) === FALSE) {
39 throw new RuntimeException("Cannot load test_data.mysql. Aborting.");
42 unset($query, $query2, $query3);
44 \Civi\Test
::schema()->setStrict(TRUE);
47 civicrm_api('setting', 'create', ['installed' => 1, 'domain_id' => 'all', 'version' => 3]);
50 civicrm_api('system', 'flush', ['version' => 3, 'triggers' => 1]);
52 \CRM_Core_BAO_ConfigSetting
::setEnabledComponents([