diff --git a/.travis.yml b/.travis.yml index 40d771e9..fc886ac7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,7 +54,7 @@ jobs: echo "Running unit tests"; echo; echo; - .Build/bin/phpunit --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php --testsuite unit; + .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php --testsuite unit; fi - > @@ -63,7 +63,7 @@ jobs: echo "Running functional tests"; echo; echo; - find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo "Running functional test suite {}"; .Build/bin/phpunit --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'; + find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo "Running functional test suite {}"; .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php {}'; fi - > @@ -179,7 +179,7 @@ jobs: echo "Running unit tests"; echo; echo; - .Build/bin/phpunit --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php --log-junit .Log/junit/unit_$VERSION.xml --coverage-php .Log/coverage/unit_$VERSION.cov --testsuite unit; + .Build/bin/phpunit --bootstrap .Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php --log-junit .Log/junit/unit_$VERSION.xml --coverage-php .Log/coverage/unit_$VERSION.cov --testsuite unit; fi if [ -d "Tests/Functional" ]; then diff --git a/Classes/Aggregate/AbstractInlineContentAggregate.php b/Classes/Aggregate/AbstractInlineContentAggregate.php index 7e6ce922..b893b1c6 100644 --- a/Classes/Aggregate/AbstractInlineContentAggregate.php +++ b/Classes/Aggregate/AbstractInlineContentAggregate.php @@ -30,7 +30,8 @@ protected function getAvailableInlineFields() continue; } foreach ($configuration['tca'] as $field => $fieldConfiguration) { - if ('inline' === $fieldConfiguration['config']['type'] + if (isset($fieldConfiguration['config']['type']) + && 'inline' === $fieldConfiguration['config']['type'] && 'tt_content' === $fieldConfiguration['config']['foreign_table'] ) { if (empty($inlineFields[$table])) { diff --git a/Classes/Aggregate/AbstractOverridesAggregate.php b/Classes/Aggregate/AbstractOverridesAggregate.php index 14014f2a..d7fb1efc 100644 --- a/Classes/Aggregate/AbstractOverridesAggregate.php +++ b/Classes/Aggregate/AbstractOverridesAggregate.php @@ -39,9 +39,12 @@ protected function addTableColumns(array $tableConfiguration) return; } + // allow new TCA parent structure which was introduced in mask 8 + $allowedTableFields = array_merge($this->maskConfiguration[$this->table]['tca'], ['tx_mask_content_parent_uid' => []]); + $newTableFields = array_intersect_key( $tableConfiguration['columns'], - $this->maskConfiguration[$this->table]['tca'] + $allowedTableFields, ); if (empty($newTableFields)) { return; diff --git a/Classes/Aggregate/ContentElementIconAggregate.php b/Classes/Aggregate/ContentElementIconAggregate.php index a4cd5941..7baffc17 100644 --- a/Classes/Aggregate/ContentElementIconAggregate.php +++ b/Classes/Aggregate/ContentElementIconAggregate.php @@ -86,7 +86,7 @@ protected function process() <<registerIcon( '$iconIdentifier', - \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider::class, + \FriendsOfTYPO3\FontawesomeProvider\Imaging\IconProvider\FontawesomeIconProvider::class, [ 'name' => '$iconName', ] diff --git a/Classes/Aggregate/ContentRenderingAggregate.php b/Classes/Aggregate/ContentRenderingAggregate.php index 8221ef5a..ddc5b208 100644 --- a/Classes/Aggregate/ContentRenderingAggregate.php +++ b/Classes/Aggregate/ContentRenderingAggregate.php @@ -168,7 +168,8 @@ protected function addDataProcessing($table, array $fields) $index = 10; foreach ($fields as $field) { if (empty($GLOBALS['TCA'][$table]['columns'][$field]['config']['type']) - || 'inline' !== $GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] + || ('inline' !== $GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] + && 'file' !== $GLOBALS['TCA'][$table]['columns'][$field]['config']['type']) || empty($GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table']) ) { continue; diff --git a/Classes/Aggregate/ExtensionConfigurationAggregate.php b/Classes/Aggregate/ExtensionConfigurationAggregate.php index c1696cc7..5c34e13f 100644 --- a/Classes/Aggregate/ExtensionConfigurationAggregate.php +++ b/Classes/Aggregate/ExtensionConfigurationAggregate.php @@ -102,11 +102,12 @@ protected function addComposerJson() 'type' => 'typo3-cms-extension', 'license' => 'GPL-2.0-or-later', 'require' => [ - 'typo3/cms-backend' => '^' . TYPO3_branch, - 'typo3/cms-core' => '^' . TYPO3_branch, - 'typo3/cms-extbase' => '^' . TYPO3_branch, - 'typo3/cms-fluid' => '^' . TYPO3_branch, - 'typo3/cms-frontend' => '^' . TYPO3_branch, + 'typo3/cms-backend' => '^' . $this->typo3Version->getBranch(), + 'typo3/cms-core' => '^' . $this->typo3Version->getBranch(), + 'typo3/cms-extbase' => '^' . $this->typo3Version->getBranch(), + 'typo3/cms-fluid' => '^' . $this->typo3Version->getBranch(), + 'typo3/cms-frontend' => '^' . $this->typo3Version->getBranch(), + 'friendsoftypo3/fontawesome-provider' => '^1.0', ], 'replace' => [ 'typo3-ter/mask' => 'self.version', diff --git a/Classes/Aggregate/TcaAwareTrait.php b/Classes/Aggregate/TcaAwareTrait.php index 16cb354e..33559978 100644 --- a/Classes/Aggregate/TcaAwareTrait.php +++ b/Classes/Aggregate/TcaAwareTrait.php @@ -17,6 +17,9 @@ * LICENSE file that was distributed with this source code. */ +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; +use TYPO3\CMS\Core\Utility\VersionNumberUtility; + trait TcaAwareTrait { use LanguageAwareTrait; @@ -86,17 +89,33 @@ protected function addFieldSqlDefinition(array $tableConfiguration, $field) && 'inline' === $this->maskConfiguration[$table]['tca'][$field]['config']['type'] && 'tt_content' === $this->maskConfiguration[$table]['tca'][$field]['config']['foreign_table'] ) { - $this->addSqlDefinition( - 'tt_content', - $field . '_parent', - $definition - ); - $this->addSqlDefinitions( - 'tt_content', - [ - 'KEY ' . $field . '_parent' => '(' . $field . '_parent,pid,deleted)', - ] - ); + // allow new TCA parent structure which was introduced in mask 8 + $maskVersion = preg_replace('/[^0-9\.]/', '', ExtensionManagementUtility::getExtensionVersion('mask')); + if (version_compare($maskVersion, '8.0.0', '>=')) { + $this->maskConfiguration['tt_content']['tx_mask_content_parent_uid'] = [ + 'config' => [ + 'type' => 'passthrough', + ], + ]; + $this->addSqlDefinitions('tt_content', [ + 'tx_mask_content_parent_uid' => 'int(11) unsigned DEFAULT \'0\' NOT NULL', + 'tx_mask_content_role' => 'varchar(255) DEFAULT \'\' NOT NULL', + 'tx_mask_content_tablenames' => 'varchar(255) DEFAULT \'\' NOT NULL', + 'KEY tx_mask_content_parent_uid' => '(tx_mask_content_parent_uid)', + ]); + } else { + $this->addSqlDefinition( + 'tt_content', + $field . '_parent', + $definition + ); + $this->addSqlDefinitions( + 'tt_content', + [ + 'KEY ' . $field . '_parent' => '(' . $field . '_parent,pid,deleted)', + ] + ); + } } } diff --git a/Classes/CodeGenerator/HtmlCodeGenerator.php b/Classes/CodeGenerator/HtmlCodeGenerator.php index 634a16a4..4b0ea160 100644 --- a/Classes/CodeGenerator/HtmlCodeGenerator.php +++ b/Classes/CodeGenerator/HtmlCodeGenerator.php @@ -18,8 +18,7 @@ * LICENSE file that was distributed with this source code. */ -use MASK\Mask\Domain\Repository\StorageRepository; -use MASK\Mask\Helper\FieldHelper; +use MASK\Mask\Definition\TableDefinitionCollection; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -27,25 +26,8 @@ */ class HtmlCodeGenerator { - /** - * @var FieldHelper - */ - protected $fieldHelper; - - /** - * @var StorageRepository - */ - protected $storageRepository; - - public function __construct(StorageRepository $storageRepository = null, FieldHelper $fieldHelper = null) + public function __construct(protected TableDefinitionCollection $tableDefinitionCollection) { - $this->storageRepository = $storageRepository ?: GeneralUtility::makeInstance(StorageRepository::class); - - if (method_exists($this->storageRepository, 'getFormType')) { - $this->fieldHelper = $this->storageRepository; - } else { - $this->fieldHelper = $fieldHelper ?: GeneralUtility::makeInstance(FieldHelper::class, $this->storageRepository); - } } /** @@ -57,7 +39,7 @@ public function __construct(StorageRepository $storageRepository = null, FieldHe */ public function generateHtml($key, $table = 'tt_content') { - $storage = $this->storageRepository->loadElement('tt_content', $key); + $storage = $this->tableDefinitionCollection->loadElement('tt_content', $key)->toArray(); $html = ''; if (!empty($storage['tca'])) { foreach ($storage['tca'] as $fieldKey => $fieldConfig) { @@ -83,7 +65,7 @@ public function generateHtml($key, $table = 'tt_content') */ protected function generateFieldHtml($fieldKey, $elementKey, $table = 'tt_content', $datafield = 'data') { - $formType = strtolower($this->fieldHelper->getFormType($fieldKey, $elementKey, $table)); + $formType = strtolower((string)$this->tableDefinitionCollection->getFieldType($fieldKey, $table, $elementKey)); if (in_array($formType, ['linebreak', 'tab'], true)) { return ''; } @@ -161,11 +143,11 @@ protected function generateFieldHtml($fieldKey, $elementKey, $table = 'tt_conten break; case 'inline': - $inlineFields = $this->storageRepository->loadInlineFields($fieldKey); + $inlineFields = $this->tableDefinitionCollection->loadInlineFields($fieldKey, $elementKey); $inlineFieldsHtml = ''; $datafieldInline = strtr($datafield, '.', '_'); if (!empty($inlineFields)) { - foreach ($inlineFields as $inlineField) { + foreach ($inlineFields->toArray() as $inlineField) { $inlineFieldsHtml .= $this->generateFieldHtml($inlineField['maskKey'], $elementKey, $fieldKey, $datafieldInline . '_item.data'); } } diff --git a/Classes/Controller/ExportController.php b/Classes/Controller/ExportController.php index 2bbfef9a..03f80b2b 100644 --- a/Classes/Controller/ExportController.php +++ b/Classes/Controller/ExportController.php @@ -33,11 +33,16 @@ use IchHabRecht\MaskExport\FileCollection\PlainTextFileCollection; use IchHabRecht\MaskExport\FileCollection\SqlFileCollection; use MASK\Mask\Domain\Repository\StorageRepository; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Finder\Finder; +use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Messaging\AbstractMessage; +use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Http\ForwardResponse; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extensionmanager\Domain\Model\Extension; @@ -81,25 +86,35 @@ class ExportController extends ActionController */ protected $maskConfiguration; - public function __construct(StorageRepository $storageRepository) - { + protected ?ModuleTemplate $moduleTemplate = null; + + public function __construct( + StorageRepository $storageRepository, + protected readonly PageRenderer $pageRenderer, + protected readonly ModuleTemplateFactory $moduleTemplateFactory + ) { $this->maskConfiguration = (array)$storageRepository->load(); } - /** - * @param string $vendorName - * @param string $extensionName - * @param array $elements - */ - public function listAction($vendorName = '', $extensionName = '', $elements = []) + public function setModuleTemplate(ModuleTemplate $moduleTemplate) { + $this->moduleTemplate = $moduleTemplate; + } + + public function listAction( + string $vendorName = '', + string $extensionName = '', + array $elements = [] + ): ResponseInterface { $extensionName = $extensionName ?: $this->getExtensionName(); $vendorName = $vendorName ?: $this->getVendorName(); $elements = $elements ?: $this->getElements(); $files = $this->getFiles($vendorName, $extensionName, $elements); - $this->view->assignMultiple( + $moduleTemplate = $this->getModuleTemplate(); + $moduleTemplate->setTitle('Mask Export'); + $moduleTemplate->assignMultiple( [ 'composerMode' => Environment::isComposerMode(), 'vendorName' => $vendorName, @@ -109,15 +124,17 @@ public function listAction($vendorName = '', $extensionName = '', $elements = [] 'files' => $files, ] ); + + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/MaskExport/Toggler'); + $this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal'); + return $moduleTemplate->renderResponse(); } - /** - * @param string $vendorName - * @param string $extensionName - * @param array $elements - */ - public function saveAction($vendorName = '', $extensionName = '', $elements = []) - { + public function saveAction( + string $vendorName = '', + string $extensionName = '', + array $elements = [] + ): ResponseInterface { if (empty($vendorName)) { $vendorName = $this->getVendorName(); } else { @@ -135,22 +152,17 @@ public function saveAction($vendorName = '', $extensionName = '', $elements = [] $backendUser->writeUC(); $action = 'list'; - if ($this->request->hasArgument('submit')) { - $submit = strtolower($this->request->getArgument('submit')); + if ($this->request->hasArgument('submitted')) { + $submit = strtolower($this->request->getArgument('submitted')); if (in_array($submit, ['download', 'install'], true)) { $action = $submit; } } - $this->forward($action, null, null, ['vendorName' => $vendorName, 'extensionName' => $extensionName, 'elements' => $elements]); + return new ForwardResponse($action); } - /** - * @param string $vendorName - * @param string $extensionName - * @param array $elements - */ - public function downloadAction($vendorName, $extensionName, $elements) + public function downloadAction(string $vendorName, string $extensionName, array $elements): void { $files = $this->getFiles($vendorName, $extensionName, $elements); @@ -174,25 +186,23 @@ public function downloadAction($vendorName, $extensionName, $elements) exit; } - /** - * @param string $vendorName - * @param string $extensionName - * @param array $elements - */ - public function installAction($vendorName, $extensionName, $elements) + public function installAction(string $vendorName, string $extensionName, array $elements): ResponseInterface { - $paths = Extension::returnInstallPaths(); - if (empty($paths['Local']) || !file_exists($paths['Local'])) { - throw new \RuntimeException('Local extension install path is missing', 1500061028); + if (Environment::isComposerMode()) { + $vendorFolder = strtolower($vendorName) . '/' . $extensionName; + $extensionPath = Environment::getComposerRootPath() . '/vendor/' . $vendorFolder; + } else { + $paths = Extension::returnInstallPaths(); + if (empty($paths['Local']) || !file_exists($paths['Local'])) { + throw new \RuntimeException('Local extension install path is missing', 1500061028); + } + $extensionPath = $paths['Local'] . $extensionName; } - - $extensionPath = $paths['Local'] . $extensionName; $files = $this->getFiles($vendorName, $extensionName, $elements); $this->writeExtensionFilesToPath($files, $extensionPath); - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); if (!Environment::isComposerMode()) { - $managementService = $objectManager->get(ExtensionManagementService::class); + $managementService = GeneralUtility::makeInstance(ExtensionManagementService::class); $managementService->reloadPackageInformation($extensionName); $extension = $managementService->getExtension($extensionName); $installInformation = $managementService->installExtension($extension); @@ -211,17 +221,17 @@ public function installAction($vendorName, $extensionName, $elements) ); } } else { - $installUtility = $objectManager->get(InstallUtility::class); + $installUtility = GeneralUtility::makeInstance(InstallUtility::class); $installUtility->reloadCaches(); $this->addFlashMessage( '', - 'Extension files of ' . $extensionName . ' were written successfully', + 'Extension files were succesfully written to ' . $vendorFolder, AbstractMessage::OK ); } - $this->redirect('list'); + return $this->redirect('list'); } /** @@ -542,4 +552,13 @@ protected function getBackendUser() { return $GLOBALS['BE_USER']; } + + protected function getModuleTemplate(): ModuleTemplate + { + if (!$this->moduleTemplate) { + $this->moduleTemplate = $this->moduleTemplateFactory->create($this->request); + } + + return $this->moduleTemplate; + } } diff --git a/Classes/FlagResolver/PhpFileFlag/DefinedTypo3ModeFlag.php b/Classes/FlagResolver/PhpFileFlag/DefinedTypo3ModeFlag.php index b6ecd0ba..c66c4604 100644 --- a/Classes/FlagResolver/PhpFileFlag/DefinedTypo3ModeFlag.php +++ b/Classes/FlagResolver/PhpFileFlag/DefinedTypo3ModeFlag.php @@ -38,7 +38,7 @@ public function isEnabled($flags) public function execute($content) { return << [ + 'parent' => 'tools', + 'position' => ['after' => 'mask_module'], + 'access' => 'admin', + 'path' => '/module/MaskExport', + 'icon' => 'EXT:mask_export/Resources/Public/Icons/Extension.svg', + 'labels' => 'LLL:EXT:mask_export/Resources/Private/Language/locallang_mod.xlf', + 'extensionName' => 'MaskExport', + 'controllerActions' => [ + \IchHabRecht\MaskExport\Controller\ExportController::class => [ + 'list', 'save', 'download', 'install' + ] + ], + ], +]; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml new file mode 100644 index 00000000..bbd05cd7 --- /dev/null +++ b/Configuration/Services.yaml @@ -0,0 +1,11 @@ +services: + _defaults: + autowire: true + autoconfigure: true + public: false + + IchHabRecht\MaskExport\: + resource: '../Classes/*' + + IchHabRecht\MaskExport\CodeGenerator\HtmlCodeGenerator: + public: true diff --git a/Resources/Private/Layouts/Default.html b/Resources/Private/Layouts/Default.html index 05ed24ea..353e6643 100644 --- a/Resources/Private/Layouts/Default.html +++ b/Resources/Private/Layouts/Default.html @@ -1,8 +1,6 @@ - -
-
-
- -
+
+
+
+
- +
diff --git a/Resources/Private/Templates/Export/List.html b/Resources/Private/Templates/Export/List.html index 6ebd3088..b7d88d66 100644 --- a/Resources/Private/Templates/Export/List.html +++ b/Resources/Private/Templates/Export/List.html @@ -3,6 +3,8 @@

Mask Export

+ +
@@ -32,17 +34,17 @@

Mask Export

- - + + - + - + - +
diff --git a/Tests/Functional/Controller/AbstractExportControllerTestCase.php b/Tests/Functional/Controller/AbstractExportControllerTestCase.php index b0162580..282fa461 100644 --- a/Tests/Functional/Controller/AbstractExportControllerTestCase.php +++ b/Tests/Functional/Controller/AbstractExportControllerTestCase.php @@ -18,35 +18,51 @@ */ use IchHabRecht\MaskExport\Controller\ExportController; -use Nimut\TestingFramework\TestCase\FunctionalTestCase; use PHPUnit\Framework\MockObject\MockBuilder; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; +use TYPO3\CMS\Backend\Module\ModuleProvider; +use TYPO3\CMS\Backend\Routing\Route; +use TYPO3\CMS\Backend\Routing\UriBuilder; +use TYPO3\CMS\Backend\Template\ModuleTemplate; +use TYPO3\CMS\Backend\View\BackendViewFactory; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; +use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder; use TYPO3\CMS\Core\Database\Schema\SchemaMigrator; use TYPO3\CMS\Core\Database\Schema\SqlReader; +use TYPO3\CMS\Core\Http\ServerRequest; +use TYPO3\CMS\Core\Imaging\IconFactory; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Localization\LanguageStore; use TYPO3\CMS\Core\Localization\Locales; use TYPO3\CMS\Core\Localization\LocalizationFactory; +use TYPO3\CMS\Core\Messaging\FlashMessageService; use TYPO3\CMS\Core\Package\PackageManager; +use TYPO3\CMS\Core\Page\PageRenderer; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\View\FluidViewAdapter; +use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters; use TYPO3\CMS\Extbase\Mvc\Request; use TYPO3\CMS\Extbase\Mvc\Response; use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext; +use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory; use TYPO3\CMS\Fluid\View\TemplateView; +use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; abstract class AbstractExportControllerTestCase extends FunctionalTestCase { + use ProphecyTrait; + /** * @var bool */ protected $runTestInSeparateProcess = true; - /** - * @var array - */ - protected $configurationToUseInTestInstance = [ + protected array $configurationToUseInTestInstance = [ 'EXTENSIONS' => [ 'mask' => [ 'json' => 'typo3conf/ext/mask_export/Tests/Functional/Fixtures/Configuration/mask-default.json', @@ -58,22 +74,13 @@ abstract class AbstractExportControllerTestCase extends FunctionalTestCase ], ]; - /** - * @var array - */ - protected $coreExtensionsToLoad = [ + protected array $coreExtensionsToLoad = [ 'fluid_styled_content', ]; - /** - * @var array - */ - protected $files = []; + protected array $files = []; - /** - * @var array - */ - protected $testExtensionsToLoad = [ + protected array $testExtensionsToLoad = [ 'typo3conf/ext/mask', 'typo3conf/ext/mask_export', ]; @@ -85,38 +92,39 @@ protected function setUp(): void { parent::setUp(); - $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $GLOBALS['LANG'] = $this->getLanguageService(); + $GLOBALS['BE_USER'] = $this->createMock(BackendUserAuthentication::class); - $request = new Request('IchHabRecht\\MaskExport\\Controller\\ExportController'); - $request->setControllerObjectName('IchHabRecht\\MaskExport\\Controller\\ExportController'); - $request->setControllerActionName('list'); - $request->setFormat('html'); - if (method_exists($request, 'setControllerAliasToClassNameMapping')) { - $request->setControllerAliasToClassNameMapping(['Export' => ExportController::class]); - } + $route = new Route('', []); + $route->setOption('packageName', 'mask_export'); + + $serverRequest = new ServerRequest(); + $serverRequest = $serverRequest->withAttribute('extbase', new ExtbaseRequestParameters()); + $serverRequest = $serverRequest->withAttribute('route', $route); + $serverRequest = $serverRequest->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_FE); + + $request = new Request($serverRequest); + $request = $request->withControllerObjectName('IchHabRecht\\MaskExport\\Controller\\ExportController'); + $request = $request->withControllerActionName('list'); + $request = $request->withFormat('html'); $response = null; if (class_exists('TYPO3\\CMS\\Extbase\\Mvc\\Response')) { $response = new Response(); } - $view = $objectManager->get(TemplateView::class); + $renderingContext = GeneralUtility::makeInstance(RenderingContextFactory::class)->create(); + $renderingContext->setControllerName('Export'); + $renderingContext->setControllerAction('list'); + + $view = GeneralUtility::makeInstance(TemplateView::class, $renderingContext); $view->setLayoutRootPaths(['EXT:mask_export/Resources/Private/Layouts']); $view->setTemplateRootPaths(['EXT:mask_export/Tests/Functional/Fixtures/Templates']); - if (method_exists(GeneralUtility::class, 'getContainer')) { - $container = GeneralUtility::getContainer(); - $container->set(TemplateView::class, $view); - } else { - GeneralUtility::addInstance(TemplateView::class, $view); - } - $subject = $objectManager->get(ExportController::class); + $subject = GeneralUtility::makeInstance(ExportController::class); + $subject->setModuleTemplate($this->buildModuleTemplateWithViewAndRequest($view, $request)); $response = $subject->processRequest($request, $response) ?: $response; - $closure = \Closure::bind(function () use ($view) { - return $view->baseRenderingContext; - }, null, TemplateView::class); - $renderingContext = $closure(); $variables = $renderingContext->getVariableProvider(); $this->files = $variables->get('files'); } @@ -181,9 +189,30 @@ protected function getLanguageService(bool $mockBuilder = false) ); } - $languageService = new LanguageService(new Locales(), new LocalizationFactory(new LanguageStore($packageManager), $cacheManagerProphecy->reveal()), $cacheFrontendProphecy->reveal()); + $languageService = new LanguageService( + new Locales(), + new LocalizationFactory( + new LanguageStore($packageManager), + $cacheManagerProphecy->reveal() + ), + $cacheFrontendProphecy->reveal() + ); $languageService->init('default'); return $languageService; } + + protected function buildModuleTemplateWithViewAndRequest(TemplateView $view, Request $request): ModuleTemplate + { + return new ModuleTemplate( + GeneralUtility::makeInstance(PageRenderer::class), + GeneralUtility::makeInstance(IconFactory::class), + GeneralUtility::makeInstance(UriBuilder::class), + GeneralUtility::makeInstance(ModuleProvider::class), + GeneralUtility::makeInstance(FlashMessageService::class), + GeneralUtility::makeInstance(ExtensionConfiguration::class), + new FluidViewAdapter($view), + $request + ); + } } diff --git a/Tests/Functional/Fixtures/Templates/Export/List.html b/Tests/Functional/Fixtures/Templates/Export/List.html index e69de29b..17eba4b2 100644 --- a/Tests/Functional/Fixtures/Templates/Export/List.html +++ b/Tests/Functional/Fixtures/Templates/Export/List.html @@ -0,0 +1 @@ + diff --git a/Tests/Unit/FileCollection/PhpFileCollectionTest.php b/Tests/Unit/FileCollection/PhpFileCollectionTest.php index e1a65eb3..85297802 100644 --- a/Tests/Unit/FileCollection/PhpFileCollectionTest.php +++ b/Tests/Unit/FileCollection/PhpFileCollectionTest.php @@ -20,11 +20,14 @@ use IchHabRecht\MaskExport\Aggregate\PhpAwareInterface; use IchHabRecht\MaskExport\FileCollection\PhpFileCollection; use IchHabRecht\MaskExport\FlagResolver\PhpFileFlagResolver; -use Nimut\TestingFramework\TestCase\UnitTestCase; +use Prophecy\PhpUnit\ProphecyTrait; use TYPO3\CMS\Core\Service\DependencyOrderingService; +use TYPO3\TestingFramework\Core\Unit\UnitTestCase; class PhpFileCollectionTest extends UnitTestCase { + use ProphecyTrait; + /** * @test */ @@ -60,7 +63,7 @@ public function getFilesCombinesPhpFileFlags() $files = $phpFileCollection->getFiles(); $this->assertArrayHasKey('ext_tables.php', $files); - $this->assertStringContainsString('defined(\'TYPO3_MODE\') || die();', $files['ext_tables.php']); + $this->assertStringContainsString('defined(\'TYPO3\') || die();', $files['ext_tables.php']); $this->assertStringContainsString('call_user_func(static function () {', $files['ext_tables.php']); } } diff --git a/composer.json b/composer.json index eb1423e7..2f944c15 100644 --- a/composer.json +++ b/composer.json @@ -19,17 +19,18 @@ } ], "require": { - "php": "^7.2 || ^8.0", - "typo3/cms-core": "^9.5 || ^10.4.16 || ^11.5", - "typo3/cms-extbase": "^9.5 || ^10.4.16 || ^11.5", - "typo3/cms-extensionmanager": "^9.5 || ^10.4.16 || ^11.5", - "typo3/cms-fluid": "^9.5 || ^10.4.16 || ^11.5", - "mask/mask": "^4.0 || ^5.0 || ^6.0 || ^7.1" + "php": "^8.0", + "typo3/cms-core": "^11.5 || ^12.4", + "typo3/cms-extbase": "^11.5 || ^12.4", + "typo3/cms-extensionmanager": "^11.5 || ^12.4", + "typo3/cms-fluid": "^11.5 || ^12.4", + "mask/mask": "^8.0" }, "require-dev": { - "typo3/cms-fluid-styled-content": "^9.5 || ^10.4.16 || ^11.5", - "nimut/testing-framework": "6.x-dev", - "phpunit/phpunit": "^8.5" + "typo3/cms-fluid-styled-content": "^11.5 || ^12.4", + "typo3/testing-framework": "^7.0", + "phpunit/phpunit": "^9.6", + "phpspec/prophecy-phpunit": "^2.0" }, "replace": { "typo3-ter/mask-export": "self.version" diff --git a/ext_emconf.php b/ext_emconf.php index d38dd51d..7ec0889e 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -23,8 +23,8 @@ array ( 'depends' => array ( - 'typo3' => '9.5.0-11.5.99', - 'mask' => '4.0.0-7.99.99', + 'typo3' => '11.5.0-12.4.99', + 'mask' => '8.0.0-8.99.99', ), 'conflicts' => array ( diff --git a/ext_tables.php b/ext_tables.php index a5dbcfea..d1531fa6 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,6 +1,6 @@