|
19 | 19 |
|
20 | 20 | use PHPUnit\Framework\Attributes\Test; |
21 | 21 | use TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController; |
| 22 | +use TYPO3\CMS\Core\Service\DependencyOrderingService; |
22 | 23 | use TYPO3\TestingFramework\Core\Unit\UnitTestCase; |
23 | 24 |
|
24 | 25 | final class NewContentElementControllerTest extends UnitTestCase |
@@ -283,4 +284,212 @@ public function mergeContentElementWizardsWithPageTSConfigWizardsRemovesDuplicat |
283 | 284 |
|
284 | 285 | self::assertSame($expected, $result); |
285 | 286 | } |
| 287 | + |
| 288 | + #[Test] |
| 289 | + public function contentElementWizardsAreLinkedTogetherWithAfterPosition(): void |
| 290 | + { |
| 291 | + $GLOBALS['TCA']['tt_content']['ctrl']['type'] = 'CType'; |
| 292 | + $GLOBALS['TCA']['tt_content']['columns']['CType'] = [ |
| 293 | + 'config' => [ |
| 294 | + 'type' => 'select', |
| 295 | + 'renderType' => 'selectSingle', |
| 296 | + 'items' => [ |
| 297 | + [ |
| 298 | + 'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header', |
| 299 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header.description', |
| 300 | + 'value' => 'header', |
| 301 | + 'icon' => 'content-header', |
| 302 | + 'group' => 'default', |
| 303 | + ], |
| 304 | + [ |
| 305 | + 'label' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text', |
| 306 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text.description', |
| 307 | + 'value' => 'text', |
| 308 | + 'icon' => 'content-text', |
| 309 | + 'group' => 'default', |
| 310 | + ], |
| 311 | + ], |
| 312 | + 'itemGroups' => [ |
| 313 | + 'default' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.default', |
| 314 | + 'lists' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.lists', |
| 315 | + 'menu' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.menu', |
| 316 | + 'forms' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.forms', |
| 317 | + 'special' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.special', |
| 318 | + 'plugins' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.plugins', |
| 319 | + ], |
| 320 | + ], |
| 321 | + ]; |
| 322 | + $expected = [ |
| 323 | + 'default.' => [ |
| 324 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.default', |
| 325 | + 'elements.' => [ |
| 326 | + 'header.' => [ |
| 327 | + 'iconIdentifier' => 'content-header', |
| 328 | + 'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header', |
| 329 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header.description', |
| 330 | + 'defaultValues' => [ |
| 331 | + 'CType' => 'header', |
| 332 | + ], |
| 333 | + ], |
| 334 | + 'text.' => [ |
| 335 | + 'iconIdentifier' => 'content-text', |
| 336 | + 'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text', |
| 337 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text.description', |
| 338 | + 'defaultValues' => [ |
| 339 | + 'CType' => 'text', |
| 340 | + ], |
| 341 | + ], |
| 342 | + ], |
| 343 | + ], |
| 344 | + 'lists.' => [ |
| 345 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.lists', |
| 346 | + 'contentElementAfter' => 'default', |
| 347 | + ], |
| 348 | + 'menu.' => [ |
| 349 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.menu', |
| 350 | + 'contentElementAfter' => 'lists', |
| 351 | + ], |
| 352 | + 'forms.' => [ |
| 353 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.forms', |
| 354 | + 'contentElementAfter' => 'menu', |
| 355 | + ], |
| 356 | + 'special.' => [ |
| 357 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.special', |
| 358 | + 'contentElementAfter' => 'forms', |
| 359 | + ], |
| 360 | + 'plugins.' => [ |
| 361 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.plugins', |
| 362 | + 'contentElementAfter' => 'special', |
| 363 | + ], |
| 364 | + ]; |
| 365 | + $result = (new \ReflectionClass(NewContentElementController::class)) |
| 366 | + ->getMethod('loadAvailableWizards') |
| 367 | + ->invokeArgs( |
| 368 | + $this->createMock( |
| 369 | + NewContentElementController::class |
| 370 | + ), |
| 371 | + [] |
| 372 | + ); |
| 373 | + self::assertSame($expected, $result); |
| 374 | + } |
| 375 | + |
| 376 | + #[Test] |
| 377 | + public function contentElementWizardsAreOrderedByContentElementAfter(): void |
| 378 | + { |
| 379 | + $wizards = [ |
| 380 | + 'default.' => [ |
| 381 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.default', |
| 382 | + 'elements.' => [ |
| 383 | + 'header.' => [ |
| 384 | + 'iconIdentifier' => 'content-header', |
| 385 | + 'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header', |
| 386 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header.description', |
| 387 | + 'defaultValues' => [ |
| 388 | + 'CType' => 'header', |
| 389 | + ], |
| 390 | + ], |
| 391 | + 'text.' => [ |
| 392 | + 'iconIdentifier' => 'content-text', |
| 393 | + 'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text', |
| 394 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text.description', |
| 395 | + 'defaultValues' => [ |
| 396 | + 'CType' => 'text', |
| 397 | + ], |
| 398 | + ], |
| 399 | + ], |
| 400 | + ], |
| 401 | + 'forms.' => [ |
| 402 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.forms', |
| 403 | + 'contentElementAfter' => [ |
| 404 | + 'menu.', |
| 405 | + ], |
| 406 | + ], |
| 407 | + 'menu.' => [ |
| 408 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.menu', |
| 409 | + 'contentElementAfter' => [ |
| 410 | + 'lists.', |
| 411 | + ], |
| 412 | + ], |
| 413 | + 'plugins.' => [ |
| 414 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.plugins', |
| 415 | + 'contentElementAfter' => [ |
| 416 | + 'special.', |
| 417 | + ], |
| 418 | + ], |
| 419 | + 'lists.' => [ |
| 420 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.lists', |
| 421 | + 'contentElementAfter' => [ |
| 422 | + 'default.', |
| 423 | + ], |
| 424 | + ], |
| 425 | + 'special.' => [ |
| 426 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.special', |
| 427 | + 'contentElementAfter' => [ |
| 428 | + 'forms.', |
| 429 | + ], |
| 430 | + ], |
| 431 | + ]; |
| 432 | + $expected = [ |
| 433 | + 'default.' => [ |
| 434 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.default', |
| 435 | + 'elements.' => [ |
| 436 | + 'header.' => [ |
| 437 | + 'iconIdentifier' => 'content-header', |
| 438 | + 'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header', |
| 439 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.header.description', |
| 440 | + 'defaultValues' => [ |
| 441 | + 'CType' => 'header', |
| 442 | + ], |
| 443 | + ], |
| 444 | + 'text.' => [ |
| 445 | + 'iconIdentifier' => 'content-text', |
| 446 | + 'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text', |
| 447 | + 'description' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:CType.text.description', |
| 448 | + 'defaultValues' => [ |
| 449 | + 'CType' => 'text', |
| 450 | + ], |
| 451 | + ], |
| 452 | + ], |
| 453 | + ], |
| 454 | + 'lists.' => [ |
| 455 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.lists', |
| 456 | + 'after' => [ |
| 457 | + 'default.', |
| 458 | + ], |
| 459 | + ], |
| 460 | + 'menu.' => [ |
| 461 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.menu', |
| 462 | + 'after' => [ |
| 463 | + 'lists.', |
| 464 | + ], |
| 465 | + ], |
| 466 | + 'forms.' => [ |
| 467 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.forms', |
| 468 | + 'after' => [ |
| 469 | + 'menu.', |
| 470 | + ], |
| 471 | + ], |
| 472 | + 'special.' => [ |
| 473 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.special', |
| 474 | + 'after' => [ |
| 475 | + 'forms.', |
| 476 | + ], |
| 477 | + ], |
| 478 | + 'plugins.' => [ |
| 479 | + 'header' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:group.plugins', |
| 480 | + 'after' => [ |
| 481 | + 'special.', |
| 482 | + ], |
| 483 | + ], |
| 484 | + ]; |
| 485 | + $result = (new \ReflectionClass(NewContentElementController::class)) |
| 486 | + ->getMethod('orderWizards') |
| 487 | + ->invokeArgs( |
| 488 | + $this->createMock( |
| 489 | + NewContentElementController::class |
| 490 | + ), |
| 491 | + [$wizards, new DependencyOrderingService()] |
| 492 | + ); |
| 493 | + self::assertSame($expected, $result); |
| 494 | + } |
286 | 495 | } |
0 commit comments