Skip to content

Commit

Permalink
[TASK] Migrate getAccessibleMockForAbstractClass for EXT:form controller
Browse files Browse the repository at this point in the history
`getMockForAbstractClass` has been (soft-)deprecated in PHPUnit 10.1:
sebastianbergmann/phpunit#5241

Hence, we should replace its usages to follow best practices and
avoid deprecation warnings later with PHPUnit 11.

We do this by creating dedicated fixture subclasses of the affected
abstract classes.

This change also cleans up the affected test to better match the
setup/execute/verify structure.

Resolves: #102117
Related: #101601
Releases: main, 12.4
Change-Id: Iaa6cee9893d41cb95e20cda80e03f044d52d82cd
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81374
Reviewed-by: Christian Kuhn <[email protected]>
Tested-by: Stefan Bürk <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: core-ci <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
  • Loading branch information
oliverklee authored and sbuerk committed Oct 15, 2023
1 parent 60d727e commit 9d710ea
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 16 deletions.
23 changes: 7 additions & 16 deletions Tests/Unit/Controller/AbstractBackendControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,22 @@

namespace TYPO3\CMS\Form\Tests\Unit\Controller;

use TYPO3\CMS\Form\Controller\AbstractBackendController;
use TYPO3\CMS\Form\Tests\Unit\Controller\Fixtures\TestingController;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

final class AbstractBackendControllerTest extends UnitTestCase
{
/**
* @test
*/
public function resolveResourcePathsExpectResolve(): void
public function resolveResourcePathsResolvesExtNotation(): void
{
$mockController = $this->getAccessibleMockForAbstractClass(
AbstractBackendController::class,
[],
'',
false
);
$subject = new TestingController();
$input = [0 => 'EXT:form/Resources/Public/Css/form.css'];

$input = [
0 => 'EXT:form/Resources/Public/Css/form.css',
];
$result = $subject->resolveResourcePaths($input);

$expected = [
0 => 'typo3/sysext/form/Resources/Public/Css/form.css',
];

self::assertSame($expected, $mockController->_call('resolveResourcePaths', $input));
$expected = [0 => 'typo3/sysext/form/Resources/Public/Css/form.css'];
self::assertSame($expected, $result);
}
}
31 changes: 31 additions & 0 deletions Tests/Unit/Controller/Fixtures/TestingController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace TYPO3\CMS\Form\Tests\Unit\Controller\Fixtures;

use TYPO3\CMS\Form\Controller\AbstractBackendController;

/**
* Testing subclass of the abstract class with some protected methods exposed as public.
*/
final class TestingController extends AbstractBackendController
{
public function resolveResourcePaths(array $resourcePaths): array
{
return parent::resolveResourcePaths($resourcePaths);
}
}

0 comments on commit 9d710ea

Please sign in to comment.