Skip to content

Commit

Permalink
Merge pull request #11626 from seamuslee001/multilingual_log_test_fix
Browse files Browse the repository at this point in the history
(NFC) Fix logging test for multilingual on MySQL5.7
  • Loading branch information
eileenmcnaughton authored Feb 4, 2018
2 parents c5f527d + 14e47fc commit 07101de
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions tests/phpunit/CRM/Logging/LoggingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function tearDown() {
CRM_Core_I18n_Schema::makeSinglelingual('en_US');
$logging = new CRM_Logging_Schema();
$logging->dropAllLogTables();
\Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = array();
parent::tearDown();
}

Expand All @@ -40,15 +41,26 @@ public function testMultilingualAlterSchemaLogging() {
$logging->enableLogging();
$value = CRM_Core_DAO::singleValueQuery("SELECT id FROM log_civicrm_contact LIMIT 1", array(), FALSE, FALSE);
$this->assertNotNull($value, 'Logging not enabled successfully');
$logging->disableLogging();
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_option_value` ADD COLUMN `logging_test` INT DEFAULT NULL", array(), FALSE, NULL, FALSE, FALSE);
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_option_value` ADD COLUMN `logging_test` INT DEFAULT '0'", array(), FALSE, NULL, FALSE, FALSE);
CRM_Core_I18n_Schema::rebuildMultilingualSchema(array('en_US'));
$logging->enableLogging();
\Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = array();
$logging->fixSchemaDifferencesFor('civicrm_option_value', array(), TRUE);
$query = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE `log_civicrm_option_value`", array(), TRUE, NULL, FALSE, FALSE);
$query->fetch();
$query->free();
$create = explode("\n", $query->Create_Table);
$this->assertTrue(in_array(" `logging_test` int(11) DEFAULT '0'", $create));
$create = explode("\n", $query->Create_Table);
CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_option_value` DROP COLUMN `logging_test`", array(), FALSE, NULL, FALSE, FALSE);
$this->assertTrue(in_array(" `logging_test` int(11) DEFAULT NULL", $create));
$query = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE `log_civicrm_option_value`", array(), TRUE, NULL, FALSE, FALSE);
$query->fetch();
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
\Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = array();
CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales);
$logging->fixSchemaDifferencesFor('civicrm_option_value', array(), TRUE);
$this->assertTrue(in_array(" `logging_test` int(11) DEFAULT '0'", $create));
$logging->disableLogging();
}

Expand Down

0 comments on commit 07101de

Please sign in to comment.