From 483fe558e3f72c4375ea399586321ca1797075f2 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 28 Aug 2024 17:08:25 -0700 Subject: [PATCH] ActivityTest - Update to pass on Standalone Before ------ If you run this test on Standalone, it fails: like so ``` CRM_Activity_BAO_ActivityTest::testSendEmailWillReplaceTokensUniquelyForEachContact3 Exception: CRM_Core_Exception: "rename(/home/homer/buildkit/build/build-1/web/public/custom/test_email_create.txt, /home/homer/buildkit/build/build-1/web/private/attachment//test_email_create.txt): No such file or directory" #0 /home/homer/buildkit/build/build-1/web/core/CRM/Contact/Form/Task/EmailTrait.php(867): civicrm_api3("Activity", "create", (Array:9)) #1 /home/homer/buildkit/build/build-1/web/core/CRM/Contact/Form/Task/EmailTrait.php(788): CRM_Contact_Form_Task_Email->createEmailActivity(6, "subject:Mr. Joe Red II", "html:Mr. Joe Red II", "text:Mr. Joe Red II {$contact.first_name}", "", 1, (Array:1), NULL) ... After ----- Passes Comments -------- I believe this makes standalone behave the same way as Drupal. However, the underlying scenario is a bit weird -- it seems that `rename()` puts the file into the same place where it already is. Which is weird. If the purpose is to create an example file and put it through the same paces as day-to-day workflows, then you'd probably need to put the sample file somewhere else (like sys_get_temp_dir()). --- tests/phpunit/CRM/Activity/BAO/ActivityTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 46a114b720b7..abc5e6c8fa87 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -1713,7 +1713,7 @@ public function testSendEmailWillReplaceTokensUniquelyForEachContact3(): void { // Check the smarty doesn't mess stuff up. $text = 'text:' . '{contact.display_name} {$contact.first_name}'; - $filepath = Civi::paths()->getPath('[civicrm.files]/custom'); + $filepath = CRM_Core_Config::singleton()->customFileUploadDir; $fileName = 'test_email_create.txt'; $fileUri = "{$filepath}/{$fileName}"; // Create a file. @@ -1778,7 +1778,7 @@ public function testSendEmailDoesNotDuplicateAttachmentFileIDsForActivitiesCreat $html = __FUNCTION__ . ' html'; $text = __FUNCTION__ . ' text'; - $filepath = Civi::paths()->getPath('[civicrm.files]/custom'); + $filepath = CRM_Core_Config::singleton()->customFileUploadDir; $fileName = 'test_email_create.txt'; $fileUri = "{$filepath}/{$fileName}"; // Create a file.