Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPUnit 10 - Various fixes for "E2E" suite #31626

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRM/Core/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function __construct() {
'CiviTestSuite',
'CiviUnitTestCase',
'CiviEndToEndTestCase',
'CiviSimpleCacheTest',
'CiviSimpleCacheTestCase',
'Contact',
'ContributionPage',
'Custom',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@

use PHPUnit\Framework\TestCase;

abstract class CiviSimpleCacheTest extends TestCase {
abstract class CiviSimpleCacheTestCase extends TestCase {
/**
* @var array
* with functionName => reason.
*/
protected $skippedTests = [];

/**
* @var CiviSimpleCacheTest
* @var CiviSimpleCacheTestCase
*/
protected $cache;

/**
* @return CiviSimpleCacheTest that is used in the tests
* @return CiviSimpleCacheTestCase that is used in the tests
*/
abstract public function createSimpleCache();

Expand Down
42 changes: 0 additions & 42 deletions tests/phpunit/E2E/AllTests.php

This file was deleted.

2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Api4/LocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class LocaleTest extends \CiviEndToEndTestCase {

public function getLanguageExamples(): array {
public static function getLanguageExamples(): array {
$results = [];
switch (CIVICRM_UF) {
case 'Backdrop':
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Cache/CacheTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @group e2e
*/
abstract class E2E_Cache_CacheTestCase extends CiviSimpleCacheTest implements \Civi\Test\EndToEndInterface {
abstract class E2E_Cache_CacheTestCase extends CiviSimpleCacheTestCase implements \Civi\Test\EndToEndInterface {

const MAX_KEY = 255;

Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/E2E/Cache/TwoInstancesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function tearDown(): void {
/**
* Get a list of cache-creation specs.
*/
public function getSingleGenerators() {
public static function getSingleGenerators() {
$exs = [];
$exs[] = [
['type' => ['SqlGroup'], 'name' => 'TwoInstancesTest_SameSQL'],
Expand Down Expand Up @@ -81,7 +81,7 @@ public function testSingle_reload($cacheDef) {
/**
* Get a list of distinct cache-creation specs.
*/
public function getTwoGenerators() {
public static function getTwoGenerators() {
$exs = [];
$exs[] = [
['type' => ['SqlGroup'], 'name' => 'testTwo_a'],
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Core/AssetBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function buildSquareJs(GenericHookEvent $e) {
* Get a list of example assets to build/request.
* @return array
*/
public function getExamples() {
public static function getExamples() {
$examples = [];

$examples[] = [
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Core/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ErrorTest extends \CiviEndToEndTestCase {
'/Backdrop_testErrorChrome_(fatal|exception)/',
];

public function getErrorTypes() {
public static function getErrorTypes() {
return [
'frontend_fatal' => ['frontend://civicrm/dev/fake-error', 'fatal'],
'frontend_exception' => ['frontend://civicrm/dev/fake-error', 'exception'],
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Core/PrevNextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function testFetch(): void {
$this->assertEquals([200, 300], $cids);
}

public function getFillFunctions() {
public static function getFillFunctions() {
return [
['testFillSql'],
['testFillArray'],
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/E2E/Core/SmartyStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testDisallowedSmartyCalls($template, $expectedResult): void {
}
}

public function allowedSmartyCallsProvider(): array {
public static function allowedSmartyCallsProvider(): array {
return [
[
'{if count($numbers) == 2}yes{else}no{/if}',
Expand All @@ -70,7 +70,7 @@ public function allowedSmartyCallsProvider(): array {
];
}

public function disallowedSmartyCallProviders(): array {
public static function disallowedSmartyCallProviders(): array {
return [
[
"{if call_user_func(array('CRM_Utils_String', 'isAscii'), 'foo')}yes{else}no{/if}",
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/E2E/Extern/AuthxRestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @group e2e
*/
class E2E_Extern_AuthxRestTest extends E2E_Extern_BaseRestTest {
class E2E_Extern_AuthxRestTest extends E2E_Extern_RestTestCase {

public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
Expand All @@ -33,7 +33,7 @@ protected function getRestUrl() {
return CRM_Utils_System::url('civicrm/ajax/rest', NULL, TRUE, NULL, FALSE, TRUE);
}

protected function isOldQSupported(): bool {
protected static function isOldQSupported(): bool {
return FALSE;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/E2E/Extern/CliRunnerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function testPermissionLookup(): void {
* Each case gives a name (eg "cv") and template for executing the command
* (eg "cv ev @PHP").
*/
public function getRunners() {
public static function getRunners() {
$cliRunners = [];

if (CIVICRM_UF === 'WordPress') {
Expand All @@ -110,9 +110,9 @@ public function getRunners() {
return $cliRunners;
}

public function getRunnersAndPaths() {
public static function getRunnersAndPaths() {
$exs = [];
foreach ($this->getRunners() as $runner) {
foreach (static::getRunners() as $runner) {
$exs[] = array_merge($runner, ['[civicrm.root]/css/civicrm.css']);
$exs[] = array_merge($runner, ['[civicrm.packages]/jquery/css/images/arrow.png']);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/E2E/Extern/LegacyRestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* @group e2e
*/
class E2E_Extern_LegacyRestTest extends E2E_Extern_BaseRestTest {
class E2E_Extern_LegacyRestTest extends E2E_Extern_RestTestCase {

protected $LEGACY_EXTERN_SUPPORTED = ['Drupal', 'Backdrop', 'Joomla', 'WordPress'];

Expand All @@ -30,7 +30,7 @@ protected function getRestUrl() {
->getUrl('civicrm', 'extern/rest.php');
}

protected function isOldQSupported(): bool {
protected static function isOldQSupported(): bool {
return TRUE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @group e2e
*/
abstract class E2E_Extern_BaseRestTest extends CiviEndToEndTestCase {
abstract class E2E_Extern_RestTestCase extends CiviEndToEndTestCase {

use HttpTestTrait;

Expand All @@ -40,7 +40,7 @@ abstract class E2E_Extern_BaseRestTest extends CiviEndToEndTestCase {
*
* @return bool
*/
abstract protected function isOldQSupported(): bool;
abstract protected static function isOldQSupported(): bool;

/**
* @param $apiResult
Expand Down Expand Up @@ -94,7 +94,7 @@ protected function tearDown(): void {
*
* @return array; each item is a list of parameters for testAPICalls
*/
public function apiTestCases() {
public static function apiTestCases() {
$cases = [];

// entity,action: omit apiKey, valid entity+action
Expand Down Expand Up @@ -217,7 +217,7 @@ public function apiTestCases() {
0,
];

if (!$this->isOldQSupported()) {
if (!static::isOldQSupported()) {
$cases = array_filter($cases, function($case) {
// The 'civicrm/ajax/rest' end-point does not support '?q' inputs.
return !isset($case[0]['q']);
Expand Down