Simplify test
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 30 Aug 2023 02:01:24 +0000 (14:01 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 30 Aug 2023 03:21:06 +0000 (15:21 +1200)
tests/phpunit/CRM/Utils/TokenConsistencyTest.php

index d33bb0a979fea581017d7178848855a3689532c8..fffd067a545be1eaf389e905ee80ba1345dcf54c 100644 (file)
@@ -1070,28 +1070,14 @@ United States', $tokenProcessor->getRow(0)->render('message'));
   }
 
   public function testEscaping(): void {
-    $autoClean = [];
-    $create = function(string $entity, array $record = []) use (&$autoClean) {
-      // It's convenient to use createTestObject(), but it doesn't reproduce the normal escaping rules from QuickForm/APIv3/APIv4.
-      CRM_Utils_API_HTMLInputCoder::singleton()->encodeRow($record);
-      $dao = CRM_Core_DAO::createTestObject(CRM_Core_DAO_AllCoreTables::getFullName($entity), $record);
-
-      // We're not using transactions, and truncating 'contact' seems problematic, so we roll up our sleeves and cleanup each record...
-      $autoClean[] = CRM_Utils_AutoClean::with(function() use ($entity, $dao) {
-        CRM_Core_DAO::deleteTestObjects(CRM_Core_DAO_AllCoreTables::getFullName($entity), ['id' => $dao->id]);
-      });
-
-      return $dao;
-    };
-
     $context = [];
-    $context['contactId'] = $create('Contact', [
+    $context['contactId'] = $this->individualCreate([
       'first_name' => '<b>ig</b>illy brackets',
-    ])->id;
-    $context['eventId'] = $create('Event', [
+    ]);
+    $context['eventId'] = $this->eventCreateUnpaid([
       'title' => 'The Webinar',
       'description' => '<p>Some online webinar thingy.</p> <p>Attendees will need to install the <a href="http://telefoo.example.com">TeleFoo</a> app.</p>',
-    ])->id;
+    ])['id'];
 
     $messages = $expected = [];