Skip to content

Commit

Permalink
Add in Void statements on varios Core Ext Tests to future support PHP…
Browse files Browse the repository at this point in the history
…Unit8
  • Loading branch information
seamuslee001 committed Mar 19, 2021
1 parent d4c8721 commit 8d0a109
Show file tree
Hide file tree
Showing 27 changed files with 105 additions and 105 deletions.
2 changes: 1 addition & 1 deletion ext/afform/core/tests/phpunit/CRM/Afform/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function getNameExamples() {
* @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);
}
Expand Down
6 changes: 3 additions & 3 deletions ext/afform/core/tests/phpunit/Civi/Afform/FilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private function htmlFilter($fileName, $html) {
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);
Expand All @@ -46,7 +46,7 @@ public function testDefnInjection() {
$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);
Expand All @@ -58,7 +58,7 @@ public function testDefnInjectionNested() {
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function getEntityExamples() {
* @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());
Expand Down
2 changes: 1 addition & 1 deletion ext/afform/core/tests/phpunit/Civi/Afform/SymbolsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function getExamples() {
* 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);
Expand Down
8 changes: 4 additions & 4 deletions ext/afform/mock/tests/phpunit/api/v4/AfformRoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ public static function setUpBeforeClass() {
->apply();
}

public function setUp() {
public function setUp(): void {
parent::setUp();
Civi\Api4\Afform::revert()
->setCheckPermissions(FALSE)
->addWhere('name', '=', $this->formName)
->execute();
}

public function tearDown() {
public function tearDown(): void {
parent::tearDown();
Civi\Api4\Afform::revert()
->setCheckPermissions(FALSE)
->addWhere('name', '=', $this->formName)
->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);
Expand All @@ -49,7 +49,7 @@ public function testChangingPermissions() {
$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);
Expand Down
10 changes: 5 additions & 5 deletions ext/afform/mock/tests/phpunit/api/v4/AfformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function getBasicDirectives() {
* @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;
};
Expand Down Expand Up @@ -134,7 +134,7 @@ public function getFormatExamples() {
* (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)
Expand Down Expand Up @@ -177,7 +177,7 @@ public function testBasicConvert($formName, $updateFormat, $updateLayout, $readF
* (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()
Expand Down Expand Up @@ -213,7 +213,7 @@ public function getWhitespaceExamples() {
*
* @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')
Expand Down Expand Up @@ -243,7 +243,7 @@ public function testWhitespaceFormat($directiveName, $example, $exampleName) {
$this->assertEquals($example['pretty'], $this->fudgeMarkup($result['layout']));
}

public function testAutoRequires() {
public function testAutoRequires(): void {
$formName = 'mockPage';
$this->createLoggedInUser();

Expand Down
10 changes: 5 additions & 5 deletions ext/afform/mock/tests/phpunit/api/v4/AfformUsageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class api_v4_AfformUsageTest extends api_v4_AfformTestCase {

protected $formName;

public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
self::$layouts['aboutMe'] = <<<EOHTML
<af-form ctrl="modelListCtrl">
Expand All @@ -26,20 +26,20 @@ public static function setUpBeforeClass() {
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)
->execute();
parent::tearDown();
}

public function testAboutMeAllowed() {
public function testAboutMeAllowed(): void {
$this->useValues([
'layout' => self::$layouts['aboutMe'],
'permission' => CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION,
Expand Down Expand Up @@ -71,7 +71,7 @@ public function testAboutMeAllowed() {
$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,
Expand Down
34 changes: 17 additions & 17 deletions ext/authx/tests/phpunit/Civi/Authx/AllFlowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AllFlowsTest extends \PHPUnit\Framework\TestCase implements EndToEndInterf
*/
protected $quirks = [];

public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
\Civi\Test::e2e()
->installMe(__DIR__)
->callback(
Expand All @@ -46,7 +46,7 @@ function() {
->apply();
}

public function setUp() {
public function setUp(): void {
$quirks = [
'Joomla' => ['sendsExcessCookies', 'authErrorShowsForm'],
'WordPress' => ['sendsExcessCookies'],
Expand All @@ -62,7 +62,7 @@ public function setUp() {
}
}

public function tearDown() {
public function tearDown(): void {
foreach ($this->settingsBackup as $setting => $value) {
\Civi::settings()->set($setting, $value);
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public function getCredTypes() {
return $exs;
}

public function testAnonymous() {
public function testAnonymous(): void {
$http = $this->createGuzzle(['http_errors' => FALSE]);

/** @var \Psr\Http\Message\RequestInterface $request */
Expand All @@ -111,7 +111,7 @@ public function testAnonymous() {
* @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;
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testStatelessContactOnly($credType, $flowType) {
* @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 */
Expand Down Expand Up @@ -176,7 +176,7 @@ public function testStatelessUserContact($credType, $flowType) {
* @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));

Expand Down Expand Up @@ -222,7 +222,7 @@ public function testStatefulLoginAllowed($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));
Expand All @@ -244,7 +244,7 @@ public function testStatefulLoginProhibited($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]);
Expand All @@ -271,7 +271,7 @@ public function testStatefulAutoAllowed($credType) {
* @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]);
Expand All @@ -291,7 +291,7 @@ public function testStatefulAutoProhibited($credType) {
* @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']);

Expand Down Expand Up @@ -329,7 +329,7 @@ public function testStatefulStatelessOverlap() {
* @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]);
Expand Down Expand Up @@ -417,7 +417,7 @@ public function requestMyContact() {
* 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);
Expand All @@ -431,7 +431,7 @@ public function assertMyContact($cid, $uid, ResponseInterface $response) {
*
* @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);
Expand All @@ -448,7 +448,7 @@ public function assertAnonymousContact(ResponseInterface $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);
Expand All @@ -459,7 +459,7 @@ public function assertDashboardUnauthorized($response = NULL) {
);
}

public function assertDashboardOk($response = NULL) {
public function assertDashboardOk($response = NULL): void {
$response = $this->resolveResponse($response);
$this->assertStatusCode(200, $response);
$this->assertContentType('text/html', $response);
Expand Down Expand Up @@ -569,7 +569,7 @@ public function credNone($cid) {
/**
* @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)) {
Expand Down
Loading

0 comments on commit 8d0a109

Please sign in to comment.