TYPO3-Caretaker / caretaker

TYPO3 extension caretaker
https://extensions.typo3.org/extension/caretaker/
26 stars 23 forks source link

Location to flexform of test classes not useable with Namespacing #66

Open opi99 opened 7 years ago

opi99 commented 7 years ago

If you have a namespaced class the classname is used as key to build path to FlexForm. This then contains "\" which validates as not accessible.

Possible way to patch is adding a new parameter to registerCaretakerTestService

    /**
     * Adds a service for caretaker. The service is registered and the type and flexform is added to the testconf
     *
     * @param string $extKey kex of the extension wich is adding the service
     * @param string $path path to the flexform and service class without slahes before and after
     * @param string $key key wich is used for to identify the service
     * @param string $title title of the testservice
     * @param string $description description of the testservice
     * @param string $dsFile File to the FlexForm datastructure
     */
    public static function registerCaretakerTestService($extKey, $path, $key, $title, $description = '', $dsFile = null) {
        // load deferred registered test services from EXT:caretaker_instance, if that was loaded before EXT:caretaker
        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('caretaker_instance')
                && class_exists('tx_caretakerinstance_ServiceHelper')
                && count(tx_caretakerinstance_ServiceHelper::$deferredTestServicesToRegister) > 0
        ) {
            $servicesToRegister = tx_caretakerinstance_ServiceHelper::$deferredTestServicesToRegister;
            tx_caretakerinstance_ServiceHelper::$deferredTestServicesToRegister = array();
            foreach ($servicesToRegister as $service) {
                self::registerCaretakerTestService($service[0], $service[1], $service[2], $service[3], $service[4]);
            }
        }

        if (!$GLOBALS['T3_SERVICES']['caretaker_test_service'][$key]) {
            // Register test service
            \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addService(
                    'caretaker',
                    'caretaker_test_service',
                    $key,
                    array(
                            'title' => $title,
                            'description' => $description,
                            'subtype' => $key,
                            'available' => TRUE,
                            'priority' => 50,
                            'quality' => 50,
                            'os' => '',
                            'exec' => '',
                            'classFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($extKey) . $path . '/class.' . $key . 'TestService.php',
                            'className' => $key . 'TestService',
                    )
            );

            // Add testtype to TCA
            self::$tcaTestServiceItems[] = array($title, $key);

            if ($dsFile) {
                self::$tcaTestConfigDs[$key] = $dsFile;
            } else {
                // Add flexform to service-item
                self::$tcaTestConfigDs[$key] = 'FILE:EXT:' . $extKey . '/' . $path . '/' . 'ds.' . $key . 'TestService.xml';
            }
        }
    }