Commit 3c9b0dbe authored by Benni Mack's avatar Benni Mack
Browse files

[TASK] Update PHPunit to v9

PHPunit v9 allows to use further improvements to our testing
API, and also offers extended support until at least Feb 2022.

PHPunit v9 requires PHP 7.3+ which isn't a problem
for us per-se.

In addition, composer does not complain about
an abandoned package anymore if we upgrade to PHPunit 9.

In order to achieve this, we need to explicitly
require "codeception/phpunit-wrapper:^9.0" which we
can then remove later-on again.

Used composer commands:
> composer req --dev "phpunit/phpunit:^9.5" "phpspec/prophecy-phpunit" "codeception/phpunit-wrapper:^9.0" -W
> composer req --dev "phpunit/phpunit:^9.5" "phpspec/prophecy-phpunit" -d typo3/sysext/core --no-update
> composer remove --dev codeception/phpunit-wrapper

Used rector to migrate all Unit tests to prevent warnings..

Resolves: #94706
Releases: master
Change-Id: I68d9df07421149f4ad40964afc512f0f995b295b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69297


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Mathias Brodala's avatarMathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent febe4cb8
This diff is collapsed.
......@@ -33,6 +33,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
*/
class AdminPanelInitiatorTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @var bool Reset singletons created by subject
*/
......
......@@ -28,6 +28,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
class PreviewModuleTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
public function simulateDateDataProvider(): array
{
return [
......
......@@ -27,6 +27,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
class ConfigurationServiceTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @var BackendUserAuthentication|\Prophecy\Prophecy\ObjectProphecy
*/
......
......@@ -27,7 +27,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
class ModuleLoaderTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @test
*/
......
......@@ -24,7 +24,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
class StateUtilityTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @test
*/
......
......@@ -26,6 +26,7 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class PasswordResetTest extends FunctionalTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
protected LoggerInterface $logger;
public function setUp(): void
......
......@@ -32,6 +32,7 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
*/
class ConditionMatcherTest extends FunctionalTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* Sets up this test case.
*/
......
......@@ -142,7 +142,7 @@ class FormInlineAjaxControllerTest extends FunctionalTestCase
$body = (string)$response->getBody();
$jsonArray = json_decode($body, true);
self::assertRegExp('/<option value="1"[^>]* selected="selected">Dansk<\/option>/', $jsonArray['data']);
self::assertMatchesRegularExpression('/<option value="1"[^>]* selected="selected">Dansk<\/option>/', $jsonArray['data']);
}
/**
......@@ -169,7 +169,7 @@ class FormInlineAjaxControllerTest extends FunctionalTestCase
$body = (string)$response->getBody();
$jsonArray = json_decode($body, true);
self::assertNotRegExp('/<select[^>]* name="data\[tx_irretutorial_1ncsv_offer\]\[NEW[1-9]+\]\[sys_language_uid\]"[^>]*>/', $jsonArray['data']);
self::assertDoesNotMatchRegularExpression('/<select[^>]* name="data\[tx_irretutorial_1ncsv_offer\]\[NEW[1-9]+\]\[sys_language_uid\]"[^>]*>/', $jsonArray['data']);
}
/**
......
......@@ -126,7 +126,7 @@ class MfaConfigurationControllerTest extends FunctionalTestCase
self::assertEquals(200, $response->getStatusCode());
$responseContent = $response->getBody()->getContents();
self::assertStringContainsString('Multi-factor authentication required', $responseContent);
self::assertRegExp('/<div.*class="card card-size-fixed-small border-success shadow".*id="totp-provider"/s', $responseContent);
self::assertMatchesRegularExpression('/<div.*class="card card-size-fixed-small border-success shadow".*id="totp-provider"/s', $responseContent);
}
/**
......@@ -142,7 +142,7 @@ class MfaConfigurationControllerTest extends FunctionalTestCase
);
self::assertEquals(200, $response->getStatusCode());
self::assertRegExp('/<span.*title="Default provider">/s', $response->getBody()->getContents());
self::assertMatchesRegularExpression('/<span.*title="Default provider">/s', $response->getBody()->getContents());
}
/**
......@@ -382,12 +382,12 @@ class MfaConfigurationControllerTest extends FunctionalTestCase
$responseContent = $response->getBody()->getContents();
self::assertEquals(200, $response->getStatusCode());
self::assertRegExp('/<a.*href="\/typo3\/mfa.*title="Close">/s', $responseContent);
self::assertRegExp('/<button.*name="save".*form="mfaConfigurationController">/s', $responseContent);
self::assertRegExp('/<form.*name="' . $action . '".*id="mfaConfigurationController">/s', $responseContent);
self::assertMatchesRegularExpression('/<a.*href="\/typo3\/mfa.*title="Close">/s', $responseContent);
self::assertMatchesRegularExpression('/<button.*name="save".*form="mfaConfigurationController">/s', $responseContent);
self::assertMatchesRegularExpression('/<form.*name="' . $action . '".*id="mfaConfigurationController">/s', $responseContent);
// Ensure provider specific content is added as well
self::assertRegExp($providerContent, $responseContent);
self::assertMatchesRegularExpression($providerContent, $responseContent);
}
public function handleRequestAddsFormOnInteractionViewsTestTestDataProvider(): \Generator
......
......@@ -34,6 +34,7 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class MfaControllerTest extends FunctionalTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
protected MfaController $subject;
protected ServerRequest $request;
......@@ -117,10 +118,10 @@ class MfaControllerTest extends FunctionalTestCase
// Auth view for provider is renderer
self::assertStringContainsString('Time-based one-time password', $responseContent);
self::assertRegExp('/<form.*name="verify".*id="mfaController">/s', $responseContent);
self::assertMatchesRegularExpression('/<form.*name="verify".*id="mfaController">/s', $responseContent);
// Ensure provider specific content is added as well
self::assertRegExp('/<input.*id="totp"/s', $responseContent);
self::assertMatchesRegularExpression('/<input.*id="totp"/s', $responseContent);
}
/**
......@@ -164,7 +165,7 @@ class MfaControllerTest extends FunctionalTestCase
$responseContent = $response->getBody()->getContents();
self::assertStringContainsString('Alternative providers', $responseContent);
self::assertRegExp('/<a.*title="Use Recovery codes"/s', $responseContent);
self::assertMatchesRegularExpression('/<a.*title="Use Recovery codes"/s', $responseContent);
}
/**
......
......@@ -40,6 +40,7 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class ResetPasswordControllerTest extends FunctionalTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
protected ResetPasswordController $subject;
protected ServerRequestInterface $request;
......@@ -101,7 +102,7 @@ class ResetPasswordControllerTest extends FunctionalTestCase
{
$response = $this->subject->forgetPasswordFormAction($this->request)->getBody()->getContents();
self::assertStringContainsString('/*loginHighlightColor*/', $response);
self::assertRegExp('/\.btn-login { background-color: #abcdef; }.*\.card-login \.card-footer { border-color: #abcdef; }/s', $response);
self::assertMatchesRegularExpression('/\.btn-login { background-color: #abcdef; }.*\.card-login \.card-footer { border-color: #abcdef; }/s', $response);
}
/**
......
......@@ -27,6 +27,7 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class MfaInfoElementTest extends FunctionalTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
protected function setUp(): void
{
parent::setUp();
......@@ -71,10 +72,10 @@ class MfaInfoElementTest extends FunctionalTestCase
]);
// MFA is disabled
self::assertRegExp('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertNotRegExp('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
self::assertMatchesRegularExpression('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertDoesNotMatchRegularExpression('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
// MFA can NOT be deactivated
self::assertRegExp('/<button.*class="t3js-deactivate-mfa-button btn btn-danger disabled".*disabled="disabled"/s', $result['html']);
self::assertMatchesRegularExpression('/<button.*class="t3js-deactivate-mfa-button btn btn-danger disabled".*disabled="disabled"/s', $result['html']);
// JavaScript is NOT added
self::assertEmpty($result['requireJsModules']);
}
......@@ -95,10 +96,10 @@ class MfaInfoElementTest extends FunctionalTestCase
]);
// MFA is disabled
self::assertRegExp('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertNotRegExp('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
self::assertMatchesRegularExpression('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertDoesNotMatchRegularExpression('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
// MFA can NOT be deactivated
self::assertRegExp('/<button.*class="t3js-deactivate-mfa-button btn btn-danger disabled".*disabled="disabled"/s', $result['html']);
self::assertMatchesRegularExpression('/<button.*class="t3js-deactivate-mfa-button btn btn-danger disabled".*disabled="disabled"/s', $result['html']);
// JavaScript is NOT added
self::assertEmpty($result['requireJsModules']);
}
......@@ -119,18 +120,18 @@ class MfaInfoElementTest extends FunctionalTestCase
]);
// Mfa is enabled
self::assertNotRegExp('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertRegExp('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
self::assertDoesNotMatchRegularExpression('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertMatchesRegularExpression('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
// Totp item exist
self::assertRegExp('/<li.*class="list-group-item".*id="provider-totp"/s', $result['html']);
self::assertMatchesRegularExpression('/<li.*class="list-group-item".*id="provider-totp"/s', $result['html']);
// Recovery codes item does NOT exist
self::assertStringNotContainsString('id="provider-recovery-codes"', $result['html']);
// No item is locked
self::assertNotRegExp('/<span.*class="label label-danger".*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.locked/s', $result['html']);
self::assertDoesNotMatchRegularExpression('/<span.*class="label label-danger".*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.locked/s', $result['html']);
// Item can be deactivated
self::assertRegExp('/<button.*class="btn btn-default btn-sm pull-right t3js-deactivate-provider-button"/s', $result['html']);
self::assertMatchesRegularExpression('/<button.*class="btn btn-default btn-sm pull-right t3js-deactivate-provider-button"/s', $result['html']);
// MFA can be deactivated
self::assertRegExp('/<button.*class="t3js-deactivate-mfa-button btn btn-danger "/s', $result['html']);
self::assertMatchesRegularExpression('/<button.*class="t3js-deactivate-mfa-button btn btn-danger "/s', $result['html']);
// JavaScript is added
self::assertArrayHasKey('TYPO3/CMS/Backend/FormEngine/Element/MfaInfoElement', $result['requireJsModules'][0]);
}
......@@ -151,18 +152,18 @@ class MfaInfoElementTest extends FunctionalTestCase
]);
// Mfa is enabled
self::assertNotRegExp('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertRegExp('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
self::assertDoesNotMatchRegularExpression('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertMatchesRegularExpression('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
// Totp item exists
self::assertRegExp('/<li.*class="list-group-item".*id="provider-totp"/s', $result['html']);
self::assertMatchesRegularExpression('/<li.*class="list-group-item".*id="provider-totp"/s', $result['html']);
// Recovery codes item exists
self::assertRegExp('/<li.*class="list-group-item".*id="provider-recovery-codes"/s', $result['html']);
self::assertMatchesRegularExpression('/<li.*class="list-group-item".*id="provider-recovery-codes"/s', $result['html']);
// Item is locked
self::assertRegExp('/<span.*class="label label-danger".*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.locked/s', $result['html']);
self::assertMatchesRegularExpression('/<span.*class="label label-danger".*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.locked/s', $result['html']);
// Items can be deactivated
self::assertRegExp('/<button.*class="btn btn-default btn-sm pull-right t3js-deactivate-provider-button"/s', $result['html']);
self::assertMatchesRegularExpression('/<button.*class="btn btn-default btn-sm pull-right t3js-deactivate-provider-button"/s', $result['html']);
// MFA can be deactivated
self::assertRegExp('/<button.*class="t3js-deactivate-mfa-button btn btn-danger "/s', $result['html']);
self::assertMatchesRegularExpression('/<button.*class="t3js-deactivate-mfa-button btn btn-danger "/s', $result['html']);
// JavaScript is added
self::assertArrayHasKey('TYPO3/CMS/Backend/FormEngine/Element/MfaInfoElement', $result['requireJsModules'][0]);
}
......@@ -187,14 +188,14 @@ class MfaInfoElementTest extends FunctionalTestCase
]);
// Mfa is enabled
self::assertNotRegExp('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertRegExp('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
self::assertDoesNotMatchRegularExpression('/<span.*class="label label-danger.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.disabled/s', $result['html']);
self::assertMatchesRegularExpression('/<span.*class="label label-success.*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.mfa.enabled/s', $result['html']);
// Totp item exists
self::assertRegExp('/<li.*class="list-group-item".*id="provider-totp"/s', $result['html']);
self::assertMatchesRegularExpression('/<li.*class="list-group-item".*id="provider-totp"/s', $result['html']);
// Recovery codes item exists
self::assertRegExp('/<li.*class="list-group-item".*id="provider-recovery-codes"/s', $result['html']);
self::assertMatchesRegularExpression('/<li.*class="list-group-item".*id="provider-recovery-codes"/s', $result['html']);
// Item (recovery codes) is locked
self::assertRegExp('/<span.*class="label label-danger".*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.locked/s', $result['html']);
self::assertMatchesRegularExpression('/<span.*class="label label-danger".*>LLL:EXT:core\/Resources\/Private\/Language\/locallang_core.xlf:labels.locked/s', $result['html']);
// Items deactivation button is not shown
self::assertStringNotContainsString('t3js-deactivate-provider-button', $result['html']);
// MFA deactivation button is not shown
......
......@@ -31,6 +31,7 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class PageLayoutViewTest extends FunctionalTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @var PageLayoutView|AccessibleObjectInterface
*/
......
......@@ -26,6 +26,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
*/
class BackendUserConfigurationTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @var BackendUserConfiguration
*/
......
......@@ -28,6 +28,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
class TranslationConfigurationProviderTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @var TranslationConfigurationProvider
*/
......
......@@ -30,6 +30,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
*/
class EditDocumentControllerTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @var bool
*/
......
......@@ -30,6 +30,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
*/
class FileControllerTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @var File|\PHPUnit\Framework\MockObject\MockObject
*/
......
......@@ -27,6 +27,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
*/
class FormInlineAjaxControllerTest extends UnitTestCase
{
use \Prophecy\PhpUnit\ProphecyTrait;
/**
* @test
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment