Replace deprecated RegExp PHPUnit functions
authorlarssandergreen <lars@wildsight.ca>
Thu, 24 Aug 2023 16:31:03 +0000 (10:31 -0600)
committerlarssandergreen <lars@wildsight.ca>
Thu, 24 Aug 2023 16:31:03 +0000 (10:31 -0600)
54 files changed:
ext/afform/mock/ang/mockPublicForm.test.php
ext/afform/mock/tests/phpunit/api/v4/AfformContactUsageTest.php
ext/afform/mock/tests/phpunit/api/v4/AfformRoutingTest.php
ext/authx/tests/phpunit/Civi/Authx/AllFlowsTest.php
ext/flexmailer/tests/phpunit/Civi/FlexMailer/ValidatorTest.php
ext/oauth-client/tests/phpunit/api/v4/OAuthClientGrantTest.php
ext/oauth-client/tests/phpunit/api/v4/OAuthClientTest.php
mixin/menu-xml@1/example/tests/mixin/MenuXmlTest.php
tests/events/civi_region_render.evch.php
tests/events/hook_civicrm_alterMailParams.evch.php
tests/phpunit/CRM/Contact/BAO/ContactTest.php
tests/phpunit/CRM/Contribute/Form/Contribution/ConfirmTest.php
tests/phpunit/CRM/Contribute/Form/ContributionViewTest.php
tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php
tests/phpunit/CRM/Core/ComposerConfigTest.php
tests/phpunit/CRM/Core/ErrorTest.php
tests/phpunit/CRM/Core/InvokeTest.php
tests/phpunit/CRM/Extension/ManagerTest.php
tests/phpunit/CRM/Logging/SchemaTest.php
tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php
tests/phpunit/CRM/Mailing/MailingSystemTest.php
tests/phpunit/CRM/Mailing/TokensTest.php
tests/phpunit/CRM/Queue/QueueTest.php
tests/phpunit/CRM/Upgrade/SnapshotTest.php
tests/phpunit/CRM/Utils/HttpClientTest.php
tests/phpunit/CRM/Utils/SQL/SelectTest.php
tests/phpunit/CRM/Utils/SQLTest.php
tests/phpunit/CRM/Utils/StringTest.php
tests/phpunit/CRM/Utils/TokenConsistencyTest.php
tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php
tests/phpunit/Civi/API/Subscriber/WhitelistSubscriberTest.php
tests/phpunit/Civi/ActionSchedule/AbstractMappingTest.php
tests/phpunit/Civi/Angular/ManagerTest.php
tests/phpunit/Civi/Core/CiviEventDispatcherTest.php
tests/phpunit/Civi/Crypto/CryptoJwtTest.php
tests/phpunit/Civi/Crypto/CryptoRegistryTest.php
tests/phpunit/Civi/Crypto/CryptoTokenTest.php
tests/phpunit/Civi/Payment/PropertyBagTest.php
tests/phpunit/Civi/Pipe/JsonRpcSessionTest.php
tests/phpunit/Civi/Schema/MagicGetterSetterTest.php
tests/phpunit/Civi/Test/ExampleHookTest.php
tests/phpunit/Civi/Test/ExampleSubscriberTest.php
tests/phpunit/E2E/Core/AssetBuilderTest.php
tests/phpunit/E2E/Core/PathUrlTest.php
tests/phpunit/api/v3/AttachmentTest.php
tests/phpunit/api/v3/CaseTest.php
tests/phpunit/api/v3/ContactTest.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/MailingTest.php
tests/phpunit/api/v3/SyntaxConformanceTest.php
tests/phpunit/api/v4/Action/ContactGetTest.php
tests/phpunit/api/v4/Entity/ConformanceTest.php
tests/phpunit/api/v4/Entity/TranslationTest.php
tests/phpunit/api/v4/Entity/ValidateValuesTest.php

index 0eff06c8299d05a3b6911f41a0f3354ce9f2c066..0fc9bf674f839e2a6ef6164389135a0bfff31592 100644 (file)
@@ -76,7 +76,7 @@ class MockPublicFormTest extends \Civi\AfformMock\FormTestCase {
       $this->fail('Plain text message did not have URL in expected place: ' . $text);
     }
     $url = $m[1];
-    $this->assertRegExp(';^https?:.*civicrm/mock-public-form.*;', $url, "URL should look plausible");
+    $this->assertMatchesRegularExpression(';^https?:.*civicrm/mock-public-form.*;', $url, "URL should look plausible");
 
     // Going to this page will cause us to authenticate as the target contact
     $http = $this->createGuzzle(['http_errors' => FALSE, 'cookies' => new \GuzzleHttp\Cookie\CookieJar()]);
@@ -102,7 +102,7 @@ class MockPublicFormTest extends \Civi\AfformMock\FormTestCase {
       $this->fail('HTML message did not have URL in expected place: ' . $html);
     }
     $url = html_entity_decode($m[1]);
-    $this->assertRegExp(';^https?:.*civicrm/mock-public-form.*;', $url, "URL should look plausible");
+    $this->assertMatchesRegularExpression(';^https?:.*civicrm/mock-public-form.*;', $url, "URL should look plausible");
 
     // Going to this page will cause us to authenticate as the target contact
     $http = $this->createGuzzle(['cookies' => new \GuzzleHttp\Cookie\CookieJar()]);
@@ -126,7 +126,7 @@ class MockPublicFormTest extends \Civi\AfformMock\FormTestCase {
     $this->assertEquals(1, $doc->find('a')->count(), 'Document should have hyperlink');
     foreach ($doc->find('a') as $item) {
       /** @var \DOMElement $item */
-      $this->assertRegExp(';^https?:.*civicrm/mock-public-form.*;', $item->getAttribute('href'));
+      $this->assertMatchesRegularExpression(';^https?:.*civicrm/mock-public-form.*;', $item->getAttribute('href'));
       $this->assertEquals('My public form', $item->firstChild->data);
       $url = $item->getAttribute('href');
     }
index 33245f63c92fedaf53aa6a2cf3409f5e890f46d7..2792c1e5937dbbfb696d90b1ec3a9b86c72d2479 100644 (file)
@@ -90,7 +90,7 @@ EOHTML;
       ->execute()
       ->indexBy('name');
     $this->assertEquals('Logged In', $prefill['me']['values'][0]['fields']['first_name']);
-    $this->assertRegExp('/^User/', $prefill['me']['values'][0]['fields']['last_name']);
+    $this->assertMatchesRegularExpression('/^User/', $prefill['me']['values'][0]['fields']['last_name']);
 
     $submission = [
       ['fields' => ['first_name' => 'Firsty', 'last_name' => 'Lasty']],
index 00eb9ef4019b2be8ee491d17d9bd2ecd83d24934..9e609605c6e3b25c50366f5e576123414bfabbc4 100644 (file)
@@ -81,8 +81,8 @@ class api_v4_AfformRoutingTest extends \PHPUnit\Framework\TestCase implements \C
   private function assertNotAuthorized(Psr\Http\Message\ResponseInterface $result, $directive) {
     $contents = $result->getBody()->getContents();
     $this->assertEquals(403, $result->getStatusCode());
-    $this->assertRegExp(';You are not authorized to access;', $contents);
-    $this->assertNotRegExp(';' . preg_quote("<$directive>", ';') . ';', $contents);
+    $this->assertMatchesRegularExpression(';You are not authorized to access;', $contents);
+    $this->assertDoesNotMatchRegularExpression(';' . preg_quote("<$directive>", ';') . ';', $contents);
   }
 
   /**
@@ -93,8 +93,8 @@ class api_v4_AfformRoutingTest extends \PHPUnit\Framework\TestCase implements \C
   private function assertOpensPage(Psr\Http\Message\ResponseInterface $result, $directive) {
     $contents = $result->getBody()->getContents();
     $this->assertEquals(200, $result->getStatusCode());
-    $this->assertNotRegExp(';You are not authorized to access;', $contents);
-    $this->assertRegExp(';' . preg_quote("<$directive>", ';') . ';', $contents);
+    $this->assertDoesNotMatchRegularExpression(';You are not authorized to access;', $contents);
+    $this->assertMatchesRegularExpression(';' . preg_quote("<$directive>", ';') . ';', $contents);
   }
 
 }
index 0afa38b43303d0801af8315a4eab16f54cf0794c..f02d9872113dcb1170d9c2c56017135a6c970204 100644 (file)
@@ -608,7 +608,7 @@ class AllFlowsTest extends \PHPUnit\Framework\TestCase implements EndToEndInterf
       $loginArgs = ['principal' => [$principalField => $principalValue]];
       $report = $withCv(sprintf('try { return authx_login(%s); } catch (Exception $e) { return [get_class($e), $e->getMessage()]; }', var_export($loginArgs, 1)));
       $this->assertTrue(isset($report[0], $report[1]), "authx_login() should fail with invalid credentials ($principalField=>$principalValue). Received array: " . json_encode($report));
-      $this->assertRegExp($expectExceptionMessage, $report[1], "Invalid principal ($principalField=>$principalValue) should generate exception.");
+      $this->assertMatchesRegularExpression($expectExceptionMessage, $report[1], "Invalid principal ($principalField=>$principalValue) should generate exception.");
       $this->assertEquals($expectExceptionClass, $report[0], "Invalid principal ($principalField=>$principalValue) should generate exception.");
     }
   }
@@ -636,7 +636,7 @@ class AllFlowsTest extends \PHPUnit\Framework\TestCase implements EndToEndInterf
       $this->fail('Untrusted sessions should require authentication credentials');
     }
     catch (JsonRpcMethodException $e) {
-      $this->assertRegExp(';not trusted;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';not trusted;', $e->getMessage());
     }
 
     $login = $rpc->call('login', ['cred' => $this->credJwt($this->getDemoCID())]);
index 58e81083096e8b59bdbed0645fdbc13c064fc241..a0bd66b3d40f80a4089f543f9ea312aa3bf59fba 100644 (file)
@@ -91,7 +91,7 @@ class ValidatorTest extends \CiviUnitTestCase {
       array_keys($expectedErrors)
     );
     foreach ($expectedErrors as $key => $pat) {
-      $this->assertRegExp($pat, $actualErrors[$key], "Error for \"$key\" should match pattern");
+      $this->assertMatchesRegularExpression($pat, $actualErrors[$key], "Error for \"$key\" should match pattern");
     }
   }
 
index f33bf1cf0bec8ae9c880e77eb879bfb81774c367..923084a9b6b69f95bb8edb6166827bea12727210 100644 (file)
@@ -48,11 +48,11 @@ class api_v4_OAuthClientGrantTest extends \PHPUnit\Framework\TestCase implements
       $this->assertEquals('/one/auth', $url['path']);
       \parse_str($url['query'], $actualQuery);
       $this->assertEquals('code', $actualQuery['response_type']);
-      $this->assertRegExp(';^[cs]_[a-zA-Z0-9]+$;', $actualQuery['state']);
+      $this->assertMatchesRegularExpression(';^[cs]_[a-zA-Z0-9]+$;', $actualQuery['state']);
       $this->assertEquals('scope-1-foo,scope-1-bar', $actualQuery['scope']);
       // ? // $this->assertEquals('auto', $actualQuery['approval_prompt']);
       $this->assertEquals('example-id', $actualQuery['client_id']);
-      $this->assertRegExp(';civicrm/oauth-client/return;', $actualQuery['redirect_uri']);
+      $this->assertMatchesRegularExpression(';civicrm/oauth-client/return;', $actualQuery['redirect_uri']);
     }
   }
 
index b9186dac99d78b61be8e6c9cdd007d39b2a63dab..47a1a823746442d6d06066dc082bb196cee777ef 100644 (file)
@@ -79,7 +79,7 @@ class api_v4_OAuthClientTest extends \PHPUnit\Framework\TestCase implements Head
       $this->fail("Expected exception: invalid provider");
     }
     catch (CRM_Core_Exception $e) {
-      $this->assertRegExp(';Invalid provider;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Invalid provider;', $e->getMessage());
     }
   }
 
@@ -105,7 +105,7 @@ class api_v4_OAuthClientTest extends \PHPUnit\Framework\TestCase implements Head
       $this->fail("Expected exception: invalid provider");
     }
     catch (CRM_Core_Exception $e) {
-      $this->assertRegExp(';Invalid provider;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Invalid provider;', $e->getMessage());
     }
 
     Civi\Api4\OAuthClient::update()
index c3878c946b68063ab35e17534c1dbdec8a55f502..4e50f8b0abf77839539b03cf26e027c2e67b7305 100644 (file)
@@ -31,7 +31,7 @@ class MenuXmlTest extends \PHPUnit\Framework\Assert {
     $this->url = cv('url civicrm/shimmy/foobar');
     $this->assertTrue(is_string($this->url));
     $response = file_get_contents($this->url);
-    $this->assertRegExp(';hello world;', $response);
+    $this->assertMatchesRegularExpression(';hello world;', $response);
   }
 
   public function testDisabled($cv): void {
@@ -40,8 +40,8 @@ class MenuXmlTest extends \PHPUnit\Framework\Assert {
 
     $this->assertNotEmpty($this->url);
     $response = file_get_contents($this->url, FALSE, stream_context_create(['http' => ['ignore_errors' => TRUE]]));
-    $this->assertNotRegExp(';hello world;', $response);
-    $this->assertNotRegExp(';HTTP.*200.*;', $http_response_header[0]);
+    $this->assertDoesNotMatchRegularExpression(';hello world;', $response);
+    $this->assertDoesNotMatchRegularExpression(';HTTP.*200.*;', $http_response_header[0]);
   }
 
   public function testUninstalled($cv): void {
index b374ff64078d9c4d1f45de5e66ef6069e99eee70..be3706b0ff7053d6a60e32641b48a61607f8e65f 100644 (file)
@@ -24,7 +24,7 @@ return new class() extends \Civi\Test\EventCheck implements \Civi\Test\HookInter
     $this->assertTrue($e->region instanceof \CRM_Core_Region);
     /** @var \CRM_Core_Region $region */
     $region = $e->region;
-    $this->assertRegexp($this->validRegion, $region->_name);
+    $this->assertMatchesRegularExpression($this->validRegion, $region->_name);
     foreach ($region->getAll() as $snippet) {
       $this->assertContains($snippet['type'], $this->validSnippetTypes);
     }
index c41e9ee78aac6f81af6e1c730fce1f98cd86cd98..b15476b3ef6462aeddfb31fe61f171a014017ecf 100644 (file)
@@ -107,7 +107,7 @@ return new class() extends EventCheck implements HookInterface {
     $msg = 'Non-conforming hook_civicrm_alterMailParams(..., $context)';
     $dump = print_r($params, 1);
 
-    $this->assertRegExp('/^(messageTemplate|civimail|singleEmail|flexmailer)$/',
+    $this->assertMatchesRegularExpression('/^(messageTemplate|civimail|singleEmail|flexmailer)$/',
       $context, "$msg: Unrecognized context ($context)\n$dump");
 
     $contexts = [$context];
@@ -131,7 +131,7 @@ return new class() extends EventCheck implements HookInterface {
         $this->assertType($paramSpecs[$key]['type'], $value, "$msg: Bad data-type found in param ($key)\n$dump");
       }
       if (isset($paramSpecs[$key]['regex']) && $value !== NULL) {
-        $this->assertRegExp($paramSpecs[$key]['regex'], $value, "Parameter [$key => $value] should match regex ({$paramSpecs[$key]['regex']})");
+        $this->assertMatchesRegularExpression($paramSpecs[$key]['regex'], $value, "Parameter [$key => $value] should match regex ({$paramSpecs[$key]['regex']})");
       }
     }
 
index 3919933b847c85babb6af7de9f970b0657c8d558..d323b5c7bebebe59e07e66383ce9c90d8f365894 100644 (file)
@@ -1431,8 +1431,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
     $contactId = $this->individualCreate();
 
     $origTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId);
-    $this->assertRegexp('/^\d\d\d\d-\d\d-\d\d /', $origTimestamps['created_date']);
-    $this->assertRegexp('/^\d\d\d\d-\d\d-\d\d /', $origTimestamps['modified_date']);
+    $this->assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d /', $origTimestamps['created_date']);
+    $this->assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d /', $origTimestamps['modified_date']);
     $this->assertTrue($origTimestamps['created_date'] <= $origTimestamps['modified_date']);
 
     $prevTimestamps = $origTimestamps;
@@ -1442,8 +1442,8 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
 
       $callback($contactId);
       $newTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId);
-      $this->assertRegexp('/^\d\d\d\d-\d\d-\d\d /', $newTimestamps['created_date'], "Malformed created_date (after $callbackName)");
-      $this->assertRegexp('/^\d\d\d\d-\d\d-\d\d /', $newTimestamps['modified_date'], "Malformed modified_date (after $callbackName)");
+      $this->assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d /', $newTimestamps['created_date'], "Malformed created_date (after $callbackName)");
+      $this->assertMatchesRegularExpression('/^\d\d\d\d-\d\d-\d\d /', $newTimestamps['modified_date'], "Malformed modified_date (after $callbackName)");
       $this->assertEquals($origTimestamps['created_date'], $newTimestamps['created_date'], "Changed created_date (after $callbackName)");
       $this->assertTrue($prevTimestamps['modified_date'] < $newTimestamps['modified_date'], "Misordered modified_date (after $callbackName)");
 
index e52ef44d9f4a37c96aee0db4b381d06371e21bd5..f0569f2c2791cf3e376fed10c72cb6d536a2251b 100644 (file)
@@ -126,7 +126,7 @@ class CRM_Contribute_Form_Contribution_ConfirmTest extends CiviUnitTestCase {
     // check that contribution page ID isn't changed
     $this->assertEquals($contributionPageID1, $contribution['contribution_page_id']);
     // check that paid later information is present in contribution's source
-    $this->assertRegExp("/Paid later via page ID: $contributionPageID2/", $contribution['contribution_source']);
+    $this->assertMatchesRegularExpression("/Paid later via page ID: $contributionPageID2/", $contribution['contribution_source']);
     // check that contribution status is changed to 'Completed' from 'Pending'
     $this->assertEquals('Completed', $contribution['contribution_status']);
 
index 811c1379699a51570f233851f30948843cf14760..d95c0e255f5b59f818e6af25b991f8b910bb6507 100644 (file)
@@ -71,7 +71,7 @@ class CRM_Contribute_Form_ContributionViewTest extends CiviUnitTestCase {
     unset($_GET['id'], $_REQUEST['id']);
     unset($_GET['cid'], $_REQUEST['cid']);
 
-    $this->assertRegExp('/Contribution Total:\s+\$10\.00/', $contents);
+    $this->assertMatchesRegularExpression('/Contribution Total:\s+\$10\.00/', $contents);
     $this->assertStringContainsString('Mr. Anthony Anderson II', $contents);
   }
 
index ea2b3599136fba0896bf5ec22a0d4581901cc12d..8c004fab2262684d0a538fa3adaf41abcfd5c1f9 100644 (file)
@@ -1053,7 +1053,7 @@ class CRM_Core_BAO_ActionScheduleTest extends CiviUnitTestCase {
       }
 
       foreach ($patterns as $field => $pattern) {
-        $this->assertRegExp($pattern, $messageArray[$field],
+        $this->assertMatchesRegularExpression($pattern, $messageArray[$field],
           "Check that '$field'' matches regex. " . print_r(['expected' => $patterns, 'actual' => $messageArray], 1));
       }
     }
index 1e822a96b9ae65afc188f1b0bd0e520329909884..f6e22ba58ff72a931e317a1e1a8bc742e0ce63fb 100644 (file)
@@ -34,7 +34,7 @@ class CRM_Core_ComposerConfigTest extends \PHPUnit\Framework\TestCase {
 
     foreach ($lock['packages'] as $package) {
       if (isset($hardLocks[$package['name']])) {
-        $this->assertRegExp($hardLocks[$package['name']], $package['version'],
+        $this->assertMatchesRegularExpression($hardLocks[$package['name']], $package['version'],
           "Check hardlock for " . $package['name']);
         unset($hardLocks[$package['name']]);
       }
index 57287a7359ecbcc5a2d8972683a628c58d2086cf..9670c855d0d5a43b5faab9c586f63080b14a95d8 100644 (file)
@@ -92,7 +92,7 @@ class CRM_Core_ErrorTest extends CiviUnitTestCase {
     $logFiles = glob($config->configAndLogDir . '/CiviCRM*.log');
     $this->assertEquals(1, count($logFiles), 'Expect to find 1 file matching: ' . $config->configAndLogDir . '/CiviCRM*log*/');
     foreach ($logFiles as $logFile) {
-      $this->assertRegexp($pattern, file_get_contents($logFile));
+      $this->assertMatchesRegularExpression($pattern, file_get_contents($logFile));
     }
   }
 
index 914ecba2551a374fa1e8712713d965e9b34901a8..abef23388391faaa1f5988a71ba708d225a51fa7 100644 (file)
@@ -62,7 +62,7 @@ class CRM_Core_InvokeTest extends CiviUnitTestCase {
     $contents = ob_get_clean();
 
     unset($_GET['reset']);
-    $this->assertRegExp('/form.+id="Builder" class="CRM_Contact_Form_Search_Builder/', $contents);
+    $this->assertMatchesRegularExpression('/form.+id="Builder" class="CRM_Contact_Form_Search_Builder/', $contents);
   }
 
   public function testContactSummary(): void {
index 89d3508790e5e4f205d1c5f5d619d44abb1700fb..362d9413a33510645b003178ab0a2d50180457bd 100644 (file)
@@ -204,7 +204,7 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase {
       $this->fail('Expected disable to fail due to dependency');
     }
     catch (CRM_Extension_Exception $e) {
-      $this->assertRegExp('/test.foo.downstream/', $e->getMessage());
+      $this->assertMatchesRegularExpression('/test.foo.downstream/', $e->getMessage());
     }
 
     // Status unchanged
index 2eeb95e0ace3be023a06359b7dd12abb0f11f0cf..769fbd89fadd13b4ef9557f9d000b963d4c86dd5 100644 (file)
@@ -59,7 +59,7 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase {
     Civi::settings()->set('logging', TRUE);
     $log_table = CRM_Core_DAO::executeQuery('SHOW CREATE TABLE log_civicrm_acl');
     while ($log_table->fetch()) {
-      $this->assertRegexp('/ENGINE=InnoDB/', $log_table->Create_Table);
+      $this->assertMatchesRegularExpression('/ENGINE=InnoDB/', $log_table->Create_Table);
     }
   }
 
@@ -71,7 +71,7 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase {
     Civi::settings()->set('logging', TRUE);
     $log_table = CRM_Core_DAO::executeQuery('SHOW CREATE TABLE log_civicrm_acl');
     while ($log_table->fetch()) {
-      $this->assertRegexp('/ENGINE=MyISAM/', $log_table->Create_Table);
+      $this->assertMatchesRegularExpression('/ENGINE=MyISAM/', $log_table->Create_Table);
     }
   }
 
@@ -110,19 +110,19 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase {
     CRM_Core_DAO::executeQuery('ALTER TABLE log_civicrm_acl ENGINE ARCHIVE');
     $log_table = CRM_Core_DAO::executeQuery('SHOW CREATE TABLE log_civicrm_acl');
     while ($log_table->fetch()) {
-      $this->assertRegexp('/ENGINE=ARCHIVE/', $log_table->Create_Table);
+      $this->assertMatchesRegularExpression('/ENGINE=ARCHIVE/', $log_table->Create_Table);
     }
     // engine should not change by default
     $schema->updateLogTableSchema(['updateChangedEngineConfig' => FALSE, 'forceEngineMigration' => FALSE]);
     $log_table = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE log_civicrm_acl");
     while ($log_table->fetch()) {
-      $this->assertRegExp('/ENGINE=ARCHIVE/', $log_table->Create_Table);
+      $this->assertMatchesRegularExpression('/ENGINE=ARCHIVE/', $log_table->Create_Table);
     }
     // update with forceEngineMigration should convert to InnoDB
     $schema->updateLogTableSchema(['updateChangedEngineConfig' => FALSE, 'forceEngineMigration' => TRUE]);
     $log_table = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE log_civicrm_acl");
     while ($log_table->fetch()) {
-      $this->assertRegExp('/ENGINE=InnoDB/', $log_table->Create_Table);
+      $this->assertMatchesRegularExpression('/ENGINE=InnoDB/', $log_table->Create_Table);
     }
   }
 
@@ -423,8 +423,8 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase {
     $dao = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE civicrm_test_table");
     $dao->fetch();
     // using regex since not sure it's always int(10), so accept int(10), int(11), integer, etc...
-    $this->assertRegExp('/`id` int(.*) unsigned NOT NULL AUTO_INCREMENT/', $dao->Create_Table);
-    $this->assertRegExp('/`activity_id` int(.*) unsigned NOT NULL/', $dao->Create_Table);
+    $this->assertMatchesRegularExpression('/`id` int(.*) unsigned NOT NULL AUTO_INCREMENT/', $dao->Create_Table);
+    $this->assertMatchesRegularExpression('/`activity_id` int(.*) unsigned NOT NULL/', $dao->Create_Table);
     $this->assertStringContainsString('`texty` varchar(255)', $dao->Create_Table);
     $this->assertStringContainsString('ENGINE=InnoDB', $dao->Create_Table);
     $this->assertStringContainsString('FOREIGN KEY (`activity_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE CASCADE', $dao->Create_Table);
@@ -434,8 +434,8 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase {
     $dao->fetch();
     $this->assertStringNotContainsString('AUTO_INCREMENT', $dao->Create_Table);
     // This seems debatable whether `id` should lose its NOT NULL status
-    $this->assertRegExp('/`id` int(.*) unsigned DEFAULT NULL/', $dao->Create_Table);
-    $this->assertRegExp('/`activity_id` int(.*) unsigned DEFAULT NULL/', $dao->Create_Table);
+    $this->assertMatchesRegularExpression('/`id` int(.*) unsigned DEFAULT NULL/', $dao->Create_Table);
+    $this->assertMatchesRegularExpression('/`activity_id` int(.*) unsigned DEFAULT NULL/', $dao->Create_Table);
     $this->assertStringContainsString('`texty` varchar(255)', $dao->Create_Table);
     $this->assertStringContainsString('ENGINE=InnoDB', $dao->Create_Table);
     $this->assertStringNotContainsString('FOREIGN KEY', $dao->Create_Table);
index d4e74e96df24e2524e4574e27f57634cd9766539..0904541155c570f66922eae13e2ede7d766c2073 100644 (file)
@@ -82,10 +82,10 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase {
       $this->assertEquals("Mr. Foo{$offset} Anderson II", $message->to[0]->name);
       $this->assertEquals("mail{$offset}@nul.example.com", $message->to[0]->email);
 
-      $this->assertRegExp('#^text/plain; charset=utf-8#', $message->headers['Content-Type']);
-      $this->assertRegExp(';^b\.[\d\.a-f]+@chaos.org$;', $message->headers['Return-Path']);
-      $this->assertRegExp(';^b\.[\d\.a-f]+@chaos.org$;', $message->headers['X-CiviMail-Bounce'][0]);
-      $this->assertRegExp(';^\<mailto:u\.[\d\.a-f]+@chaos.org\>$;', $message->headers['List-Unsubscribe'][0]);
+      $this->assertMatchesRegularExpression('#^text/plain; charset=utf-8#', $message->headers['Content-Type']);
+      $this->assertMatchesRegularExpression(';^b\.[\d\.a-f]+@chaos.org$;', $message->headers['Return-Path']);
+      $this->assertMatchesRegularExpression(';^b\.[\d\.a-f]+@chaos.org$;', $message->headers['X-CiviMail-Bounce'][0]);
+      $this->assertMatchesRegularExpression(';^\<mailto:u\.[\d\.a-f]+@chaos.org\>$;', $message->headers['List-Unsubscribe'][0]);
       $this->assertEquals('bulk', $message->headers['Precedence'][0]);
     }
   }
@@ -107,7 +107,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase {
       $this->assertTrue($message->body instanceof ezcMailText);
 
       $this->assertEquals('plain', $message->body->subType);
-      $this->assertRegExp(
+      $this->assertMatchesRegularExpression(
         ";" .
         // Default header
         "Sample Header for TEXT formatted content.\n" .
@@ -140,7 +140,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase {
       [$textPart, $htmlPart] = $message->body->getParts();
 
       $this->assertEquals('html', $htmlPart->subType);
-      $this->assertRegExp(
+      $this->assertMatchesRegularExpression(
         ";" .
         // Default header
         "Sample Header for HTML formatted content.\n" .
@@ -156,7 +156,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase {
       );
 
       $this->assertEquals('plain', $textPart->subType);
-      $this->assertRegExp(
+      $this->assertMatchesRegularExpression(
         ";" .
         // Default header
         "Sample Header for TEXT formatted content.\n" .
@@ -197,7 +197,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase {
       [$textPart, $htmlPart] = $message->body->getParts();
 
       $this->assertEquals('html', $htmlPart->subType);
-      $this->assertRegExp(
+      $this->assertMatchesRegularExpression(
         ";" .
         // body_html
         "<p>You can go to <a href=['\"].*(extern/url.php|civicrm/mailing/url)(\?|&amp\\;)u=\d+&amp\\;qid=\d+['\"] rel='nofollow'>Google</a>" .
@@ -212,7 +212,7 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase {
       );
 
       $this->assertEquals('plain', $textPart->subType);
-      $this->assertRegExp(
+      $this->assertMatchesRegularExpression(
         ";" .
         //  body_html, filtered
         "You can go to Google \\[1\\] or opt out \\[2\\]\\.\n" .
@@ -342,13 +342,13 @@ abstract class CRM_Mailing_BaseMailingSystemTest extends CiviUnitTestCase {
       if ($htmlUrlRegex) {
         $caseName = print_r(['inputHtml' => $inputHtml, 'params' => $params, 'htmlUrlRegex' => $htmlUrlRegex, 'htmlPart' => $htmlPart->text], 1);
         $this->assertEquals('html', $htmlPart->subType, "Should have HTML part in case: $caseName");
-        $this->assertRegExp($htmlUrlRegex, $htmlPart->text, "Should have correct HTML in case: $caseName");
+        $this->assertMatchesRegularExpression($htmlUrlRegex, $htmlPart->text, "Should have correct HTML in case: $caseName");
       }
 
       if ($textUrlRegex) {
         $caseName = print_r(['inputHtml' => $inputHtml, 'params' => $params, 'textUrlRegex' => $textUrlRegex, 'textPart' => $textPart->text], 1);
         $this->assertEquals('plain', $textPart->subType, "Should have text part in case: $caseName");
-        $this->assertRegExp($textUrlRegex, $textPart->text, "Should have correct text in case: $caseName");
+        $this->assertMatchesRegularExpression($textUrlRegex, $textPart->text, "Should have correct text in case: $caseName");
       }
     }
   }
index d48267ccb5a06a093560a356a61ef2a00e5af5da..50e49d03739778fece3e995d1e884e5a7bc8de94 100644 (file)
@@ -92,8 +92,8 @@ class CRM_Mailing_MailingSystemTest extends CRM_Mailing_BaseMailingSystemTest {
 
     $result = $this->callAPISuccess('mailing', 'create', $params);
     $previewResult = $result['values'][$result['id']]['api.Mailing.preview'];
-    $this->assertRegexp('!>Forward this email written in ckeditor</a>!', $previewResult['values']['body_html']);
-    $this->assertRegexp('!<a href="([^"]+)civicrm/mailing/forward&amp;reset=1&amp;jid=&amp;qid=&amp;h=\w*">!', $previewResult['values']['body_html']);
+    $this->assertMatchesRegularExpression('!>Forward this email written in ckeditor</a>!', $previewResult['values']['body_html']);
+    $this->assertMatchesRegularExpression('!<a href="([^"]+)civicrm/mailing/forward&amp;reset=1&amp;jid=&amp;qid=&amp;h=\w*">!', $previewResult['values']['body_html']);
     $this->assertStringNotContainsString("http://http://", $previewResult['values']['body_html']);
   }
 
index 8734ee90ffe674ebd6b65e77f6193d0064408faa..7577ab70bd904457790a428c362a9a7f3efc5bb5 100644 (file)
@@ -59,7 +59,7 @@ class CRM_Mailing_TokensTest extends \CiviUnitTestCase {
     $p->evaluate();
     $count = 0;
     foreach ($p->getRows() as $row) {
-      $this->assertRegExp($expectRegex, $row->render('example'));
+      $this->assertMatchesRegularExpression($expectRegex, $row->render('example'));
       $count++;
     }
     $this->assertEquals(1, $count);
@@ -96,7 +96,7 @@ class CRM_Mailing_TokensTest extends \CiviUnitTestCase {
     $p->evaluate();
     $count = 0;
     foreach ($p->getRows() as $row) {
-      $this->assertRegExp($expectRegex, $row->render('example'));
+      $this->assertMatchesRegularExpression($expectRegex, $row->render('example'));
       $count++;
     }
     $this->assertEquals(1, $count);
@@ -138,14 +138,14 @@ class CRM_Mailing_TokensTest extends \CiviUnitTestCase {
     //      $this->fail('TokenProcessor::evaluate() should have thrown an exception');
     //    }
     //    catch (CRM_Core_Exception $e) {
-    //      $this->assertRegExp(';Cannot use action tokens unless context defines mailingJobId and mailingActionTarget;', $e->getMessage());
+    //      $this->assertMatchesRegularExpression(';Cannot use action tokens unless context defines mailingJobId and mailingActionTarget;', $e->getMessage());
     //    }
 
     $p->evaluate();
 
     // FIXME: For compatibility with
     $actual = $p->getRow(0)->render('example');
-    $this->assertRegExp($expectRegex, $actual);
+    $this->assertMatchesRegularExpression($expectRegex, $actual);
   }
 
 }
index 1ec3c33cd580a1b00d7dd3e9334b301ffe761118..89a3f4df69b3274c40441c3077dc26c8ec426ca7 100644 (file)
@@ -87,7 +87,7 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase {
       $this->fail('Should fail without error policy');
     }
     catch (CRM_Core_Exception $e) {
-      $this->assertRegExp('/Invalid error mode/', $e->getMessage());
+      $this->assertMatchesRegularExpression('/Invalid error mode/', $e->getMessage());
     }
 
     $q2 = Civi::queue('test/complete/2', [
@@ -386,7 +386,7 @@ class CRM_Queue_QueueTest extends CiviUnitTestCase {
       $this->fail('Queue lookup should fail. There is neither pre-existing registration nor new details.');
     }
     catch (CRM_Core_Exception $e) {
-      $this->assertRegExp(';Missing field "type";', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Missing field "type";', $e->getMessage());
     }
   }
 
index a5324a7fcc88ec1d97d3206ea82e11747dc8ce8a..be8ae6b371b008f2e5ba23279249ed72a4fec6ae 100644 (file)
@@ -33,14 +33,14 @@ class CRM_Upgrade_SnapshotTest extends CiviUnitTestCase {
       $this->fail('Accepted invalid name');
     }
     catch (CRM_Core_Exception $e) {
-      $this->assertRegExp('/Malformed snapshot name/', $e->getMessage());
+      $this->assertMatchesRegularExpression('/Malformed snapshot name/', $e->getMessage());
     }
     try {
       CRM_Upgrade_Snapshot::createTableName('civicrm', '5.45', 'long_table_name_that_is_too_long_for_the_validation');
       $this->fail('Accepted excessive name');
     }
     catch (CRM_Core_Exception $e) {
-      $this->assertRegExp('/Snapshot name is too long/', $e->getMessage());
+      $this->assertMatchesRegularExpression('/Snapshot name is too long/', $e->getMessage());
     }
   }
 
index 70a128d840acf3d330d80c54938830d3bc21d707..225169c37916b723cb4d1ce8cdc05a34045b826b 100644 (file)
@@ -47,13 +47,13 @@ class CRM_Utils_HttpClientTest extends CiviUnitTestCase {
   public function testFetchHttp() {
     $result = $this->client->fetch(self::VALID_HTTP_URL, $this->tmpFile);
     $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $result);
-    $this->assertRegExp(self::VALID_HTTP_REGEX, file_get_contents($this->tmpFile));
+    $this->assertMatchesRegularExpression(self::VALID_HTTP_REGEX, file_get_contents($this->tmpFile));
   }
 
   public function testFetchHttps_valid() {
     $result = $this->client->fetch(self::VALID_HTTPS_URL, $this->tmpFile);
     $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $result);
-    $this->assertRegExp(self::VALID_HTTPS_REGEX, file_get_contents($this->tmpFile));
+    $this->assertMatchesRegularExpression(self::VALID_HTTPS_REGEX, file_get_contents($this->tmpFile));
   }
 
   public function testFetchHttps_invalid_verify() {
@@ -71,7 +71,7 @@ class CRM_Utils_HttpClientTest extends CiviUnitTestCase {
 
     $result = $this->client->fetch(self::SELF_SIGNED_HTTPS_URL, $this->tmpFile);
     $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $result);
-    $this->assertRegExp(self::SELF_SIGNED_HTTPS_REGEX, file_get_contents($this->tmpFile));
+    $this->assertMatchesRegularExpression(self::SELF_SIGNED_HTTPS_REGEX, file_get_contents($this->tmpFile));
   }
 
   public function testFetchHttp_badOutFile() {
@@ -82,13 +82,13 @@ class CRM_Utils_HttpClientTest extends CiviUnitTestCase {
   public function testGetHttp() {
     [$status, $data] = $this->client->get(self::VALID_HTTP_URL);
     $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $status);
-    $this->assertRegExp(self::VALID_HTTP_REGEX, $data);
+    $this->assertMatchesRegularExpression(self::VALID_HTTP_REGEX, $data);
   }
 
   public function testGetHttps_valid() {
     [$status, $data] = $this->client->get(self::VALID_HTTPS_URL);
     $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $status);
-    $this->assertRegExp(self::VALID_HTTPS_REGEX, $data);
+    $this->assertMatchesRegularExpression(self::VALID_HTTPS_REGEX, $data);
   }
 
   public function testGetHttps_invalid_verify() {
@@ -106,7 +106,7 @@ class CRM_Utils_HttpClientTest extends CiviUnitTestCase {
 
     [$status, $data] = $this->client->get(self::SELF_SIGNED_HTTPS_URL);
     $this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $status);
-    $this->assertRegExp(self::SELF_SIGNED_HTTPS_REGEX, $data);
+    $this->assertMatchesRegularExpression(self::SELF_SIGNED_HTTPS_REGEX, $data);
   }
 
 }
index 399b01b696312f598874e2d2a2fc9629efc2ff85..0e15bcf4846c6d83e029ea1bffc0ab0110909386 100644 (file)
@@ -154,7 +154,7 @@ class CRM_Utils_SQL_SelectTest extends CiviUnitTestCase {
       $this->fail('In output mode, we should reject requests to interpolate inputs.');
     }
     catch (Exception $e) {
-      $this->assertRegExp("/Cannot mix interpolation modes/", $e->getMessage());
+      $this->assertMatchesRegularExpression("/Cannot mix interpolation modes/", $e->getMessage());
     }
 
     $outputModeFragment = CRM_Utils_SQL_Select::fragment()
@@ -166,7 +166,7 @@ class CRM_Utils_SQL_SelectTest extends CiviUnitTestCase {
       $this->fail('In output-mode, we should reject requests to merge from input-mode.');
     }
     catch (Exception $e) {
-      $this->assertRegExp("/Cannot merge queries that use different interpolation modes/", $e->getMessage());
+      $this->assertMatchesRegularExpression("/Cannot merge queries that use different interpolation modes/", $e->getMessage());
     }
   }
 
@@ -253,7 +253,7 @@ class CRM_Utils_SQL_SelectTest extends CiviUnitTestCase {
       $this->fail('Unknown variables should throw errors in strict mode.');
     }
     catch (Exception $e) {
-      $this->assertRegExp('/Cannot build query. Variable "@johnMcClane" is unknown./', $e->getMessage());
+      $this->assertMatchesRegularExpression('/Cannot build query. Variable "@johnMcClane" is unknown./', $e->getMessage());
     }
   }
 
index 02e3a879c81914909ccb1ab3a11a1b3663ebb051..e4c4bbe25cf95c24f79daf883987ed43f1d57119 100644 (file)
@@ -33,7 +33,7 @@ class CRM_Utils_SQLTest extends CiviUnitTestCase {
       ]);
     }
     catch (CRM_Core_Exception $e) {
-      $this->assertRegExp(';Cannot build query. Variable "!the_table" is unknown.;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Cannot build query. Variable "!the_table" is unknown.;', $e->getMessage());
     }
   }
 
index 4a86843c3532dbe48f979017c154e7d753d33b5a..efac06977d9181cf00f7b7533cc399771051bdb5 100644 (file)
@@ -118,11 +118,11 @@ class CRM_Utils_StringTest extends CiviUnitTestCase {
     for ($i = 0; $i < 4; $i++) {
       $actual = CRM_Utils_String::createRandom(4, 'abc');
       $this->assertEquals(4, strlen($actual));
-      $this->assertRegExp('/^[abc]+$/', $actual);
+      $this->assertMatchesRegularExpression('/^[abc]+$/', $actual);
 
       $actual = CRM_Utils_String::createRandom(6, '12345678');
       $this->assertEquals(6, strlen($actual));
-      $this->assertRegExp('/^[12345678]+$/', $actual);
+      $this->assertMatchesRegularExpression('/^[12345678]+$/', $actual);
     }
   }
 
index 214aa065556d7bc29440d69a7ad46ded934c43db..16f5c5eecc7023bd2d2131573c4ec3ac41189fe1 100644 (file)
@@ -840,7 +840,7 @@ United States', $tokenProcessor->getRow(0)->render('message'));
       $this->fail('Expected unquoted parameter to fail');
     }
     catch (\CRM_Core_Exception $e) {
-      $this->assertRegExp(';Malformed token param;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Malformed token param;', $e->getMessage());
     }
   }
 
index 50c85f9adbb0a1f1b6878fd39916a749f9c62879..f7095429b4f1ec2902a069fd32ba809a4239e2c0 100644 (file)
@@ -209,7 +209,7 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase {
       '$params' => $params,
       '$result' => $result,
     ], TRUE));
-    $this->assertRegExp($expectedError, $result['error_message']);
+    $this->assertMatchesRegularExpression($expectedError, $result['error_message']);
   }
 
   /**
@@ -229,7 +229,7 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase {
     // run with permission check
     $result = $this->kernel->runSafe('FakeFile', 'create', $params);
     $this->assertTrue((bool) $result['is_error'], 'Undelegated entity with check_permissions = 1 should fail');
-    $this->assertRegExp('/Unrecognized target entity table \(civicrm_membership\)/', $result['error_message']);
+    $this->assertMatchesRegularExpression('/Unrecognized target entity table \(civicrm_membership\)/', $result['error_message']);
     // repeat without permission check
     $params['check_permissions'] = 0;
     $result = $this->kernel->runSafe('FakeFile', 'create', $params);
index b54eee9d6d0b69a8b749d15d235552e1d7a50bb9..dc3d55337153ef7142e6e1e1a316ba8a08cc80e4 100644 (file)
@@ -388,7 +388,7 @@ class WhitelistSubscriberTest extends \CiviUnitTestCase {
     }
     else {
       $this->assertAPIFailure($result);
-      $this->assertRegExp('/The request does not match any active API authorizations./', $result['error_message']);
+      $this->assertMatchesRegularExpression('/The request does not match any active API authorizations./', $result['error_message']);
     }
   }
 
index fb0317cdf5a8384f8ae219c3b9b923d366fcbce5..438da75c37dc29a9bc0233945e0ed0281a7ad9de 100644 (file)
@@ -313,7 +313,7 @@ abstract class AbstractMappingTest extends \CiviUnitTestCase {
         $this->assertEquals($expectMessage['to'], $actualMessage['to'], $errorText);
       }
       if (isset($expectMessage['subject'])) {
-        $this->assertRegExp($expectMessage['subject'], $actualMessage['subject'], $errorText);
+        $this->assertMatchesRegularExpression($expectMessage['subject'], $actualMessage['subject'], $errorText);
       }
     }
   }
index 0100eae8e0fb8e522510e9bbee8d1bbcaba37308..6509c17865d0a375ba97dac8eefa952903c05058 100644 (file)
@@ -99,7 +99,7 @@ class ManagerTest extends \CiviUnitTestCase {
    */
   public function testGetPartials() {
     $partials = $this->angular->getPartials('crmMailing');
-    $this->assertRegExp('/ng-form="crmMailingSubform">/', $partials['~/crmMailing/EditMailingCtrl/2step.html']);
+    $this->assertMatchesRegularExpression('/ng-form="crmMailingSubform">/', $partials['~/crmMailing/EditMailingCtrl/2step.html']);
     // If crmMailing changes, feel free to use a different example.
   }
 
@@ -110,7 +110,7 @@ class ManagerTest extends \CiviUnitTestCase {
     \CRM_Utils_Hook::singleton()->setHook('civicrm_alterAngular', [$this, 'hook_civicrm_alterAngular']);
 
     $partials = $this->angular->getPartials('crmMailing');
-    $this->assertRegExp('/ng-form="crmMailingSubform" cat-stevens="ts\\(\'wild world\'\\)">/', $partials['~/crmMailing/EditMailingCtrl/2step.html']);
+    $this->assertMatchesRegularExpression('/ng-form="crmMailingSubform" cat-stevens="ts\\(\'wild world\'\\)">/', $partials['~/crmMailing/EditMailingCtrl/2step.html']);
     // If crmMailing changes, feel free to use a different example.
   }
 
@@ -118,11 +118,11 @@ class ManagerTest extends \CiviUnitTestCase {
     \CRM_Utils_Hook::singleton()->setHook('civicrm_angularModules', [$this, 'hook_civicrm_angularModules_fooBar']);
 
     $paths = $this->angular->getResources(['fooBar'], 'js', 'path');
-    $this->assertRegExp('/visual-bundle.[a-z0-9]+.js/', $paths[0]);
-    $this->assertRegExp('/crossfilter/', file_get_contents($paths[0]));
+    $this->assertMatchesRegularExpression('/visual-bundle.[a-z0-9]+.js/', $paths[0]);
+    $this->assertMatchesRegularExpression('/crossfilter/', file_get_contents($paths[0]));
 
-    $this->assertRegExp('/Common.js/', $paths[1]);
-    $this->assertRegExp('/console/', file_get_contents($paths[1]));
+    $this->assertMatchesRegularExpression('/Common.js/', $paths[1]);
+    $this->assertMatchesRegularExpression('/console/', file_get_contents($paths[1]));
   }
 
   /**
index 5eea810a66c0ac9a3babf80c3e2a0accdf7d2483..135525a96e20f87b4cba16e7212c354bc2d6b404 100644 (file)
@@ -47,7 +47,7 @@ class CiviEventDispatcherTest extends \CiviUnitTestCase {
       $this->fail('Expected exception');
     }
     catch (\Exception $e) {
-      $this->assertRegExp(';The dispatch policy prohibits event;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';The dispatch policy prohibits event;', $e->getMessage());
     }
   }
 
index 43711e8602c7d7293886255fc697218527ca820c..c5fa1a2e9d4a24f47ce9f36eeab38a02cee3f379 100644 (file)
@@ -48,7 +48,7 @@ class CryptoJwtTest extends \CiviUnitTestCase {
       $this->fail('Expected decode to fail with exception');
     }
     catch (CryptoException $e) {
-      $this->assertRegExp(';Expired token;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Expired token;', $e->getMessage());
     }
   }
 
@@ -89,7 +89,7 @@ class CryptoJwtTest extends \CiviUnitTestCase {
         $this->fail('Expected decode to fail with exception');
       }
       catch (CryptoException $e) {
-        $this->assertRegExp(';Signature verification failed;', $e->getMessage());
+        $this->assertMatchesRegularExpression(';Signature verification failed;', $e->getMessage());
       }
     }
   }
index bad98388d9389a41ee17442d8dca51d516b68f01..2cdea071bec8526e00e59e0b183b17df70f49b0a 100644 (file)
@@ -102,7 +102,7 @@ class CryptoRegistryTest extends \CiviUnitTestCase {
       $this->fail("Expected crypto exception");
     }
     catch (CryptoException $e) {
-      $this->assertRegExp(';Malformed key ID;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Malformed key ID;', $e->getMessage());
     }
   }
 
index c17696846d0a12d752504ddcf6d944d917d7e1ea..87d928c98e27ada84cf44e635618c98dcda35b4e 100644 (file)
@@ -44,7 +44,7 @@ class CryptoTokenTest extends \CiviUnitTestCase {
       $this->fail("Expected CryptoException");
     }
     catch (CryptoException $e) {
-      $this->assertRegExp(';Cannot decrypt token. Invalid format.;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Cannot decrypt token. Invalid format.;', $e->getMessage());
     }
 
     $goodExample = $cryptoToken->encrypt('mess with me', 'UNIT-TEST');
@@ -57,7 +57,7 @@ class CryptoTokenTest extends \CiviUnitTestCase {
       $this->fail("Expected CryptoException");
     }
     catch (CryptoException $e) {
-      $this->assertRegExp(';Cannot decrypt token. Invalid format.;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';Cannot decrypt token. Invalid format.;', $e->getMessage());
     }
   }
 
@@ -84,7 +84,7 @@ class CryptoTokenTest extends \CiviUnitTestCase {
    */
   public function testRoundtrip($inputText, $inputKeyIdOrTag, $expectTokenRegex, $expectTokenLen, $expectPlain) {
     $token = \Civi::service('crypto.token')->encrypt($inputText, $inputKeyIdOrTag);
-    $this->assertRegExp($expectTokenRegex, $token);
+    $this->assertMatchesRegularExpression($expectTokenRegex, $token);
     $this->assertEquals($expectTokenLen, strlen($token));
     $this->assertEquals($expectPlain, \Civi::service('crypto.token')->isPlainText($token));
 
@@ -99,7 +99,7 @@ class CryptoTokenTest extends \CiviUnitTestCase {
     $cryptoToken = \Civi::service('crypto.token');
 
     $first = $cryptoToken->encrypt("hello world", 'UNIT-TEST');
-    $this->assertRegExp(';k=asdf-key-1;', $first);
+    $this->assertMatchesRegularExpression(';k=asdf-key-1;', $first);
     $this->assertEquals('hello world', $cryptoToken->decrypt($first));
 
     // If the keys haven't changed yet, then rekey() is a null-op.
@@ -113,8 +113,8 @@ class CryptoTokenTest extends \CiviUnitTestCase {
       'id' => 'new-key',
     ]);
     $third = $cryptoToken->rekey($first, 'UNIT-TEST');
-    $this->assertNotRegExp(';k=asdf-key-1;', $third);
-    $this->assertRegExp(';k=new-key;', $third);
+    $this->assertDoesNotMatchRegularExpression(';k=asdf-key-1;', $third);
+    $this->assertMatchesRegularExpression(';k=new-key;', $third);
     $this->assertEquals('hello world', $cryptoToken->decrypt($third));
   }
 
@@ -141,7 +141,7 @@ class CryptoTokenTest extends \CiviUnitTestCase {
       'id' => 'interim-key',
     ]);
     $third = $cryptoToken->rekey($first, 'APPLE');
-    $this->assertRegExp(';k=interim-key;', $third);
+    $this->assertMatchesRegularExpression(';k=interim-key;', $third);
     $this->assertEquals('hello world', $cryptoToken->decrypt($third));
 
     // But if we add another key with earlier priority,
index 0602ca5e5e10216fb48f12602065b8ae0fa51bfa..846a5eaa87f61a6bd6c27799d1c48c57ce2a69f4 100644 (file)
@@ -467,7 +467,7 @@ class PropertyBagTest extends \PHPUnit\Framework\TestCase implements HeadlessInt
       $propertyBag->setBillingCountry($bad);
       $this->assertCount(1, $propertyBag->logs);
       $latestLog = end($propertyBag->logs);
-      $this->assertRegExp("/setBillingCountry input warnings.*Expected string.*munged to: \"\"/s", $latestLog);
+      $this->assertMatchesRegularExpression("/setBillingCountry input warnings.*Expected string.*munged to: \"\"/s", $latestLog);
       $this->assertEquals('', $propertyBag->getBillingCountry());
     }
 
@@ -477,7 +477,7 @@ class PropertyBagTest extends \PHPUnit\Framework\TestCase implements HeadlessInt
     $propertyBag->setBillingCountry('');
     $this->assertCount(1, $propertyBag->logs);
     $latestLog = end($propertyBag->logs);
-    $this->assertRegExp('/setBillingCountry input warnings.+\nNot ISO 3166-1.+\n.*munged to: ""/', $latestLog);
+    $this->assertMatchesRegularExpression('/setBillingCountry input warnings.+\nNot ISO 3166-1.+\n.*munged to: ""/', $latestLog);
     $this->assertEquals('', $propertyBag->getBillingCountry());
 
     // Invalid country name
@@ -486,7 +486,7 @@ class PropertyBagTest extends \PHPUnit\Framework\TestCase implements HeadlessInt
     $propertyBag->setBillingCountry('UnitedKing');
     $this->assertCount(1, $propertyBag->logs);
     $latestLog = end($propertyBag->logs);
-    $this->assertRegExp('/setBillingCountry input warnings.+\nNot ISO 3166-1.+\nGiven input did not match a country name\.\n.*munged to: ""/', $latestLog);
+    $this->assertMatchesRegularExpression('/setBillingCountry input warnings.+\nNot ISO 3166-1.+\nGiven input did not match a country name\.\n.*munged to: ""/', $latestLog);
     $this->assertEquals('', $propertyBag->getBillingCountry());
 
     // Valid country name
@@ -495,7 +495,7 @@ class PropertyBagTest extends \PHPUnit\Framework\TestCase implements HeadlessInt
     $propertyBag->setBillingCountry('United Kingdom');
     $this->assertCount(1, $propertyBag->logs);
     $latestLog = end($propertyBag->logs);
-    $this->assertRegExp('/setBillingCountry input warnings.+\nNot ISO 3166-1.+\nGiven input matched a country name.*?\n.*munged to: "GB"/', $latestLog);
+    $this->assertMatchesRegularExpression('/setBillingCountry input warnings.+\nNot ISO 3166-1.+\nGiven input matched a country name.*?\n.*munged to: "GB"/', $latestLog);
     $this->assertEquals('GB', $propertyBag->getBillingCountry());
 
     // Invalid country ID
@@ -504,7 +504,7 @@ class PropertyBagTest extends \PHPUnit\Framework\TestCase implements HeadlessInt
     $propertyBag->setBillingCountry(-1);
     $this->assertCount(1, $propertyBag->logs);
     $latestLog = end($propertyBag->logs);
-    $this->assertRegExp('/setBillingCountry input warnings.+\nExpected string\nGiven input looked like it could be a country ID but did not.*?\n.*munged to: ""/', $latestLog);
+    $this->assertMatchesRegularExpression('/setBillingCountry input warnings.+\nExpected string\nGiven input looked like it could be a country ID but did not.*?\n.*munged to: ""/', $latestLog);
     $this->assertEquals('', $propertyBag->getBillingCountry());
 
     // Valid country ID
@@ -513,7 +513,7 @@ class PropertyBagTest extends \PHPUnit\Framework\TestCase implements HeadlessInt
     $propertyBag->setBillingCountry(1154); /* should be New Zealand */
     $this->assertCount(1, $propertyBag->logs);
     $latestLog = end($propertyBag->logs);
-    $this->assertRegExp('/setBillingCountry input warnings.+\nExpected string\nGiven input matched a country ID.*?\n.*munged to: "NZ"/', $latestLog);
+    $this->assertMatchesRegularExpression('/setBillingCountry input warnings.+\nExpected string\nGiven input matched a country ID.*?\n.*munged to: "NZ"/', $latestLog);
     $this->assertEquals('NZ', $propertyBag->getBillingCountry());
   }
 
index 2240e9090c378d13a75af556f6434adab6ce0a33..594118b311cef41811ca4d1b4d27ee89b4c0549e 100644 (file)
@@ -123,7 +123,7 @@ class JsonRpcSessionTest extends \CiviUnitTestCase {
     $decode = json_decode($responses[1], TRUE);
     $this->assertEquals('2.0', $decode['jsonrpc']);
     $this->assertEquals('bad1', $decode['id']);
-    $this->assertRegexp(';API.*System.*zznnzznnzz.*not exist;', $decode['error']['message']);
+    $this->assertMatchesRegularExpression(';API.*System.*zznnzznnzz.*not exist;', $decode['error']['message']);
 
     $decode = json_decode($responses[2], TRUE);
     $this->assertEquals('2.0', $decode['jsonrpc']);
@@ -134,7 +134,7 @@ class JsonRpcSessionTest extends \CiviUnitTestCase {
     $this->assertEquals('2.0', $decode['jsonrpc']);
     $this->assertEquals('bad2', $decode['id']);
     $this->assertEquals(1, $decode['result']['is_error']);
-    $this->assertRegexp(';API.*System.*zznnzznnzz.*not exist;', $decode['result']['error_message']);
+    $this->assertMatchesRegularExpression(';API.*System.*zznnzznnzz.*not exist;', $decode['result']['error_message']);
   }
 
   public function testApi4() {
@@ -168,7 +168,7 @@ class JsonRpcSessionTest extends \CiviUnitTestCase {
     };
     $apiFail = function($line, $caseId) {
       $decode = json_decode($line, TRUE);
-      $this->assertRegExp(';Authorization failed;', $decode['error']['message'], "($caseId) Should have authorization error. Got: $line");
+      $this->assertMatchesRegularExpression(';Authorization failed;', $decode['error']['message'], "($caseId) Should have authorization error. Got: $line");
     };
 
     $cases = []; /* [ ActivePerms?, Trusted?, CheckPerms?, ExpectResult */
@@ -193,7 +193,7 @@ class JsonRpcSessionTest extends \CiviUnitTestCase {
       [$inActivePerms, $inTrusted, $inApiCall, $expect] = $case;
       $this->setPermissions($inActivePerms);
       $responses = $this->runLines([$useException, $inApiCall], $inTrusted);
-      $this->assertRegExp($inTrusted === 'u' ? ';"untrusted";' : ';"trusted";', $responses[0], "($caseId) Header should indicate trust level");
+      $this->assertMatchesRegularExpression($inTrusted === 'u' ? ';"untrusted";' : ';"trusted";', $responses[0], "($caseId) Header should indicate trust level");
       $expect($responses[2], $caseId);
     }
   }
@@ -212,7 +212,7 @@ class JsonRpcSessionTest extends \CiviUnitTestCase {
     $decode = json_decode($responses[1], TRUE);
     $this->assertEquals('2.0', $decode['jsonrpc']);
     $this->assertEquals('bad1', $decode['id']);
-    $this->assertRegexp(';Api.*System.*zznnzznnzz.*not exist;', $decode['error']['message']);
+    $this->assertMatchesRegularExpression(';Api.*System.*zznnzznnzz.*not exist;', $decode['error']['message']);
 
     $decode = json_decode($responses[2], TRUE);
     $this->assertEquals('2.0', $decode['jsonrpc']);
@@ -223,7 +223,7 @@ class JsonRpcSessionTest extends \CiviUnitTestCase {
     $this->assertEquals('2.0', $decode['jsonrpc']);
     $this->assertEquals('bad2', $decode['id']);
     $this->assertEquals(1, $decode['result']['is_error']);
-    $this->assertRegexp(';Api.*System.*zznnzznnzz.*not exist;', $decode['result']['error_message']);
+    $this->assertMatchesRegularExpression(';Api.*System.*zznnzznnzz.*not exist;', $decode['result']['error_message']);
   }
 
   /**
index 02a747cfdff7fc6ef7a49664d2624f067a96dac5..302a6598a5cabd40756b7b5f755b7a46f641c855 100644 (file)
@@ -102,7 +102,7 @@ class MagicGetterSetterTest extends \CiviUnitTestCase {
       }
       catch (\CRM_Core_Exception $e) {
         $message = $e->getMessage();
-        $this->assertRegExp('/Unknown method.*::' . $nonMethod . '()/', $message);
+        $this->assertMatchesRegularExpression('/Unknown method.*::' . $nonMethod . '()/', $message);
       }
     }
   }
index 7d431a7369e9275683d968cbe4ce0e9d4d44de3e..e19760df6f4ac4d20e1d9b53e4a4782ca21739e5 100644 (file)
@@ -90,7 +90,7 @@ class ExampleHookTest extends TestCase implements HeadlessInterface, HookInterfa
     $p = new Main();
     $p->run();
     $content = ob_get_clean();
-    $this->assertRegExp('; hook_civicrm_alterContent on_hook_civicrm_alterContent;', $content);
+    $this->assertMatchesRegularExpression('; hook_civicrm_alterContent on_hook_civicrm_alterContent;', $content);
   }
 
   /**
index b82ad16d7f71d9b79a5f1afd81437752b9ffc32e..3bc9c599f00485c99fc8cef8eb33c2fe236afe3c 100644 (file)
@@ -75,7 +75,7 @@ class ExampleSubscriberTest extends \PHPUnit\Framework\TestCase implements Headl
     $p->run();
     $content = ob_get_contents();
     ob_end_clean();
-    $this->assertRegExp(';myAlterContentObject myAlterContentParams;', $content);
+    $this->assertMatchesRegularExpression(';myAlterContentObject myAlterContentParams;', $content);
   }
 
   public function testGetFields() {
index 305ce27e8d6f90e1436cec8621a6bd8cda190463..d6f9b4b6e517eb0749ce86a656c9eacf738ef162 100644 (file)
@@ -133,7 +133,7 @@ class AssetBuilderTest extends \CiviEndToEndTestCase {
     \Civi::service('asset_builder')->setCacheEnabled(TRUE);
     $url = \Civi::service('asset_builder')->getUrl($asset, $params);
     $this->assertEquals(1, $this->fired['hook_civicrm_buildAsset']);
-    $this->assertRegExp(';^https?:.*dyn/square.[0-9a-f]+.(txt|js)$;', $url);
+    $this->assertMatchesRegularExpression(';^https?:.*dyn/square.[0-9a-f]+.(txt|js)$;', $url);
     $this->assertEquals($expectedContent, file_get_contents($url));
     // Note: This actually relies on httpd to determine MIME type.
     // That could be ambiguous for javascript.
@@ -157,7 +157,7 @@ class AssetBuilderTest extends \CiviEndToEndTestCase {
     $url = \Civi::service('asset_builder')->getUrl($asset, $params);
     $this->assertEquals(0, $this->fired['hook_civicrm_buildAsset']);
     // Ex: Traditional URLs on D7 have "/". Traditional URLs on WP have "%2F".
-    $this->assertRegExp(';^https?:.*civicrm(/|%2F)asset(/|%2F)builder.*square.(txt|js);', $url);
+    $this->assertMatchesRegularExpression(';^https?:.*civicrm(/|%2F)asset(/|%2F)builder.*square.(txt|js);', $url);
 
     // Simulate a request. Our fake hook won't fire in a real request.
     parse_str(parse_url($url, PHP_URL_QUERY), $get);
index 2fd0f4c121a0eedf73a589d8a4a39c46d22e11bd..56d969e3ff76d152526692d914089366228bf851 100644 (file)
@@ -64,7 +64,7 @@ class PathUrlTest extends \CiviEndToEndTestCase {
 
     foreach (array_merge($urlOnly, $pathAndUrl) as $var) {
       $url = \Civi::paths()->getVariable($var, 'url');
-      $this->assertRegExp(';^https?:;', $url, "The URL for $var should resolve a URL.");
+      $this->assertMatchesRegularExpression(';^https?:;', $url, "The URL for $var should resolve a URL.");
     }
   }
 
@@ -73,9 +73,9 @@ class PathUrlTest extends \CiviEndToEndTestCase {
    * @param string $url
    */
   private function assertUrlContentRegex($expectContentRegex, $url) {
-    $this->assertRegexp(';^https?:;', $url, "The URL ($url) should be absolute.");
+    $this->assertMatchesRegularExpression(';^https?:;', $url, "The URL ($url) should be absolute.");
     $content = file_get_contents($url);
-    $this->assertRegexp($expectContentRegex, $content);
+    $this->assertMatchesRegularExpression($expectContentRegex, $content);
   }
 
   /**
@@ -85,7 +85,7 @@ class PathUrlTest extends \CiviEndToEndTestCase {
   private function assertFileContentRegex($expectContentRegex, $file) {
     $this->assertFileExists($file);
     $content = file_get_contents($file);
-    $this->assertRegexp($expectContentRegex, $content);
+    $this->assertMatchesRegularExpression($expectContentRegex, $content);
   }
 
   /**
index 03e05bc0f8b687ec40b7f3c061bab1130ae16395..05370070473f350fd903998b9bee215b9878cf16 100644 (file)
@@ -322,7 +322,7 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
     $this->assertEquals($entity_table, $createResult['values'][$fileId]['entity_table']);
     $this->assertEquals($entity->id, $createResult['values'][$fileId]['entity_id']);
     $this->assertEquals('My test description', $createResult['values'][$fileId]['description']);
-    $this->assertRegExp('/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/', $createResult['values'][$fileId]['upload_date']);
+    $this->assertMatchesRegularExpression('/\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d/', $createResult['values'][$fileId]['upload_date']);
     $this->assertNotTrue(isset($createResult['values'][$fileId]['content']));
     $this->assertNotEmpty($createResult['values'][$fileId]['url']);
     $this->assertAttachmentExistence(TRUE, $createResult);
@@ -378,7 +378,7 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
       'entity_table' => $entity_table,
       'entity_id' => $entity->id,
     ]);
-    $this->assertRegExp($expectedError, $createResult['error_message']);
+    $this->assertMatchesRegularExpression($expectedError, $createResult['error_message']);
   }
 
   /**
@@ -403,7 +403,7 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
     $updateResult = $this->callAPIFailure('Attachment', 'create', $updateParams + [
       'id' => $fileId,
     ]);
-    $this->assertRegExp($expectedError, $updateResult['error_message']);
+    $this->assertMatchesRegularExpression($expectedError, $updateResult['error_message']);
   }
 
   /**
@@ -560,7 +560,7 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
     }
 
     $getResult = $this->callAPIFailure('Attachment', 'get', $getParams);
-    $this->assertRegExp($expectedError, $getResult['error_message']);
+    $this->assertMatchesRegularExpression($expectedError, $getResult['error_message']);
   }
 
   /**
index 9e23c44d8ba83f5e2628f3f2707ef8c89ca1c744..ac644fa7b4b2cf81e77384137882d96e4ea19849 100644 (file)
@@ -925,8 +925,8 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $case_1 = $this->callAPISuccess('Case', 'getsingle', [
       'id' => $case_created['id'],
     ]);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_1['created_date']);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_1['modified_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_1['created_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_1['modified_date']);
     $this->assertApproxEquals(strtotime($case_1['created_date']), strtotime($case_1['modified_date']), 2);
 
     $activity_1 = $this->callAPISuccess('activity', 'getsingle', [
@@ -935,8 +935,8 @@ class api_v3_CaseTest extends CiviCaseTestCase {
         'limit' => 1,
       ],
     ]);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_1['created_date']);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_1['modified_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_1['created_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_1['modified_date']);
     $this->assertApproxEquals(strtotime($activity_1['created_date']), strtotime($activity_1['modified_date']), 2);
 
     usleep(1.5 * 1000000);
@@ -948,8 +948,8 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $activity_2 = $this->callAPISuccess('activity', 'getsingle', [
       'id' => $activity_1['id'],
     ]);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_2['created_date']);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_2['modified_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_2['created_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $activity_2['modified_date']);
     $this->assertNotEquals($activity_2['created_date'], $activity_2['modified_date']);
 
     $this->assertEquals($activity_1['created_date'], $activity_2['created_date']);
@@ -960,8 +960,8 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $case_2 = $this->callAPISuccess('Case', 'getsingle', [
       'id' => $case_created['id'],
     ]);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_2['created_date']);
-    $this->assertRegExp(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_2['modified_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_2['created_date']);
+    $this->assertMatchesRegularExpression(';^\d\d\d\d-\d\d-\d\d \d\d:\d\d;', $case_2['modified_date']);
     $this->assertEquals($case_1['created_date'], $case_2['created_date']);
     $this->assertNotEquals($case_2['created_date'], $case_2['modified_date']);
   }
index 1df6d0942c21e5851bdabad2ad8445c2c41d27ae..f44fbf08c982fe4ec322862fe70e8726f412375e 100644 (file)
@@ -617,7 +617,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'id' => $contactId,
       'api_key' => 'defg4321',
     ]);
-    $this->assertRegExp(';Permission denied to modify api key;', $result['error_message']);
+    $this->assertMatchesRegularExpression(';Permission denied to modify api key;', $result['error_message']);
 
     // Return everything -- because permissions are not being checked
     $config->userPermissionClass->permissions = [];
@@ -2650,7 +2650,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $result = $this->callAPIFailure('Contact', 'get', [
       'id' => '@user:exampleUser',
     ]);
-    $this->assertRegExp('/cannot be resolved to a contact ID/', $result['error_message']);
+    $this->assertMatchesRegularExpression('/cannot be resolved to a contact ID/', $result['error_message']);
   }
 
   /**
index 796561a3ffff25aaef9410d76c871d0bfbce1574..6578318196187d800161fc3d3e54f83313a3cf0b 100644 (file)
@@ -170,7 +170,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $this->assertEquals(95.00, $contribution['net_amount']);
     $this->assertEquals(23456, $contribution['trxn_id']);
     $this->assertEquals(78910, $contribution['invoice_id']);
-    $this->assertRegExp('/INV_\d+/', $contribution['invoice_number']);
+    $this->assertMatchesRegularExpression('/INV_\d+/', $contribution['invoice_number']);
     $this->assertEquals('SSF', $contribution['contribution_source']);
     $this->assertEquals('Completed', $contribution['contribution_status']);
     // Create a second contribution - we are testing that 'id' gets the right contribution id (not the contact id).
index 51a3308c4608052f77a41fe9accf30a15b16e848..bbce84c9096d2dd1486620256ee6c84928f9abe3 100644 (file)
@@ -302,8 +302,8 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $this->assertEquals("Hello $displayName", $previewResult['values']['subject']);
     $this->assertStringContainsString("This is $displayName", $previewResult['values']['body_text']);
     $this->assertStringContainsString("<p>This is $displayName.</p>", $previewResult['values']['body_html']);
-    $this->assertRegexp('!>Forward this email</a>!', $previewResult['values']['body_html']);
-    $this->assertRegexp('!<a href="([^"]+)civicrm/mailing/forward&amp;reset=1&amp;jid=&amp;qid=&amp;h=\w*">!', $previewResult['values']['body_html']);
+    $this->assertMatchesRegularExpression('!>Forward this email</a>!', $previewResult['values']['body_html']);
+    $this->assertMatchesRegularExpression('!<a href="([^"]+)civicrm/mailing/forward&amp;reset=1&amp;jid=&amp;qid=&amp;h=\w*">!', $previewResult['values']['body_html']);
     $this->assertStringNotContainsString("http://http://", $previewResult['values']['body_html']);
   }
 
@@ -678,7 +678,7 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $submitParams['id'] = $id;
     if ($expectedFailure) {
       $submitResult = $this->callAPIFailure('mailing', 'submit', $submitParams);
-      $this->assertRegExp($expectedFailure, $submitResult['error_message']);
+      $this->assertMatchesRegularExpression($expectedFailure, $submitResult['error_message']);
     }
     else {
       $submitResult = $this->callAPIAndDocument('Mailing', 'submit', $submitParams, __FUNCTION__, __FILE__);
@@ -1077,7 +1077,7 @@ SELECT event_queue_id, time_stamp FROM {$temporaryTableName}";
       $this->callAPISuccess('mailing', 'create', $this->_params + ['id' => $mail['id'], 'modified_date' => '2 seconds ago']);
     }
     catch (Exception $e) {
-      $this->assertRegExp("/Failure in api call for mailing create:  Mailing has not been saved, Content maybe out of date, please refresh the page and try again/", $e->getMessage());
+      $this->assertMatchesRegularExpression("/Failure in api call for mailing create:  Mailing has not been saved, Content maybe out of date, please refresh the page and try again/", $e->getMessage());
     }
   }
 
index bfd1f4cc98c2ef2f9c15ec6f8f32252359b4bd74..72b6f876ff8c32b44257a018d2bc26b655bf9b72 100644 (file)
@@ -791,7 +791,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
     $result = civicrm_api($Entity, 'Get', ['version' => 3]);
     $this->assertEquals(1, $result['is_error']);
     // $this->assertStringContainsString("API ($Entity, Get) does not exist", $result['error_message']);
-    $this->assertRegExp('/API (.*) does not exist/', $result['error_message']);
+    $this->assertMatchesRegularExpression('/API (.*) does not exist/', $result['error_message']);
   }
 
   /**
index 93d9eb93149db97f01ce3e2461a488dae08a480d..cf92553548690f15c6af922db255220d04185882 100644 (file)
@@ -98,7 +98,7 @@ class ContactGetTest extends Api4TestBase implements TransactionalInterface {
     catch (\CRM_Core_Exception $e) {
       $msg = $e->getMessage();
     }
-    $this->assertRegExp(';Expected to find one Contact record;', $msg);
+    $this->assertMatchesRegularExpression(';Expected to find one Contact record;', $msg);
     $limit1 = Contact::get(FALSE)->addWhere('last_name', '=', $last_name)->setLimit(1)->execute();
     $this->assertCount(1, (array) $limit1);
     $this->assertCount(1, $limit1);
index 7e05bbea68c9cfc334707c190c7142ab96d8cdf5..c582de01b998f8f66ae00a3ff69f0933b2dc24e0 100644 (file)
@@ -184,7 +184,7 @@ class ConformanceTest extends Api4TestBase implements HookInterface {
     $this->assertNotEmpty($info['description']);
     $this->assertIsArray($info['primary_key']);
     $this->assertNotEmpty($info['primary_key']);
-    $this->assertRegExp(';^\d\.\d+$;', $info['since']);
+    $this->assertMatchesRegularExpression(';^\d\.\d+$;', $info['since']);
     $this->assertContains($info['searchable'], ['primary', 'secondary', 'bridge', 'none']);
   }
 
index 9dd2708ae1d636fb732a62a56573ef5272ada311..0163cab438e43d7a223621a727120af59efcb14b 100644 (file)
@@ -191,7 +191,7 @@ class TranslationTest extends Api4TestBase implements TransactionalInterface, Ho
       $this->fail('Create should have failed');
     }
     catch (\CRM_Core_Exception $e) {
-      $this->assertRegExp($errorRegex, $e->getMessage());
+      $this->assertMatchesRegularExpression($errorRegex, $e->getMessage());
     }
   }
 
@@ -221,7 +221,7 @@ class TranslationTest extends Api4TestBase implements TransactionalInterface, Ho
         $this->fail('Update should fail');
       }
       catch (\CRM_Core_Exception $e) {
-        $this->assertRegExp($errorRegex, $e->getMessage());
+        $this->assertMatchesRegularExpression($errorRegex, $e->getMessage());
       }
     }
   }
index c1847c5e802d8e5cee289d39eee31e15840b4076..0a95fcd1426a34d6dd335e99c0c1d10620457357 100644 (file)
@@ -162,9 +162,9 @@ class ValidateValuesTest extends Api4TestBase implements TransactionalInterface
     }
     catch (\CRM_Core_Exception $e) {
       $this->assertEquals(1, $hookCount);
-      $this->assertRegExp(';not sufficiently namey;', $e->getMessage());
-      $this->assertRegExp(';tongue twister;', $e->getMessage());
-      $this->assertRegExp(';disagree with the spelling;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';not sufficiently namey;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';tongue twister;', $e->getMessage());
+      $this->assertMatchesRegularExpression(';disagree with the spelling;', $e->getMessage());
     }
   }
 
@@ -185,8 +185,8 @@ class ValidateValuesTest extends Api4TestBase implements TransactionalInterface
   }
 
   protected function assertWellFormedEvent(ValidateValuesEvent $e) {
-    $this->assertRegExp('/Contact/', $e->getEntityName());
-    $this->assertRegExp('/create|save|update/', $e->getActionName());
+    $this->assertMatchesRegularExpression('/Contact/', $e->getEntityName());
+    $this->assertMatchesRegularExpression('/create|save|update/', $e->getActionName());
     $this->assertTrue(count($e->records) > 0);
     foreach ($e->records as $record) {
       $this->assertWellFormedFields($record);
@@ -207,7 +207,7 @@ class ValidateValuesTest extends Api4TestBase implements TransactionalInterface
 
   protected function assertWellFormedFields($record) {
     foreach ($record as $field => $value) {
-      $this->assertRegExp('/^[a-zA-Z0-9_]+$/', $field);
+      $this->assertMatchesRegularExpression('/^[a-zA-Z0-9_]+$/', $field);
     }
   }