diff --git a/.gitattributes b/.gitattributes index d0da7c5..fe00658 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ /Tests export-ignore /.* export-ignore /ExtensionBuilder.json export-ignore +/phpstan.neon export-ignore diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml new file mode 100644 index 0000000..91f97dc --- /dev/null +++ b/.github/workflows/Release.yml @@ -0,0 +1,52 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + publish: + name: Publish new version to TER + if: startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-20.04 + env: + TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Check tag + run: | + if ! [[ ${{ github.ref }} =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then + exit 1 + fi + + - name: Get version + id: get-version + run: echo "version=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV + + - name: Get comment + id: get-comment + run: | + readonly local comment=$(git tag -n10 -l ${{ env.version }} | sed "s/^[0-9.]*[ ]*//g") + + if [[ -z "${comment// }" ]]; then + echo "comment=Released version ${{ env.version }} of ${{ env.TYPO3_EXTENSION_KEY }}" >> $GITHUB_ENV + else + echo "comment=$comment" >> $GITHUB_ENV + fi + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + extensions: intl, mbstring, json, zip, curl + tools: composer:v2 + + - name: Install tailor + run: composer global require typo3/tailor --prefer-dist --no-progress + + - name: Publish to TER + run: php ~/.composer/vendor/bin/tailor ter:publish --comment "${{ env.comment }}" ${{ env.version }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..522dd74 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,65 @@ +name: Testing calendarize_external +on: [push, pull_request] +jobs: + build: + strategy: + fail-fast: false + matrix: + php: ["7.4", "8.1", "8.2"] + typo3: ["10.4","11.5"] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer + extensions: pdo + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Get composer cache directory + id: composercache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install the right version + run: composer require "typo3/cms-core:^${{ matrix.typo3 }}" "typo3/cms-workspaces:^${{ matrix.typo3 }}" -W + + - name: Unit Tests with phpunit + run: composer run tool:phpunit -- + + # start db + - name: Start MySQL + run: sudo /etc/init.d/mysql start + + # functional tests + - name: Functional Tests + run: | + export typo3DatabaseName="typo3"; + export typo3DatabaseHost="127.0.0.1"; + export typo3DatabaseUsername="root"; + export typo3DatabasePassword="root"; + composer run tool:phpunit:functional -- + + - name: Run PHP CS Fixer checks + run: composer run tool:php-cs-fixer-check + +# - name: Run DepTrac +# run: composer run tool:deptrac + + - name: Reset composer.json + run: git checkout composer.json; diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8d15c..3a9427a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +[TASK] prepare CI tools 0afd597 2023-10-31 Falko Trojahn + [BUGFIX] console output shows calendar and pageIds even if not run due to errors d5d778c 2023-10-30 Falko Trojahn [TASK] tca evaluation class for error_count reset #3679 1f47a1e 2023-02-10 Falko Trojahn diff --git a/Classes/Command/CalImportCommandController.php b/Classes/Command/CalImportCommandController.php index 69ddfd6..f4a44e5 100644 --- a/Classes/Command/CalImportCommandController.php +++ b/Classes/Command/CalImportCommandController.php @@ -21,16 +21,11 @@ use Symfony\Component\Console\Style\SymfonyStyle; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; -use TYPO3\CMS\Core\Database\Query\Restriction\EndTimeRestriction; -use TYPO3\CMS\Core\Database\Query\Restriction\HiddenRestriction; -use TYPO3\CMS\Core\Database\Query\Restriction\StartTimeRestriction; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\MathUtility; class CalImportCommandController extends Command { - /** * @var ICalServiceInterface */ @@ -59,17 +54,16 @@ class CalImportCommandController extends Command /** * ImportCommandController constructor. * - * @param ICalServiceInterface $iCalService + * @param ICalServiceInterface $iCalService * @param EventDispatcherInterface $eventDispatcher - * @param IndexerService $indexerService + * @param IndexerService $indexerService */ public function __construct( - ICalServiceInterface $iCalService, + ICalServiceInterface $iCalService, EventDispatcherInterface $eventDispatcher, - IndexerService $indexerService, - ICalUrlService $iCalUrlService - ) - { + IndexerService $indexerService, + ICalUrlService $iCalUrlService + ) { $this->iCalService = $iCalService; $this->eventDispatcher = $eventDispatcher; $this->indexerService = $indexerService; @@ -79,11 +73,10 @@ public function __construct( ->get('calendarize_external', 'scheduleRanges'); $this->scheduleRanges = (explode(',', $scheduleRanges)); if (empty($this->scheduleRanges[0])) { - $this->scheduleRanges = array(2, 6); + $this->scheduleRanges = [2, 6]; } parent::__construct(); - } protected function configure() @@ -92,7 +85,7 @@ protected function configure() ->addArgument( 'schedule', InputArgument::REQUIRED, - "The frequency in hours must be one of: " . implode(',', $this->scheduleRanges) . " \r\n" + 'The frequency in hours must be one of: ' . implode(',', $this->scheduleRanges) . " \r\n" . "Hint: You can set the schedule ranges in the extension configuration.\r\n" ) ->addOption( @@ -114,9 +107,9 @@ protected function configure() } /** - * Executes the command to import all external calendars + * Executes the command to import all external calendars. * - * @param InputInterface $input + * @param InputInterface $input * @param OutputInterface $output * * @return int 0 if everything went fine, or an exit code @@ -128,7 +121,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $io = new SymfonyStyle($input, $output); $table = 'tx_calendarizeexternal_domain_model_calendar'; - $schedule = $input->getArgument('schedule'); if (MathUtility::canBeInterpretedAsInteger($schedule)) { $schedulemin = 0; @@ -136,7 +128,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($schedule > $scheduleRange) { $schedulemin = $scheduleRange; } else { - continue 1; + continue; } } $io->text('Run all external calendars which have set schedule range between ' . $schedulemin . ' and <=' . $schedule . 'h.'); @@ -150,12 +142,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $since = $input->getOption('since'); $reindex = $input->getOption('reindex'); $ignoreBeforeDate = null; - $ignoreTwoYearsBeforeDate = new \DateTime("-2 years"); + $ignoreTwoYearsBeforeDate = new \DateTime('-2 years'); $msgsince = ''; if (null !== $since) { - $ignoreBeforeDate = new \DateTime("-" . ltrim($since, '-')); + $ignoreBeforeDate = new \DateTime('-' . ltrim($since, '-')); $io->text('Skipping all events before ' . $ignoreBeforeDate->format(\DateTimeInterface::ATOM)); - $msgsince = $ignoreBeforeDate->format("d-m-y H:i"); + $msgsince = $ignoreBeforeDate->format('d-m-y H:i'); } $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($table); @@ -183,11 +175,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $errorcount = $record['error_count']; if ($errorcount > 10) { // do not run, has to be cleared manually in Backend-record - $io->warning('Not running: error count is:' . $errorcount ); + $io->warning('Not running: error count is:' . $errorcount); continue; } $ignoreDate = $ignoreBeforeDate; // from --since - if ($record['last_run'] == 0) { + if (0 == $record['last_run']) { $ignoreDate = $ignoreTwoYearsBeforeDate; // default if not run } @@ -197,11 +189,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $icalFile = $this->iCalUrlService->getOrCreateLocalFileForUrl($record['ics_url']); // @todo create md5 from content $contents = GeneralUtility::getURL($icalFile); - $md5 = md5 ($contents); + $md5 = md5($contents); } catch (UnableToGetFileForUrlException $e) { $io->error('Invalid URL: ' . $e->getMessage()); $errormsg .= "ical: invalid url.\r\n"; - $errorcount++; + ++$errorcount; $connection->update( $table, ['last_message' => "ERROR: \r\n" . $errormsg, 'last_run' => $lastrun, 'error_count' => $errorcount], @@ -210,8 +202,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int continue; } if (!empty($record['md5']) && !empty($md5) && $md5 == $record['md5'] - && $record['last_run'] != 0) { - $io->text('ical file has not been changed (md5) - not importing'); + && 0 != $record['last_run']) { + $io->text('ical file has not been changed (md5) - not importing'); // Remove temporary file GeneralUtility::unlink_tempfile($icalFile); continue; @@ -228,7 +220,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int } $errormsg .= 'Unable to process events: ' . $e->getMessage(); - $errorcount++; + ++$errorcount; $connection->update( $table, ['last_message' => "ERROR: \r\n" . $errormsg, 'last_run' => $lastrun, 'error_count' => $errorcount], @@ -240,8 +232,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int GeneralUtility::unlink_tempfile($icalFile); } - $io->text('Found ' . \count($events) . ' events in ' . $record['title'] ); - $msg .= "Found " . \count($events) . " events. \r\n"; + $io->text('Found ' . \count($events) . ' events in ' . $record['title']); + $msg .= 'Found ' . \count($events) . " events. \r\n"; $io->section('Send ImportSingleIcalEvent for each event'); $io->progressStart(\count($events)); @@ -277,15 +269,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($exceptionCount > 0) { $msg .= "$exceptionCount events had errors"; // @todo event errors count as one error ? - $errorcount++; + ++$errorcount; } - $msg .= (($record['last_run'] == 0) ? " not within last two years (first run only)." : ($msgsince ? " before " . $msgsince : "")) . "\r\n"; + $msg .= ((0 == $record['last_run']) ? ' not within last two years (first run only).' : ($msgsince ? ' before ' . $msgsince : '')) . "\r\n"; $connection->update( $table, ['last_message' => $msg, 'last_run' => $lastrun, 'error_count' => $errorcount, 'md5' => $md5], ['uid' => $record['uid']] ); - } // after all calendar imports run reindex events if ($reindex) { diff --git a/Classes/Domain/Model/ExternalCalendar.php b/Classes/Domain/Model/ExternalCalendar.php index 335c119..a2ebe07 100644 --- a/Classes/Domain/Model/ExternalCalendar.php +++ b/Classes/Domain/Model/ExternalCalendar.php @@ -4,7 +4,6 @@ namespace Verdigado\CalendarizeExternal\Domain\Model; - /** * This file is part of the "Calendarize External" Extension for TYPO3 CMS. * @@ -15,41 +14,40 @@ */ /** - * ExternalCalendar + * ExternalCalendar. */ class ExternalCalendar extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity { - /** - * title + * title. * * @var string */ protected $title = ''; /** - * icsUrl + * icsUrl. * * @var string */ protected $icsUrl = ''; /** - * note + * note. * * @var string */ protected $note = ''; /** - * scheduler_interval + * scheduler_interval. * * @var int */ protected $scheduler_interval = 0; /** - * Returns the title + * Returns the title. * * @return string $title */ @@ -59,10 +57,9 @@ public function getTitle() } /** - * Sets the title + * Sets the title. * * @param string $title - * @return void */ public function setTitle(string $title) { @@ -70,7 +67,7 @@ public function setTitle(string $title) } /** - * Returns the icsUrl + * Returns the icsUrl. * * @return string $icsUrl */ @@ -80,10 +77,9 @@ public function getIcsUrl() } /** - * Sets the icsUrl + * Sets the icsUrl. * * @param string $icsUrl - * @return void */ public function setIcsUrl(string $icsUrl) { @@ -91,7 +87,7 @@ public function setIcsUrl(string $icsUrl) } /** - * Returns the note + * Returns the note. * * @return string $note */ @@ -101,10 +97,9 @@ public function getNote() } /** - * Sets the note + * Sets the note. * * @param string $note - * @return void */ public function setNote(string $note) { @@ -112,7 +107,7 @@ public function setNote(string $note) } /** - * Returns the scheduler_interval + * Returns the scheduler_interval. * * @return int $scheduler_interval */ @@ -122,10 +117,9 @@ public function getSchedulerInterval() } /** - * Sets the scheduler_interval + * Sets the scheduler_interval. * * @param int $scheduler_interval - * @return void */ public function setSchedulerInterval(int $scheduler_interval) { diff --git a/Classes/Evaluation/ErrorCountReset.php b/Classes/Evaluation/ErrorCountReset.php index c0b5ecc..9880ca2 100644 --- a/Classes/Evaluation/ErrorCountReset.php +++ b/Classes/Evaluation/ErrorCountReset.php @@ -10,7 +10,7 @@ class ErrorCountReset { /** - * JavaScript code for client side validation/evaluation + * JavaScript code for client side validation/evaluation. * * @return string JavaScript code for client side validation/evaluation */ @@ -20,11 +20,12 @@ public function returnFieldJS() } /** - * Server-side validation/evaluation on saving the record + * Server-side validation/evaluation on saving the record. * * @param string $value The field value to be evaluated * @param string $is_in The "is_in" value of the field configuration from TCA - * @param bool $set Boolean defining if the value is written to the database or not. + * @param bool $set boolean define, if the value is written to the database or not + * * @return string Evaluated field value */ public function evaluateFieldValue($value, $is_in, &$set) @@ -33,9 +34,10 @@ public function evaluateFieldValue($value, $is_in, &$set) } /** - * Server-side validation/evaluation on opening the record + * Server-side validation/evaluation on opening the record. * * @param array $parameters Array with key 'value' containing the field value from the database + * * @return string Evaluated field value */ public function deevaluateFieldValue(array $parameters) diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index c24450d..5a8da47 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -2,29 +2,22 @@ namespace Verdigado\CalendarizeExternal\Hooks; -/** +/* * This file is part of the "calendarize_external" Extension for TYPO3 CMS. * * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ -// @todo cleanup start -use TYPO3\CMS\Backend\Utility\BackendUtility as BackendUtilityCore; -use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Information\Typo3Version; -use TYPO3\CMS\Core\Site\SiteFinder; -use TYPO3\CMS\Core\Utility\GeneralUtility; -// @todo cleanup end use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** - * Userfunc to render scheduler range selectbox + * Userfunc to render scheduler range selectbox. */ class ItemsProcFunc { - /** - * Generate a select box of schedule hour ranges to select + * Generate a select box of schedule hour ranges to select. * * @param array $params */ @@ -34,11 +27,10 @@ public function user_schedulerIntervalSelect(&$params): void ->get('calendarize_external', 'scheduleRanges'); $items = (explode(',', $setting)); if (empty($items[0])) { - $items = array(2, 6); + $items = [2, 6]; } foreach ($items as $item) { $params['items'][] = [$item . 'h', $item]; } } - } diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index ee609b7..8f95345 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -1,4 +1,5 @@ [ 'title' => 'LLL:EXT:calendarize_external/Resources/Private/Language/locallang_db.xlf:tx_calendarizeexternal_domain_model_calendar', @@ -14,7 +15,7 @@ 'endtime' => 'endtime', ], 'searchFields' => 'title,ics_url,note,last_message', - 'iconfile' => 'EXT:calendarize_external/Resources/Public/Icons/tx_calendarizeexternal_domain_model_calendar.gif' + 'iconfile' => 'EXT:calendarize_external/Resources/Public/Icons/tx_calendarizeexternal_domain_model_calendar.gif', ], 'types' => [ '1' => ['showitem' => 'title, ics_url, note, scheduler_interval, last_run, last_message, error_count, @@ -32,8 +33,8 @@ [ 0 => '', 1 => '', - 'invertStateDisplay' => true - ] + 'invertStateDisplay' => true, + ], ], ], ], @@ -46,8 +47,8 @@ 'eval' => 'datetime,int', 'default' => 0, 'behaviour' => [ - 'allowLanguageSynchronization' => true - ] + 'allowLanguageSynchronization' => true, + ], ], ], 'endtime' => [ @@ -59,11 +60,11 @@ 'eval' => 'datetime,int', 'default' => 0, 'range' => [ - 'upper' => mktime(0, 0, 0, 1, 1, 2038) + 'upper' => mktime(0, 0, 0, 1, 1, 2038), ], 'behaviour' => [ - 'allowLanguageSynchronization' => true - ] + 'allowLanguageSynchronization' => true, + ], ], ], @@ -74,7 +75,7 @@ 'type' => 'input', 'size' => 30, 'eval' => 'trim', - 'default' => '' + 'default' => '', ], ], 'ics_url' => [ @@ -84,7 +85,7 @@ 'type' => 'input', 'size' => 30, 'eval' => 'trim', - 'default' => '' + 'default' => '', ], ], 'note' => [ @@ -94,7 +95,7 @@ 'type' => 'input', 'size' => 30, 'eval' => 'trim', - 'default' => '' + 'default' => '', ], ], 'scheduler_interval' => [ @@ -107,8 +108,8 @@ 'itemsProcFunc' => \Verdigado\CalendarizeExternal\Hooks\ItemsProcFunc::class . '->user_schedulerIntervalSelect', 'type' => 'select', 'renderType' => 'selectSingle', - 'size' => 1 - ] + 'size' => 1, + ], ], 'last_message' => [ 'exclude' => true, @@ -117,7 +118,7 @@ 'type' => 'text', 'cols' => 30, 'rows' => 5, - 'readOnly' => true + 'readOnly' => true, ], ], 'last_run' => [ @@ -147,9 +148,8 @@ 'type' => 'text', 'cols' => 60, 'rows' => 5, - 'default' => '' + 'default' => '', ], ], - ], ]; diff --git a/Documentation/Settings.cfg b/Documentation/Settings.cfg index 0bc4b8c..588d4b9 100644 --- a/Documentation/Settings.cfg +++ b/Documentation/Settings.cfg @@ -4,8 +4,8 @@ [general] project = Calendarize External -version = 0.0.4 -release = 0.0.4 +version = 0.1.0 +release = 0.1.0 copyright = 2022 - 2023 Falko Trojahn, verdigado e.G. [html_theme_options] diff --git a/README.md b/README.md index 944ef0a..b75ff09 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ -TYPO3 Extension calendarize_external +# TYPO3 Extension calendarize_external Extension for TYPO3, calendarize, external calendars for users ## Features +This TYPO3 extension enables non-admin editors to schedule external calendar imports and get informed about the state of the import. + ## Installation Simply install the extension with Composer or the [Extension Manager](https://extensions.typo3.org/). @@ -12,6 +14,8 @@ Simply install the extension with Composer or the [Extension Manager](https://ex ## Usage +See [Documentation](Documentation/Introduction/Index.rst) + ### ddev local setup The extension comes with a ready to use DDEV local configuration: @@ -40,3 +44,5 @@ rm -rf .build/ composer.lock ``` ## Community + +See the [Issues on Github](https://github.com/verdigado/calendarize_external/issues) \ No newline at end of file diff --git a/Resources/Private/Build/PhpCsFixer.php b/Resources/Private/Build/PhpCsFixer.php new file mode 100644 index 0000000..80360f0 --- /dev/null +++ b/Resources/Private/Build/PhpCsFixer.php @@ -0,0 +1,71 @@ +in($baseDir . '/Classes') + ->in($baseDir . '/Tests/Unit') + ->in($baseDir . '/Tests/Functional') + ->in($baseDir . '/Configuration/TCA') + ->in($baseDir . '/Resources/Private/Build'); + +$config = new \PhpCsFixer\Config(); + +return $config + ->setRiskyAllowed(true) + ->setRules([ + '@DoctrineAnnotation' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + 'no_superfluous_phpdoc_tags' => false, + 'array_syntax' => ['syntax' => 'short'], + 'blank_line_after_opening_tag' => true, + 'braces' => ['allow_single_line_closure' => true], + 'cast_spaces' => ['space' => 'none'], + 'compact_nullable_typehint' => true, + 'concat_space' => ['spacing' => 'one'], + 'declare_equal_normalize' => ['space' => 'none'], + 'dir_constant' => true, + 'function_typehint_space' => true, + 'lowercase_cast' => true, + 'logical_operators' => false, + 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], + 'modernize_types_casting' => true, + 'native_function_casing' => true, + 'new_with_braces' => true, + 'no_alias_functions' => true, + 'no_blank_lines_after_phpdoc' => true, + 'no_empty_phpdoc' => true, + 'no_empty_statement' => true, + 'no_leading_import_slash' => true, + 'no_leading_namespace_whitespace' => true, + 'no_null_property_initialization' => true, + 'no_short_bool_cast' => true, + 'no_singleline_whitespace_before_semicolons' => true, + 'no_superfluous_elseif' => true, + 'no_trailing_comma_in_singleline_array' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_useless_else' => true, + 'no_whitespace_in_blank_line' => true, + 'ordered_imports' => true, + 'php_unit_mock_short_will_return' => true, + 'php_unit_test_case_static_method_calls' => ['call_type' => 'self'], + 'phpdoc_no_access' => true, + 'phpdoc_no_empty_return' => true, + 'phpdoc_no_package' => true, + 'phpdoc_scalar' => true, + 'phpdoc_trim' => true, + 'phpdoc_types' => true, + 'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], + 'return_type_declaration' => ['space_before' => 'none'], + 'single_quote' => true, + 'single_trait_insert_per_statement' => true, + 'whitespace_after_comma_in_array' => true, + ]) + ->setFinder($finder); diff --git a/Resources/Private/Build/Rector.php b/Resources/Private/Build/Rector.php new file mode 100644 index 0000000..406b494 --- /dev/null +++ b/Resources/Private/Build/Rector.php @@ -0,0 +1,39 @@ +parameters(); + + $parameters->set(Option::SETS, [ + Typo3SetList::TYPO3_104, + Typo3SetList::TYPO3_11, + ]); + + $parameters->set(Option::AUTO_IMPORT_NAMES, true); + $parameters->set(Option::IMPORT_SHORT_CLASSES, false); + $parameters->set(Option::IMPORT_DOC_BLOCKS, false); + $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73); + $parameters->set(Typo3Option::OUTPUT_CHANGELOG, true); + + $parameters->set(Option::SKIP, [ + NameImportingPostRector::class => [ + 'ClassAliasMap.php', + 'ext_localconf.php', + 'ext_emconf.php', + 'ext_tables.php', + __DIR__ . '/**/TCA/*', + __DIR__ . '/**/Configuration/RequestMiddlewares.php', + __DIR__ . '/**/Configuration/Commands.php', + __DIR__ . '/**/Configuration/AjaxRoutes.php', + __DIR__ . '/**/Configuration/Extbase/Persistence/Classes.php', + ], + ]); +}; diff --git a/Tests/Functional/BasicTest.php b/Tests/Functional/BasicTest.php index a347fb2..6327284 100644 --- a/Tests/Functional/BasicTest.php +++ b/Tests/Functional/BasicTest.php @@ -7,7 +7,7 @@ use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; /** - * Test case + * Test case. * * @author Falko Trojahn */ @@ -21,12 +21,10 @@ class BasicTest extends FunctionalTestCase ]; /** - * Just a dummy to show that at least one test is actually executed - * - * @test + * Just a dummy to show that at least one test is actually executed. */ - public function dummy(): void + public function testDummy(): void { - $this->assertTrue(true); + self::assertTrue(true); } } diff --git a/Tests/Unit/Domain/Model/ExternalCalendarTest.php b/Tests/Unit/Domain/Model/ExternalCalendarTest.php index 8c7fa41..35480f0 100644 --- a/Tests/Unit/Domain/Model/ExternalCalendarTest.php +++ b/Tests/Unit/Domain/Model/ExternalCalendarTest.php @@ -9,7 +9,7 @@ use TYPO3\TestingFramework\Core\Unit\UnitTestCase; /** - * Test case + * Test case. * * @author Falko Trojahn */ @@ -35,10 +35,7 @@ protected function tearDown(): void parent::tearDown(); } - /** - * @test - */ - public function getTitleReturnsInitialValueForString(): void + public function testGetTitleReturnsInitialValueForString(): void { self::assertSame( '', @@ -46,20 +43,14 @@ public function getTitleReturnsInitialValueForString(): void ); } - /** - * @test - */ - public function setTitleForStringSetsTitle(): void + public function testSetTitleForStringSetsTitle(): void { $this->subject->setTitle('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->_get('title')); } - /** - * @test - */ - public function getIcsUrlReturnsInitialValueForString(): void + public function testGetIcsUrlReturnsInitialValueForString(): void { self::assertSame( '', @@ -67,20 +58,14 @@ public function getIcsUrlReturnsInitialValueForString(): void ); } - /** - * @test - */ - public function setIcsUrlForStringSetsIcsUrl(): void + public function testSetIcsUrlForStringSetsIcsUrl(): void { $this->subject->setIcsUrl('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->_get('icsUrl')); } - /** - * @test - */ - public function getNoteReturnsInitialValueForString(): void + public function testGetNoteReturnsInitialValueForString(): void { self::assertSame( '', @@ -88,20 +73,14 @@ public function getNoteReturnsInitialValueForString(): void ); } - /** - * @test - */ - public function setNoteForStringSetsNote(): void + public function testSetNoteForStringSetsNote(): void { $this->subject->setNote('Conceived at T3CON10'); self::assertEquals('Conceived at T3CON10', $this->subject->_get('note')); } - /** - * @test - */ - public function getSchedulerIntervalReturnsInitialValueForInt(): void + public function testGetSchedulerIntervalReturnsInitialValueForInt(): void { self::assertSame( 0, @@ -109,10 +88,7 @@ public function getSchedulerIntervalReturnsInitialValueForInt(): void ); } - /** - * @test - */ - public function setSchedulerIntervalForIntSetsSchedulerInterval(): void + public function testSetSchedulerIntervalForIntSetsSchedulerInterval(): void { $this->subject->setSchedulerInterval(12); diff --git a/composer.json b/composer.json index c587719..6bf1ada 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,22 @@ { "name": "verdigado/calendarize-external", - "description": "Calendarize users can edit external calendars", + "description": "Calendarize users can create/edit external calendar imports", "type": "typo3-cms-extension", "authors": [ + { + "name": "Alexander Bigga (verdigado eG)", + "role": "Developer" + }, { "name": "Falko Trojahn (verdigado eG)", "role": "Developer" } ], - "license": [ - "GPL-2.0-or-later" - ], + "homepage": "https://github.com/verdigado/calendarize_external", + "license": "GPL-2.0-or-later", + "support": { + "issues": "https://github.com/verdigado/calendarize_external/issues" + }, "config": { "sort-packages": true, "vendor-dir": ".Build/vendor", @@ -22,7 +28,8 @@ }, "require": { "lochmueller/calendarize": "^12.4 || @dev", - "typo3/cms-core": "^10.4 || ^11.5" + "typo3/cms-core": "^10.4 || ^11.5", + "typo3/cms-scheduler": "^8.7 || ^10.4 || 11.*.*@dev" }, "require-dev": { "helhum/typo3-console": "^v6.7.7 || ^v7.1.6", @@ -40,7 +47,13 @@ "typo3/cms-info": "^8.7 || ^10.4 || 11.*.*@dev", "typo3/cms-lowlevel": "^8.7 || ^10.4 || 11.*.*@dev", "typo3/cms-rte-ckeditor": "^8.7 || ^10.4 || 11.*.*@dev", - "typo3/cms-tstemplate": "^8.7 || ^10.4 || 11.*.*@dev" + "typo3/cms-tstemplate": "^8.7 || ^10.4 || 11.*.*@dev", + "typo3/testing-framework": "^7.0", + "squizlabs/php_codesniffer": "^2.6", + "friendsofphp/php-cs-fixer": "^3.0", + "phpmd/phpmd": "^2.4", + "scrutinizer/ocular": "^1.3", + "phpstan/phpstan": "^1.10" }, "scripts": { "typo3-cms-scripts": [ @@ -53,7 +66,33 @@ ], "post-autoload-dump": [ "@typo3-cms-scripts", - "@ddev-symlink-project" + "@ddev-symlink-project", + "TYPO3\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare" + ], + "code": [ + "@tool:php-cs-fixer", + "@tool:phpunit" + ], + "tool:php-cs-fixer": [ + "php-cs-fixer fix --config Resources/Private/Build/PhpCsFixer.php" + ], + "tool:php-cs-fixer-check": [ + "php-cs-fixer fix --config Resources/Private/Build/PhpCsFixer.php --dry-run" + ], + "tool:phpunit": [ + "phpunit --configuration=Tests/Unit/Build/UnitTests.xml" + ], + "tool:phpunit:functional": [ + "phpunit --configuration=Tests/Functional/Build/FunctionalTests.xml" + ], + "tool:phpdoc": [ + "docker run --rm -v $(pwd):/data phpdoc/phpdoc -d Classes -t .Build/phpdoc" + ], + "tool:rector": [ + "docker run --rm --volume $PWD:/app --user $(id -u):$(id -g) ghcr.io/sabbelasichon/typo3-rector process --config=Resources/Private/Build/Rector.php" + ], + "tool:phpstan": [ + "phpstan analyse -c phpstan.neon" ] }, "autoload": { diff --git a/ext_emconf.php b/ext_emconf.php index 5dcd459..728e889 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -8,7 +8,7 @@ 'author_email' => 'support@verdigado.net', 'state' => 'alpha', 'clearCacheOnLoad' => 0, - 'version' => '0.0.4', + 'version' => '0.1.0', 'constraints' => [ 'depends' => [ 'typo3' => '10.4.0-11.4.99', diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..a33f5cf --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: 1 + paths: + - Classes + - Tests