Skip to content

Commit b65b185

Browse files
authored
Merge pull request #754 from extcode/make_extension_compatible_to_typo3_version_14_2
[TASK] Make extension compatible to TYPO3 v14.2
2 parents 9922bcd + 9e67159 commit b65b185

18 files changed

+118
-109
lines changed

Build/.php-cs-fixer.dist.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
(new PhpCsFixer\Finder())
1212
->ignoreVCSIgnored(true)
1313
->in(__DIR__ . '/../')
14+
->exclude(
15+
[
16+
'var/',
17+
]
18+
)
1419
)
1520
->setRiskyAllowed(true)
1621
->setRules([

Build/phpstan-baseline.neon

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2436,6 +2436,12 @@ parameters:
24362436
count: 1
24372437
path: ../Classes/Domain/Validator/OrderItemValidator.php
24382438

2439+
-
2440+
message: '#^Parameter \#2 \$validators of method Extcode\\Cart\\Domain\\Validator\\OrderItemValidator\:\:checkProperty\(\) expects Traversable\<mixed, TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface\>, iterable\<TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface\>&SplObjectStorage given\.$#'
2441+
identifier: argument.type
2442+
count: 1
2443+
path: ../Classes/Domain/Validator/OrderItemValidator.php
2444+
24392445
-
24402446
message: '#^Property TYPO3\\CMS\\Extbase\\Validation\\Validator\\AbstractGenericObjectValidator\:\:\$propertyValidators \(array\<string, iterable\<TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface\>&SplObjectStorage\>\) does not accept array\<string, \(iterable\<TYPO3\\CMS\\Extbase\\Validation\\Validator\\ValidatorInterface\>&SplObjectStorage\)\|SplObjectStorage\<object, mixed\>\>\.$#'
24412447
identifier: assign.propertyType
@@ -5555,10 +5561,3 @@ parameters:
55555561
identifier: argument.templateType
55565562
count: 1
55575563
path: ../Tests/Unit/Validation/Validator/EmptyValidatorTest.php
5558-
5559-
-
5560-
message: '#^Cannot access offset ''cart'' on mixed\.$#'
5561-
identifier: offsetAccess.nonOffsetAccessible
5562-
count: 1
5563-
path: ../ext_emconf.php
5564-

Build/phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ parameters:
88
- ../Classes
99
- ../Configuration
1010
- ../Tests
11-
- ../ext_emconf.php
1211
- ../ext_localconf.php
1312

1413
disallowedFunctionCalls:

Classes/Service/OrderItemCleanupService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private function deleteRecordsFromTable(string $tableName, array $recordUids): v
7474

7575
if ($dataHandler->errorLog !== []) {
7676
throw new RuntimeException(
77-
'Could not properly delete records for table: ' . $tableName . ', got the following errors: ' . implode(', ', array_filter($dataHandler->errorLog, 'is_string')),
77+
'Could not properly delete records for table: ' . $tableName . ', got the following errors: ' . implode(', ', array_filter($dataHandler->errorLog, is_string(...))),
7878
1751526777
7979
);
8080
}

Tests/Fixtures/BackendUser.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
return [
6+
'be_users' => [
7+
0 => [
8+
'uid' => '1',
9+
'pid' => '0',
10+
'username' => 'admin',
11+
'password' => '$1$tCrlLajZ$C0sikFQQ3SWaFAZ1Me0Z/1',
12+
'admin' => 1,
13+
],
14+
],
15+
];

Tests/Fixtures/BaseDatabase.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,23 @@
1616
'deleted' => '0',
1717
'is_siteroot' => '1',
1818
],
19+
100 => [
20+
'uid' => '101',
21+
'pid' => '0',
22+
'title' => 'Shop',
23+
'doktype' => PageRepository::DOKTYPE_SYSFOLDER,
24+
'slug' => '/shop-folder',
25+
'sorting' => '128',
26+
'deleted' => '0',
27+
],
28+
104 => [
29+
'uid' => '105',
30+
'pid' => '101',
31+
'title' => 'Orders',
32+
'doktype' => PageRepository::DOKTYPE_SYSFOLDER,
33+
'slug' => '/orders-folder',
34+
'sorting' => '128',
35+
'deleted' => '0',
36+
],
1937
],
2038
];

Tests/Functional/Command/AbstractCommandTestCase.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
* LICENSE file that was distributed with this source code.
1212
*/
1313

14-
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
14+
use Codappix\Typo3PhpDatasets\TestingFramework;
1515
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
1616
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
1717

1818
abstract class AbstractCommandTestCase extends FunctionalTestCase
1919
{
20+
use TestingFramework;
21+
22+
private const FORM_PROTECTION_SESSION_TOKEN = 'testtoken';
23+
2024
protected function setUp(): void
2125
{
2226
$this->testExtensionsToLoad = [
@@ -25,28 +29,26 @@ protected function setUp(): void
2529

2630
$this->coreExtensionsToLoad = [
2731
'typo3/cms-beuser',
32+
'typo3/cms-core',
2833
];
2934

3035
$this->pathsToLinkInTestInstance['typo3conf/ext/cart/Tests/Functional/Fixtures/Import/Sites/'] = 'typo3conf/sites';
3136

3237
parent::setUp();
3338

34-
$backendUser = self::createStub(BackendUserAuthentication::class);
35-
$backendUser->method('isAdmin')->willReturn(true);
36-
$backendUser->method('recordEditAccessInternals')->willReturn(true);
37-
$backendUser->workspace = 0;
38-
$backendUser->user = [
39-
'uid' => 1,
40-
'admin' => true,
41-
];
42-
$GLOBALS['BE_USER'] = $backendUser;
39+
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/BaseDatabase.php');
40+
$this->importPHPDataSet(__DIR__ . '/../../Fixtures/BackendUser.php');
41+
42+
$this->setUpBackendUser(1)
43+
->getSession()
44+
->set('formProtectionSessionToken', self::FORM_PROTECTION_SESSION_TOKEN);
45+
4346
$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->create('en');
4447
}
4548

4649
protected function tearDown(): void
4750
{
4851
unset(
49-
$GLOBALS['BE_USER'],
5052
$GLOBALS['LANG']
5153
);
5254

Tests/Functional/EventListener/Mail/AttachmentFromOrderItemTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ class AttachmentFromOrderItemTest extends FunctionalTestCase
2424

2525
public function setUp(): void
2626
{
27-
$this->testExtensionsToLoad[] = 'extcode/cart';
28-
$this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example';
27+
$this->testExtensionsToLoad = [
28+
'extcode/cart',
29+
'typo3conf/ext/cart/Tests/Fixtures/cart_example',
30+
];
31+
32+
$this->coreExtensionsToLoad = [
33+
'typo3/cms-beuser',
34+
'typo3/cms-core',
35+
];
2936

3037
parent::setUp();
3138

Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,15 @@ class AttachmentFromTypoScriptTest extends FunctionalTestCase
2626

2727
public function setUp(): void
2828
{
29-
$this->testExtensionsToLoad[] = 'extcode/cart';
30-
$this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example';
29+
$this->testExtensionsToLoad = [
30+
'extcode/cart',
31+
'typo3conf/ext/cart/Tests/Fixtures/cart_example',
32+
];
33+
34+
$this->coreExtensionsToLoad = [
35+
'typo3/cms-beuser',
36+
'typo3/cms-core',
37+
];
3138

3239
parent::setUp();
3340

Tests/Functional/Service/MailHandlerTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,15 @@ class MailHandlerTest extends FunctionalTestCase
3434

3535
public function setUp(): void
3636
{
37-
$this->testExtensionsToLoad[] = 'extcode/cart';
38-
$this->testExtensionsToLoad[] = 'typo3conf/ext/cart/Tests/Fixtures/cart_example';
37+
$this->testExtensionsToLoad = [
38+
'extcode/cart',
39+
'typo3conf/ext/cart/Tests/Fixtures/cart_example',
40+
];
41+
42+
$this->coreExtensionsToLoad = [
43+
'typo3/cms-beuser',
44+
'typo3/cms-core',
45+
];
3946

4047
$this->configurationToUseInTestInstance = [
4148
'LOG' => [
@@ -346,7 +353,7 @@ private function getMockBuilderForMailHandlerClass(bool $mailerThrowException =
346353
$mailer->method('send')->willThrowException(new Exception());
347354
}
348355

349-
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(__CLASS__);
356+
$logger = GeneralUtility::makeInstance(LogManager::class)->getLogger(self::class);
350357
$logService = GeneralUtility::makeInstance(
351358
LogService::class,
352359
$logger,

0 commit comments

Comments
 (0)