* @dataProvider getNameExamples
* @throws \Exception
*/
- public function testNameConversion($inputFileName, $toFormat, $expected) {
+ public function testNameConversion($inputFileName, $toFormat, $expected): void {
$actual = _afform_angular_module_name($inputFileName, $toFormat);
$this->assertEquals($expected, $actual);
}
return $htmls[$fileName];
}
- public function testDefnInjection() {
+ public function testDefnInjection(): void {
$inputHtml = sprintf(self::PERSON_TPL,
'<div af-fieldset="person"><af-field name="first_name" /></div>');
$filteredHtml = $this->htmlFilter('~/afform/MyForm.aff.html', $inputHtml);
$this->assertEquals('First Name', $myField['defn']['label']);
}
- public function testDefnInjectionNested() {
+ public function testDefnInjectionNested(): void {
$inputHtml = sprintf(self::PERSON_TPL,
'<span><div af-fieldset="person"><foo><af-field name="first_name" /></foo></div></span>');
$filteredHtml = $this->htmlFilter('~/afform/MyForm.aff.html', $inputHtml);
$this->assertEquals('First Name', $myField['defn']['label']);
}
- public function testDefnOverrideTitle() {
+ public function testDefnOverrideTitle(): void {
$inputHtml = sprintf(self::PERSON_TPL,
'<div af-fieldset="person"><af-field name="first_name" defn="{label: \'Given name\'}" /></div>');
$filteredHtml = $this->htmlFilter('~/afform/MyForm.aff.html', $inputHtml);
* @param $expectEntities
* @dataProvider getEntityExamples
*/
- public function testGetEntities($html, $expectEntities) {
+ public function testGetEntities($html, $expectEntities): void {
$parser = new \CRM_Afform_ArrayHtml();
$fdm = new FormDataModel($parser->convertHtmlToArray($html));
$this->assertEquals($expectEntities, $fdm->getEntities());
* Types are (e)lement, (a)ttribute, (c)lass
* @dataProvider getExamples
*/
- public function testSymbols($html, $expect) {
+ public function testSymbols($html, $expect): void {
$expectDefaults = ['e' => [], 'a' => [], 'c' => []];
$expect = array_merge($expectDefaults, $expect);
$actual = Symbols::scan($html);
->apply();
}
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
Civi\Api4\Afform::revert()
->setCheckPermissions(FALSE)
->execute();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
Civi\Api4\Afform::revert()
->setCheckPermissions(FALSE)
->execute();
}
- public function testChangingPermissions() {
+ public function testChangingPermissions(): void {
$http = new \GuzzleHttp\Client(['http_errors' => FALSE]);
$url = function ($path, $query = NULL) {
return CRM_Utils_System::url($path, $query, TRUE, NULL, FALSE);
$this->assertOpensPage($result, 'mock-page');
}
- public function testChangingPath() {
+ public function testChangingPath(): void {
$http = new \GuzzleHttp\Client(['http_errors' => FALSE]);
$url = function ($path, $query = NULL) {
return CRM_Utils_System::url($path, $query, TRUE, NULL, FALSE);
* @param array $originalMetadata
* @dataProvider getBasicDirectives
*/
- public function testGetUpdateRevert($formName, $originalMetadata) {
+ public function testGetUpdateRevert($formName, $originalMetadata): void {
$get = function($arr, $key) {
return isset($arr[$key]) ? $arr[$key] : NULL;
};
* (For debug messages) A symbolic name of the example data-set being tested.
* @dataProvider getFormatExamples
*/
- public function testBasicConvert($formName, $updateFormat, $updateLayout, $readFormat, $readLayout, $exampleName) {
+ public function testBasicConvert($formName, $updateFormat, $updateLayout, $readFormat, $readLayout, $exampleName): void {
$actual = Civi\Api4\Afform::convert()->setLayout($updateLayout)
->setFrom($updateFormat)
->setTo($readFormat)
* (For debug messages) A symbolic name of the example data-set being tested.
* @dataProvider getFormatExamples
*/
- public function testUpdateAndGetFormat($formName, $updateFormat, $updateLayout, $readFormat, $readLayout, $exampleName) {
+ public function testUpdateAndGetFormat($formName, $updateFormat, $updateLayout, $readFormat, $readLayout, $exampleName): void {
Civi\Api4\Afform::revert()->addWhere('name', '=', $formName)->execute();
Civi\Api4\Afform::update()
*
* @dataProvider getWhitespaceExamples
*/
- public function testWhitespaceFormat($directiveName, $example, $exampleName) {
+ public function testWhitespaceFormat($directiveName, $example, $exampleName): void {
Civi\Api4\Afform::save()
->addRecord(['name' => $directiveName, 'layout' => $example['html']])
->setLayoutFormat('html')
$this->assertEquals($example['pretty'], $this->fudgeMarkup($result['layout']));
}
- public function testAutoRequires() {
+ public function testAutoRequires(): void {
$formName = 'mockPage';
$this->createLoggedInUser();
protected $formName;
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
self::$layouts['aboutMe'] = <<<EOHTML
<af-form ctrl="modelListCtrl">
EOHTML;
}
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->formName = 'mock' . rand(0, 100000);
}
- public function tearDown() {
+ public function tearDown(): void {
Civi\Api4\Afform::revert()
->setCheckPermissions(FALSE)
->addWhere('name', '=', $this->formName)
parent::tearDown();
}
- public function testAboutMeAllowed() {
+ public function testAboutMeAllowed(): void {
$this->useValues([
'layout' => self::$layouts['aboutMe'],
'permission' => CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION,
$this->assertEquals('Lasty', $contact['last_name']);
}
- public function testAboutMeForbidden() {
+ public function testAboutMeForbidden(): void {
$this->useValues([
'layout' => self::$layouts['aboutMe'],
'permission' => CRM_Core_Permission::ALWAYS_DENY_PERMISSION,
*/
protected $quirks = [];
- public static function setUpBeforeClass() {
+ public static function setUpBeforeClass(): void {
\Civi\Test::e2e()
->installMe(__DIR__)
->callback(
->apply();
}
- public function setUp() {
+ public function setUp(): void {
$quirks = [
'Joomla' => ['sendsExcessCookies', 'authErrorShowsForm'],
'WordPress' => ['sendsExcessCookies'],
}
}
- public function tearDown() {
+ public function tearDown(): void {
foreach ($this->settingsBackup as $setting => $value) {
\Civi::settings()->set($setting, $value);
}
return $exs;
}
- public function testAnonymous() {
+ public function testAnonymous(): void {
$http = $this->createGuzzle(['http_errors' => FALSE]);
/** @var \Psr\Http\Message\RequestInterface $request */
* @throws \GuzzleHttp\Exception\GuzzleException
* @dataProvider getStatelessExamples
*/
- public function testStatelessContactOnly($credType, $flowType) {
+ public function testStatelessContactOnly($credType, $flowType): void {
if ($credType === 'pass') {
$this->assertTrue(TRUE, 'No need to test password credentials with non-user contacts');
return;
* @throws \GuzzleHttp\Exception\GuzzleException
* @dataProvider getStatelessExamples
*/
- public function testStatelessUserContact($credType, $flowType) {
+ public function testStatelessUserContact($credType, $flowType): void {
$http = $this->createGuzzle(['http_errors' => FALSE]);
/** @var \Psr\Http\Message\RequestInterface $request */
* @throws \GuzzleHttp\Exception\GuzzleException
* @dataProvider getCredTypes
*/
- public function testStatefulLoginAllowed($credType) {
+ public function testStatefulLoginAllowed($credType): void {
$flowType = 'login';
$credFunc = 'cred' . ucfirst(preg_replace(';[^a-zA-Z0-9];', '', $credType));
* @throws \GuzzleHttp\Exception\GuzzleException
* @dataProvider getCredTypes
*/
- public function testStatefulLoginProhibited($credType) {
+ public function testStatefulLoginProhibited($credType): void {
$flowType = 'login';
$http = $this->createGuzzle(['http_errors' => FALSE]);
$credFunc = 'cred' . ucfirst(preg_replace(';[^a-zA-Z0-9];', '', $credType));
* @throws \GuzzleHttp\Exception\GuzzleException
* @dataProvider getCredTypes
*/
- public function testStatefulAutoAllowed($credType) {
+ public function testStatefulAutoAllowed($credType): void {
$flowType = 'auto';
$cookieJar = new CookieJar();
$http = $this->createGuzzle(['http_errors' => FALSE, 'cookies' => $cookieJar]);
* @throws \GuzzleHttp\Exception\GuzzleException
* @dataProvider getCredTypes
*/
- public function testStatefulAutoProhibited($credType) {
+ public function testStatefulAutoProhibited($credType): void {
$flowType = 'auto';
$cookieJar = new CookieJar();
$http = $this->createGuzzle(['http_errors' => FALSE, 'cookies' => $cookieJar]);
* @throws \CiviCRM_API3_Exception
* @throws \GuzzleHttp\Exception\GuzzleException
*/
- public function testStatefulStatelessOverlap() {
+ public function testStatefulStatelessOverlap(): void {
\Civi::settings()->set("authx_login_cred", ['api_key']);
\Civi::settings()->set("authx_header_cred", ['api_key']);
* @throws \CiviCRM_API3_Exception
* @throws \GuzzleHttp\Exception\GuzzleException
*/
- public function testMultipleStateless() {
+ public function testMultipleStateless(): void {
\Civi::settings()->set("authx_header_cred", ['api_key']);
$cookieJar = new CookieJar();
$http = $this->createGuzzle(['http_errors' => FALSE, 'cookies' => $cookieJar]);
* The expected user ID
* @param \Psr\Http\Message\ResponseInterface $response
*/
- public function assertMyContact($cid, $uid, ResponseInterface $response) {
+ public function assertMyContact($cid, $uid, ResponseInterface $response): void {
$this->assertContentType('application/json', $response);
$this->assertStatusCode(200, $response);
$j = json_decode((string) $response->getBody(), 1);
*
* @param \Psr\Http\Message\ResponseInterface $response
*/
- public function assertAnonymousContact(ResponseInterface $response) {
+ public function assertAnonymousContact(ResponseInterface $response): void {
$formattedFailure = $this->formatFailure($response);
$this->assertContentType('application/json', $response);
$this->assertStatusCode(200, $response);
*
* @param \Psr\Http\Message\ResponseInterface $response
*/
- public function assertDashboardUnauthorized($response = NULL) {
+ public function assertDashboardUnauthorized($response = NULL): void {
$response = $this->resolveResponse($response);
if (!in_array('authErrorShowsForm', $this->quirks)) {
$this->assertStatusCode(403, $response);
);
}
- public function assertDashboardOk($response = NULL) {
+ public function assertDashboardOk($response = NULL): void {
$response = $this->resolveResponse($response);
$this->assertStatusCode(200, $response);
$this->assertContentType('text/html', $response);
/**
* @param \Psr\Http\Message\ResponseInterface $response
*/
- private function assertFailedDueToProhibition($response) {
+ private function assertFailedDueToProhibition($response): void {
$this->assertBodyRegexp(';HTTP 401;', $response);
$this->assertContentType('text/plain', $response);
if (!in_array('sendsExcessCookies', $this->quirks)) {
->apply();
}
- public function setUp() {
+ public function setUp(): void {
$this->setUpEwayProcessor();
$this->processor = \Civi\Payment\System::singleton()->getById($this->ids['PaymentProcessor']['eWAY']);
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
$this->callAPISuccess('PaymentProcessor', 'delete', ['id' => $this->ids['PaymentProcessor']['eWAY']]);
parent::tearDown();
}
/**
* Test making a once off payment
*/
- public function testSinglePayment() {
+ public function testSinglePayment(): void {
$this->setupMockHandler();
$params = $this->getBillingParams();
$params['amount'] = 10.00;
/**
* Test making a failed once off payment
*/
- public function testErrorSinglePayment() {
+ public function testErrorSinglePayment(): void {
$this->setupMockHandler(NULL, TRUE);
$params = $this->getBillingParams();
$params['amount'] = 5.24;
];
}
- public function setUpEwayProcessor() {
+ public function setUpEwayProcessor(): void {
$params = [
'name' => 'demo',
'domain_id' => CRM_Core_Config::domainID(),
*
* @throws \CiviCRM_API3_Exception
*/
- protected function setupMockHandler($id = NULL, $error = FALSE) {
+ protected function setupMockHandler($id = NULL, $error = FALSE): void {
if ($id) {
$this->processor = Civi\Payment\System::singleton()->getById($id);
}
*
* @return array
*/
- public function getExpectedSinglePaymentResponses() {
+ public function getExpectedSinglePaymentResponses(): array {
return [
'<ewayResponse><ewayTrxnStatus>True</ewayTrxnStatus><ewayTrxnNumber>10002</ewayTrxnNumber><ewayTrxnReference>xyz</ewayTrxnReference><ewayTrxnOption1/><ewayTrxnOption2/><ewayTrxnOption3/><ewayAuthCode>123456</ewayAuthCode><ewayReturnAmount>1000</ewayReturnAmount><ewayTrxnError>00,Transaction Approved(Test Gateway)</ewayTrxnError></ewayResponse>',
];
*
* @return array
*/
- public function getExpectedSinglePaymentRequests() {
+ public function getExpectedSinglePaymentRequests(): array {
return [
'<ewaygateway><ewayCustomerID>87654321</ewayCustomerID><ewayTotalAmount>1000</ewayTotalAmount><ewayCardHoldersName>John O'Connor</ewayCardHoldersName><ewayCardNumber>4444333322221111</ewayCardNumber><ewayCardExpiryMonth>10</ewayCardExpiryMonth><ewayCardExpiryYear>22</ewayCardExpiryYear><ewayTrxnNumber>xyz</ewayTrxnNumber><ewayCustomerInvoiceDescription>Test Contribution</ewayCustomerInvoiceDescription><ewayCustomerFirstName>John</ewayCustomerFirstName><ewayCustomerLastName>O'Connor</ewayCustomerLastName><ewayCustomerEmail>unittesteway@civicrm.org</ewayCustomerEmail><ewayCustomerAddress>8 Hobbitton Road, The Shire, NSW.</ewayCustomerAddress><ewayCustomerPostcode>5010</ewayCustomerPostcode><ewayCustomerInvoiceRef>xyz</ewayCustomerInvoiceRef><ewayCVN>123</ewayCVN><ewayOption1></ewayOption1><ewayOption2></ewayOption2><ewayOption3></ewayOption3><ewayCustomerIPAddress>127.0.0.1</ewayCustomerIPAddress><ewayCustomerBillingCountry>AUS</ewayCustomerBillingCountry></ewaygateway>',
];
*
* @return array
*/
- public function getExpectedSinglePaymentErrorResponses() {
+ public function getExpectedSinglePaymentErrorResponses(): array {
return [
'<ewayResponse><ewayTrxnStatus>False</ewayTrxnStatus><ewayTrxnNumber>10003</ewayTrxnNumber><ewayTrxnReference>xyz</ewayTrxnReference><ewayTrxnOption1/><ewayTrxnOption2/><ewayTrxnOption3/><ewayAuthCode>123456</ewayAuthCode><ewayReturnAmount>524</ewayReturnAmount><ewayTrxnError>24,Do Not Honour(Test Gateway)</ewayTrxnError></ewayResponse>',
];
/**
* Test api applies permissions on line item actions (delete & get).
*/
- public function testBuildAmount() {
+ public function testBuildAmount(): void {
$priceSet = PriceSet::create()->setValues(['name' => 'test', 'title' => 'test', 'extends' => 'CiviMember'])->execute()->first();
PriceField::create()->setValues([
'financial_type_id:name' => 'Donation',
*
* @dataProvider versionThreeAndFour
*/
- public function testLineItemApiPermissions($version) {
+ public function testLineItemApiPermissions($version): void {
$contact1 = $this->individualCreate();
$defaultPriceFieldID = $this->getDefaultPriceFieldID();
$order = $this->callAPISuccess('Order', 'create', [
/**
* Test buildMembershipTypes.
*/
- public function testMembershipTypesHook() {
+ public function testMembershipTypesHook(): void {
$types = MembershipType::save(FALSE)->setRecords([
['name' => 'Forbidden', 'financial_type_id:name' => 'Member Dues'],
['name' => 'Go for it', 'financial_type_id:name' => 'Donation'],
/**
* Test buildMembershipTypes.
*/
- public function testBuildOptions() {
+ public function testBuildOptions(): void {
$this->setupLoggedInUserWithLimitedFinancialTypeAccess();
$options = \CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes();
$this->assertEquals(['Donation'], array_merge($options));
*/
class HtmlClickTrackerTest extends \CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
* @param $expectHtml
* @dataProvider getHrefExamples
*/
- public function testReplaceHref($inputHtml, $expectHtml) {
+ public function testReplaceHref($inputHtml, $expectHtml): void {
$actual = HtmlClickTracker::replaceHrefUrls($inputHtml, function($url) {
return "tracking($url)";
});
*/
class TextClickTrackerTest extends \CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
* @param $expectHtml
* @dataProvider getHrefExamples
*/
- public function testReplaceTextUrls($inputHtml, $expectHtml) {
+ public function testReplaceTextUrls($inputHtml, $expectHtml): void {
$inputText = \CRM_Utils_String::htmlToText($inputHtml);
$expectText = \CRM_Utils_String::htmlToText($expectHtml);
$expectText = str_replace('/tracking', 'tracking', $expectText);
->apply();
}
- public function setUp() {
+ public function setUp(): void {
// Mock the getTrackerURL call; we don't need to test creating a row in a table.
// If you want this to work without runkit, then either (a) make the dummy rows or (b) switch this to a hook/event that is runtime-configurable.
require_once 'CRM/Mailing/BAO/TrackableURL.php';
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
// Reset the class.
runkit7_method_remove('\CRM_Mailing_BAO_TrackableURL', 'getBasicTrackerURL');
runkit7_method_rename('\CRM_Mailing_BAO_TrackableURL', 'orig_getBasicTrackerURL', 'getBasicTrackerURL');
/**
* Example: Test that a link without any tokens works.
*/
- public function testLinkWithoutTokens() {
+ public function testLinkWithoutTokens(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://example.com/foo/bar?a=b&c=d#frag';
$result = $filter->filterContent($msg, 1, 1);
/**
* Example: Test that a link with tokens in the query works.
*/
- public function testLinkWithTokensInQueryWithStaticParams() {
+ public function testLinkWithTokensInQueryWithStaticParams(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://example.com/foo/bar?a=b&cid={contact.id}';
$result = $filter->filterContent($msg, 1, 1);
/**
* Example: Test that a link with tokens in the query works.
*/
- public function testLinkWithTokensInQueryWithMultipleStaticParams() {
+ public function testLinkWithTokensInQueryWithMultipleStaticParams(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://example.com/foo/bar?cs={contact.checksum}&a=b&cid={contact.id}';
$result = $filter->filterContent($msg, 1, 1);
/**
* Example: Test that a link with tokens in the query works.
*/
- public function testLinkWithTokensInQueryWithMultipleStaticParamsHtml() {
+ public function testLinkWithTokensInQueryWithMultipleStaticParamsHtml(): void {
$filter = new HtmlClickTracker();
$msg = '<a href="https://example.com/foo/bar?cs={contact.checksum}&a=b&cid={contact.id}">See this</a>';
$result = $filter->filterContent($msg, 1, 1);
/**
* Example: Test that a link with tokens in the query works.
*/
- public function testLinkWithTokensInQueryWithoutStaticParams() {
+ public function testLinkWithTokensInQueryWithoutStaticParams(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://example.com/foo/bar?cid={contact.id}';
$result = $filter->filterContent($msg, 1, 1);
* Seems browsers maintain the fragment when they receive a redirect, so a
* token here might still work.
*/
- public function testLinkWithTokensInFragment() {
+ public function testLinkWithTokensInFragment(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://example.com/foo/bar?a=b#cid={contact.id}';
$result = $filter->filterContent($msg, 1, 1);
* Seems browsers maintain the fragment when they receive a redirect, so a
* token here might still work.
*/
- public function testLinkWithTokensInQueryAndFragment() {
+ public function testLinkWithTokensInQueryAndFragment(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://example.com/foo/bar?a=b&cid={contact.id}#cid={contact.id}';
$result = $filter->filterContent($msg, 1, 1);
/**
* We can't handle tokens in the domain so it should not be tracked.
*/
- public function testLinkWithTokensInDomainFails() {
+ public function testLinkWithTokensInDomainFails(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://{some.domain}.com/foo/bar';
$result = $filter->filterContent($msg, 1, 1);
/**
* We can't handle tokens in the path so it should not be tracked.
*/
- public function testLinkWithTokensInPathFails() {
+ public function testLinkWithTokensInPathFails(): void {
$filter = new TextClickTracker();
$msg = 'See this: https://example.com/{some.path}';
$result = $filter->filterContent($msg, 1, 1);
*/
class ConcurrentDeliveryTest extends \api_v3_JobProcessMailingTest {
- public function setUp() {
+ public function setUp(): void {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
\Civi::settings()->set('flexmailer_traditional', 'flexmailer');
}
- public function tearDown() {
+ public function tearDown(): void {
// We're building on someone else's test and don't fully trust them to
// protect our settings. Make sure they did.
$ok = ('flexmailer' == \Civi::settings()->get('flexmailer_traditional'))
* @dataProvider concurrencyExamples
* @see _testConcurrencyCommon
*/
- public function testConcurrency($settings, $expectedTallies, $expectedTotal) {
+ public function testConcurrency($settings, $expectedTallies, $expectedTotal): void {
parent::testConcurrency($settings, $expectedTallies, $expectedTotal);
}
- public function testBasic() {
+ public function testBasic(): void {
parent::testBasic();
}
private $counts;
- public function setUp() {
+ public function setUp(): void {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
$this->assertEquals('flexmailer', $context);
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
$this->assertNotEmpty($this->counts['hook_alterMailParams']);
foreach (FlexMailer::getEventTypes() as $event => $class) {
$htmlUrlRegex,
$textUrlRegex,
$params
- ) {
+ ): void {
parent::testUrlTracking($inputHtml, $htmlUrlRegex, $textUrlRegex, $params);
}
return $cases;
}
- public function testBasicHeaders() {
+ public function testBasicHeaders(): void {
parent::testBasicHeaders();
}
- public function testText() {
+ public function testText(): void {
parent::testText();
}
- public function testHtmlWithOpenTracking() {
+ public function testHtmlWithOpenTracking(): void {
parent::testHtmlWithOpenTracking();
}
- public function testHtmlWithOpenAndUrlTracking() {
+ public function testHtmlWithOpenAndUrlTracking(): void {
parent::testHtmlWithOpenAndUrlTracking();
}
*/
class SimpleFilterTest extends \CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
/**
* Ensure that the utility `SimpleFilter::byValue()` correctly filters.
*/
- public function testByValue() {
+ public function testByValue(): void {
$test = $this;
list($tasks, $e) = $this->createExampleBatch();
/**
* Ensure that the utility `SimpleFilter::byColumn()` correctly filters.
*/
- public function testByColumn() {
+ public function testByColumn(): void {
$test = $this;
list($tasks, $e) = $this->createExampleBatch();
*/
protected $footer;
- public function setUp() {
+ public function setUp(): void {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
));
}
- public function tearDown() {
+ public function tearDown(): void {
// DGW
\CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0;
parent::tearDown();
}
- public function testMailerPreview() {
+ public function testMailerPreview(): void {
// BEGIN SAMPLE DATA
$contactID = $this->individualCreate();
$displayName = $this->callAPISuccess('contact', 'get',
$this->assertEquals('flexmailer', $previewResult['values']['_rendered_by_']);
}
- public function testMailerPreviewWithoutId() {
+ public function testMailerPreviewWithoutId(): void {
// BEGIN SAMPLE DATA
$contactID = $this->createLoggedInUser();
$displayName = $this->callAPISuccess('contact', 'get', ['id' => $contactID]);
* @param array $expectMaxIds
* Array(string $table => int $maxId).
*/
- protected function assertMaxIds($expectMaxIds) {
+ protected function assertMaxIds($expectMaxIds): void {
foreach ($expectMaxIds as $table => $maxId) {
$this->assertDBQuery($expectMaxIds[$table], 'SELECT MAX(id) FROM ' . $table, [], "Table $table should have a maximum ID of $maxId");
}
*/
class ValidatorTest extends \CiviUnitTestCase {
- public function setUp() {
+ public function setUp(): void {
// Activate before transactions are setup.
$manager = \CRM_Extension_System::singleton()->getManager();
if ($manager->getStatus('org.civicrm.flexmailer') !== \CRM_Extension_Manager::STATUS_INSTALLED) {
* @param array $expectedErrors
* @dataProvider getExamples
*/
- public function testExamples($mailingData, $expectedErrors) {
+ public function testExamples($mailingData, $expectedErrors): void {
$mailing = new \CRM_Mailing_DAO_Mailing();
$mailing->copyValues($mailingData);
$actualErrors = Validator::createAndRun($mailing);
return \Civi\Test::headless()->install('oauth-client')->apply();
}
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
- public function testEvalArrayTemplate() {
+ public function testEvalArrayTemplate(): void {
$vars = array(
'token' => [
'client_id' => 10,
return \Civi\Test::headless()->install('oauth-client')->apply();
}
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->assertEquals(0, CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_oauth_client'));
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
/**
* Basic sanity check - create, read, and delete a client.
*/
- public function testAuthorizationCode() {
+ public function testAuthorizationCode(): void {
$usePerms = function($ps) {
$base = ['access CiviCRM'];
\CRM_Core_Config::singleton()->userPermissionClass->permissions = array_merge($base, $ps);
return \Civi\Test::headless()->install('oauth-client')->apply();
}
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->assertEquals(0, CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_oauth_client'));
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
/**
* Basic sanity check - create, read, and delete a client.
*/
- public function testBasic() {
+ public function testBasic(): void {
$random = CRM_Utils_String::createRandom(16, CRM_Utils_String::ALPHANUMERIC);
$usePerms = function($ps) {
$base = ['access CiviCRM'];
}
}
- public function testUpdateBadProvider() {
+ public function testUpdateBadProvider(): void {
$random = CRM_Utils_String::createRandom(16, CRM_Utils_String::ALPHANUMERIC);
$usePerms = function($ps) {
$base = ['access CiviCRM'];
return \Civi\Test::headless()->install('oauth-client')->apply();
}
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
/**
* Create, read, and destroy token - with full access to secrets.
*/
- public function testGet() {
+ public function testGet(): void {
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM'];
$examples = Civi\Api4\OAuthProvider::get()
return \Civi\Test::headless()->install('oauth-client')->apply();
}
- public function setUp() {
+ public function setUp(): void {
parent::setUp();
$this->assertEquals(0, CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_oauth_client'));
$this->assertEquals(0, CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_oauth_systoken'));
}
- public function tearDown() {
+ public function tearDown(): void {
parent::tearDown();
}
/**
* Create, read, and destroy token - with full access to secrets.
*/
- public function testFullApiAccess() {
+ public function testFullApiAccess(): void {
$random = CRM_Utils_String::createRandom(16, CRM_Utils_String::ALPHANUMERIC);
$usePerms = function($ps) {
$base = ['access CiviCRM'];
/**
* Create, read, and destroy a token - with limited API access (cannot access token secrets).
*/
- public function testLimitedApiAccess() {
+ public function testLimitedApiAccess(): void {
$random = CRM_Utils_String::createRandom(16, CRM_Utils_String::ALPHANUMERIC);
$usePerms = function($ps) {
$base = ['access CiviCRM'];
$this->assertEquals("example-refresh-token-$random", $token['refresh_token']);
}
- public function testGetByScope() {
+ public function testGetByScope(): void {
$random = CRM_Utils_String::createRandom(16, CRM_Utils_String::ALPHANUMERIC);
$usePerms = function($ps) {
$base = ['access CiviCRM'];
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
- public function testCreateCreditNoteId() {
+ public function testCreateCreditNoteId(): void {
$this->_apiversion = 4;
$contactId = $this->callAPISuccess('Contact', 'create', ['contact_type' => 'Individual', 'email' => 'b@example.com'])['id'];