From f143b24586eb3aac3ccb74ef98e9ed3a361ab72f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 25 Jan 2020 08:32:43 +1100 Subject: [PATCH] Update Export unit test to pass on MySQL 8 --- tests/phpunit/CRM/Export/BAO/ExportTest.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index f2495690df..5bc0f2d342 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -1151,7 +1151,11 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { 'Tag(s)' => '', 'Note(s)' => '', ]; - $this->assertExpectedOutput($expected, $this->csv->fetchOne()); + // Include both possible options as we rely on implicit order here and MySQL 8 in testing is returning a different value for some fields. + $this->assertExpectedOutput($expected, $this->csv->fetchOne(), [ + 'Email' => ['home@example.com', 'work@example.com'], + 'Location Type' => ['Home', 'Work'], + ]); } /** @@ -2924,13 +2928,17 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase { * * @param array $expected * @param array $row + * @param array $alternatives */ - protected function assertExpectedOutput(array $expected, array $row) { + protected function assertExpectedOutput(array $expected, array $row, array $alternatives = []) { $variableFields = ['Created Date', 'Modified Date', 'Contact Hash']; foreach ($expected as $key => $value) { if (in_array($key, $variableFields)) { $this->assertTrue(!empty($row[$key])); } + elseif (array_key_exists($key, $alternatives)) { + $this->assertContains($row[$key], $alternatives[$key]); + } else { $this->assertEquals($value, $row[$key]); } -- 2.25.1