Commit db8d4994 authored by Utz, Wolf-Peter's avatar Utz, Wolf-Peter Committed by Thorsten Müller
Browse files

Add typo3 10.4 support

Remove vhs dependency
Add typoscript_rendering dependency
Clean up code
parent 6d22fddf
version: '2.3'
services:
#======================================================
# DB
#======================================================
mariadb10:
image: mariadb:10
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: funcp
tmpfs:
- /var/lib/mysql/:rw,noexec,nosuid
#======================================================
# Build
#======================================================
build:
image: edbizarro/gitlab-ci-pipeline-php:${PHP_VERSION}-alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
composer install;
"
#======================================================
# Lint
#======================================================
lint:
image: typo3gmbh/php72:latest
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
echo \"Lint php...\";
php -v | grep '^PHP';
find . -name \\*.php ! -path "./.Build/\\*" -print0 | xargs -0 -n1 -P4 php -n -c /etc/php/cli-no-xdebug/php.ini -l >/dev/null
echo \"Lint Typoscript...\";
.Build/bin/typoscript-lint Configuration/TypoScript/
echo \"Lint for debug calls...\";
if grep -rnw "Resources/Private/" "Classes/" -e "debug" -e "DebuggerUtility"; then
exit 1
fi
"
#======================================================
# Quality
#======================================================
quality:
image: php:${PHP_VERSION}-alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
echo \"Running phpcs...\";
.Build/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php Classes;
echo \"Running php-cs-fixer...\";
.Build/bin/php-cs-fixer fix --allow-risky=yes --dry-run --diff
echo \"Running phpmd...\";
.Build/bin/phpmd Classes text phpmd.xml;
echo \"Running phpstan...\";
php -d memory_limit=4G .Build/bin/phpstan analyse -c phpstan.neon
"
#======================================================
# Fix
#======================================================
fix:
image: riconet/typo3:9.5
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
echo \"Fix quality errors...\";
.Build/bin/php-cs-fixer fix --allow-risky=yes
.Build/bin/phpcbf --error-severity=1 --warning-severity=8 --extensions=php
"
#======================================================
# Functional tests
#======================================================
functional:
image: riconet/typo3:9.5
links:
- mariadb10
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
environment:
typo3DatabaseName: func_test
typo3DatabaseUsername: root
typo3DatabasePassword: funcp
typo3DatabaseHost: mariadb10
working_dir: ${ROOT_DIR}/.Build
command: >
/bin/sh -c "
echo Waiting for database start...;
while ! nc -z mariadb10 3306; do
sleep 1;
done;
echo Database is up;
bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ../Tests/Functional;
rm -rf Web/typo3temp/var/tests/func*
"
#======================================================
# Unit tests
#======================================================
unit:
image: riconet/typo3:9.5
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}/.Build
command: >
/bin/sh -c "
php bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/UnitTests.xml ${EXTRA_TEST_OPTIONS} ../Tests/Unit;
"
#!/usr/bin/env bash
# TYPO3 core test runner based on docker and docker-compose.
# Function to write a .env file in Build/docker
# This is read by docker-compose and vars defined here are
# used in .ci/docker/docker-compose.yml
# Function to write a .env file in Build/testing-docker
setUpDockerComposeDotEnv() {
[ -e .env ] && rm .env
echo "TEST_FILE=${TEST_FILE}" >>.env
echo "ROOT_DIR=${ROOT_DIR}" >>.env
echo "EXTRA_TEST_OPTIONS=${EXTRA_TEST_OPTIONS}" >>.env
echo "EXTENSION_KEY=${EXTENSION_KEY}" >>.env
echo "PHP_VERSION=${PHP_VERSION}" >>.env
echo "HOST_USER=${USER}" >>.env
echo "HOST_HOME=${HOME}" >>.env
echo "HOST_UID=$(id -u)" >>.env
# we have to set it explicitly here.
echo "HOST_UID=`id -u`" >> .env
# Your local home directory for composer and npm caching
echo "HOST_HOME=${HOME}" >> .env
}
# Function to get the real path on mac os.
......@@ -35,16 +37,14 @@ Options:
-s <...>
Specifies which test suite to run
- build: Builds the project (composer)
- lint: Lints the php files
- functional: functional tests
- lint: Lints php and typoscript files. Also finds usages of debug calls.
- unit (default): PHP unit tests
- quality: executes code quality checks (phpstan, phpcs, phpmd)
- find-debugs: Finds usages of debug calls.
- fix: Fixes some quality errors automatically.
-p <7.2|7.3>
-p <7.2>
Specifies the PHP minor version to be used
- 7.2 (default): use PHP 7.2
- 7.3: use PHP 7.3
-e "<phpunit options>"
Only with -s functional|unit
......@@ -58,7 +58,7 @@ Options:
Examples:
# Run unit tests
./Build/Scripts/runTests.sh
.ci/scripts/console.sh -s build
EOF
# Test if docker-compose exists, else exit out with error
......@@ -73,10 +73,9 @@ THIS_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)"
cd "$THIS_SCRIPT_DIR" || exit 1
# Go to directory that contains the local docker-compose.yml file
cd ../testing-docker || exit 1
cd ../docker || exit 1
# Option defaults
EXTENSION_KEY="$(basename $(realpath $PWD"/../../"))"
ROOT_DIR=$(realpath $PWD"/../../")
TEST_SUITE="unit"
PHP_VERSION="7.2"
......@@ -126,14 +125,11 @@ fi
# Set $1 to first mass argument, this is the optional test file or test directory to execute
shift $((OPTIND - 1))
if [ -n "${1}" ]; then
TEST_FILE="Web/typo3conf/ext/${EXTENSION_KEY}/${1}"
TEST_FILE="${ROOT_DIR}/${1}"
else
case ${TEST_SUITE} in
functional)
TEST_FILE="Web/typo3conf/ext/${EXTENSION_KEY}/Tests/Functional"
;;
unit)
TEST_FILE="Web/typo3conf/ext/${EXTENSION_KEY}/Tests/Unit"
TEST_FILE="${ROOT_DIR}/tests/Unit"
;;
esac
fi
......@@ -152,27 +148,27 @@ lint)
SUITE_EXIT_CODE=$?
docker-compose down
;;
functional)
quality)
setUpDockerComposeDotEnv
docker-compose run functional
docker-compose run quality
SUITE_EXIT_CODE=$?
docker-compose down
;;
unit)
fix)
setUpDockerComposeDotEnv
docker-compose run unit
docker-compose run fix
SUITE_EXIT_CODE=$?
docker-compose down
;;
quality)
unit)
setUpDockerComposeDotEnv
docker-compose run quality
docker-compose run unit
SUITE_EXIT_CODE=$?
docker-compose down
;;
find-debugs)
functional)
setUpDockerComposeDotEnv
docker-compose run debugUsageCallCheck
docker-compose run functional
SUITE_EXIT_CODE=$?
docker-compose down
;;
......
; top-most EditorConfig file
root = true
; Unix-style newlines
[*]
charset = utf-8
end_of_line = LF
insert_final_newline = true
trim_trailing_whitespace = true
[*.{php,html,typoscript,yml,yaml,xml}]
indent_style = space
indent_size = 4
max_line_length = 120
[*.{yml,yaml}]
indent_size = 2
[*.md]
max_line_length = 120
[COMMIT_EDITMSG]
max_line_length = 0
......@@ -12,4 +12,11 @@ yarn-error.log
Build/testing-docker/.env
Build/testing-docker/.database
.php_cs.cache
.sass-cache
\ No newline at end of file
.sass-cache
/yarn.lock
.Build/
.ci/docker/.env
.ci/docker/.database
/var/
node_modules/
package-lock.json
File mode changed from 100644 to 100755
<?php
$finder = PhpCsFixer\Finder::create()
->in([
__DIR__ . '/Classes/',
__DIR__ . '/Tests/',
__DIR__ . '/Configuration/TCA/'
])
->exclude(__DIR__ . '/.Build/');
$header = <<<EOF
This file is part of the "rico_dynamic_faq" Extension for TYPO3 CMS.
For the full copyright and license information, please read the
LICENSE.txt file that was distributed with this source code.
(c) 2020 PSVneo
EOF;
return PhpCsFixer\Config::create()
->setUsingCache(false)
->setRules([
'@PSR1' => true,
'@PSR2' => true,
'@Symfony' => true,
'header_comment' => [
'header' => $header,
'location' => 'after_open',
'separate' => 'both',
'commentType' => 'PHPDoc',
],
'no_useless_else' => true,
'no_useless_return' => true,
'no_unused_imports' => true,
'ordered_class_elements' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'blank_line_after_opening_tag' => false,
'concat_space' => ['spacing' => 'one'],
'array_syntax' => ['syntax' => 'short'],
'yoda_style' => true,
'declare_strict_types' => true,
'psr4' => true,
'no_php4_constructor' => true,
'no_short_echo_tag' => true,
'semicolon_after_instruction' => true,
'align_multiline_comment' => true,
'general_phpdoc_annotation_remove' => ['annotations' => ["author", "package"]],
'phpdoc_add_missing_param_annotation' => ['only_untyped' => false],
])
->setFinder($finder);
File mode changed from 100644 to 100755
version: '2.3'
services:
#======================================================
# DB
#======================================================
db:
image: mysql:5.7
command: mysqld --character-set-server=utf8
environment:
MYSQL_ROOT_PASSWORD: funcp
volumes:
- .database:/var/lib/mysql
#======================================================
# Build
#======================================================
build:
image: composer:1.6.5
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
- ${HOST_HOME}:${HOST_HOME}
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
composer install;
"
#======================================================
# Lint
#======================================================
lint:
image: typo3gmbh/php72:latest
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
php -v | grep '^PHP';
find . -name \\*.php ! -path "./.Build/\\*" -print0 | xargs -0 -n1 -P4 php -n -c /etc/php/cli-no-xdebug/php.ini -l >/dev/null
"
#======================================================
# Quality
#======================================================
quality:
image: riconet/typo3:9.5
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
echo \"Running phpcs...\";
.Build/bin/phpcs --error-severity=1 --warning-severity=8 --extensions=php Classes;
echo \"Running phpmd...\";
.Build/bin/phpmd Classes text phpmd.xml;
echo \"Running phpstan...\";
.Build/bin/phpstan analyse -c phpstan.neon --autoload-file=.Build/vendor/autoload.php -l max Classes
"
#======================================================
# Debug usage call check
#======================================================
debugUsageCallCheck:
image: php:${PHP_VERSION}-alpine
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if grep -rnw "Resources/Private/" "Classes/" -e "debug" -e "DebuggerUtility"; then
exit 1
fi
"
#======================================================
# Functional tests
#======================================================
functional:
image: riconet/typo3:9.5
user: ${HOST_UID}
links:
- db
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
- ${HOST_HOME}:${HOST_HOME}
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
environment:
typo3DatabaseName: func_test
typo3DatabaseUsername: root
typo3DatabasePassword: funcp
typo3DatabaseHost: db
working_dir: ${ROOT_DIR}/.Build
command: >
/bin/sh -c "
echo Waiting for database start...;
while ! nc -z db 3306; do
sleep 1;
done;
echo Database is up;
php bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
"
#======================================================
# Unit tests
#======================================================
unit:
image: riconet/typo3:9.5
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
- ${HOST_HOME}:${HOST_HOME}
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
working_dir: ${ROOT_DIR}/.Build
command: >
/bin/sh -c "
php bin/phpunit -c vendor/nimut/testing-framework/res/Configuration/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
"
\ No newline at end of file
......@@ -4,8 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
###
## [6.0.0]
### Added
- Add support for TYPO3 10.4
- Add typoscript_rendering dependency
- Add slug handling
- Remove VHS dependency
## [5.0.0]
### Added
......@@ -20,4 +24,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Language key `email.new_question.subject`.
- Language key `email.answer_question.subject`.
- Repository and model to fetch `sys_language` records from database.
- Service to map a `sys_langauge_uid` to an iso code.
\ No newline at end of file
- Service to map a `sys_langauge_uid` to an iso code.
<?php
/**
* This file is part of the "rico_dynamic_faq" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020 PSVneo
*/
declare(strict_types=1);
namespace Riconet\RicoDynamicFaq;
class Constants
{
public const EXTENSION_KEY = 'rico_dynamic_faq';
public const EXTENSION_NAME = 'RicoDynamicFaq';
}
<?php
/**
* This file is part of the "rico_dynamic_faq" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020 Wolf Utz <utz@riconet.de>, PSVneo
* (c) 2020 PSVneo
*/
declare(strict_types=1);
namespace Riconet\RicoDynamicFaq\Controller;
use Riconet\RicoDynamicFaq\Domain\Factory\CategoryTreeFactory;
use Riconet\RicoDynamicFaq\Domain\Model\Category;
use Riconet\RicoDynamicFaq\Domain\Repository\CategoryRepository;
use Riconet\RicoDynamicFaq\Domain\Repository\QuestionRepository;
use Riconet\RicoDynamicFaq\Domain\Factory\CategoryTreeFactory;
use Riconet\RicoDynamicFaq\Utility\PluginUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use Riconet\RicoDynamicFaq\Domain\Model\Category;
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
class CategoryController extends ActionController
{
......@@ -38,31 +36,24 @@ class CategoryController extends ActionController
*/
protected $categoryTreeFactory;
public function injectQuestionRepository(QuestionRepository $questionRepository)
{
public function __construct(
QuestionRepository $questionRepository,
CategoryRepository $categoryRepository,
CategoryTreeFactory $categoryTreeFactory
) {
$this->questionRepository = $questionRepository;
}
public function injectCategoryRepository(CategoryRepository $categoryRepository)
{
$this->categoryRepository = $categoryRepository;
}
public function injectCategoryTreeFactory(CategoryTreeFactory $categoryTreeFactory)
{
$this->categoryTreeFactory = $categoryTreeFactory;
}
public function preSelectAction()
public function preSelectAction(): void
{
$this->view->assignMultiple([
'categories' => $this->categoryRepository->findByUidCommaSeparatedString(
$this->settings['topCategories']
),
'categories' => $this->categoryRepository->findByUidCommaSeparatedString($this->settings['topCategories']),
]);
}
public function listAction(Category $rootCategory = null)
public function listAction(Category $rootCategory = null): void
{
if (is_null($rootCategory)) {
/** @var Category $rootCategory */
......@@ -70,22 +61,15 @@ class CategoryController extends ActionController
}
$this->view->assignMultiple([
'categoryTree' => $this->categoryTreeFactory->build($rootCategory),
'ceUid' => $this->configurationManager->getContentObject()->data['uid'],
]);
}
public function showAction(Category $category, int $ceUid = 0)
public function showAction(?Category $category): void
{
/** @var QuerySettingsInterface $querySettings */
$querySettings = $this->objectManager->get(QuerySettingsInterface::class);
$querySettings->setStoragePageIds(
GeneralUtility::intExplode(',', PluginUtility::getStorageSettingsOfCE($ceUid))
);
$this->questionRepository->setDefaultQuerySettings($querySettings);
$questions = $this->questionRepository->findByCategory($category);
$this->view->assignMultiple([
'categoryIsMissing' => is_null($category),
'category' => $category,
'questions' => $questions,
'questions' => is_null($category) ? null : $this->questionRepository->findByCategory($category),
]);
}
}
<?php
/**
* This file is part of the "rico_dynamic_faq" Extension for TYPO3 CMS.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* (c) 2020 Wolf Utz <utz@riconet.de>, PSVneo
* (c) 2020 PSVneo
*/
declare(strict_types=1);
namespace Riconet\RicoDynamicFaq\Controller;
use Riconet\RicoDynamicFaq\Domain\Model\Question;
use Riconet\RicoDynamicFaq\Domain\Repository\QuestionRepository;
use Riconet\RicoDynamicFaq\Domain\Service\Question\ScoreUpServiceInterface;
use Riconet\RicoDynamicFaq\Domain\Service\Question\ViewUpServiceInterface;
use Riconet\RicoDynamicFaq\Domain\Settings\FaqPluginSettings;
use Riconet\RicoDynamicFaq\Utility\LocalizationUtility;
use Riconet\RicoDynamicFaq\Utility\PluginUtility;
use Riconet\RicoDynamicFaq\Utility\ViewsUtility;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use Symfony\Component\Mime\Address;
use TYPO3\CMS\Core\Mail\FluidEmail;
use TYPO3\CMS\Core\Mail\Mailer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use Riconet\RicoDynamicFaq\Domain\Model\Question;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use Riconet\RicoDynamicFaq\Utility\EmailUtility;
use TYPO3\CMS\Extbase\Persistence\Generic\QuerySettingsInterface;
class DisplayController extends ActionController
{
......@@ -33,56 +33,36 @@ class DisplayController extends ActionController
protected $questionRepository;
/**
* @var ViewsUtility
* @var ViewUpServiceInterface
*/
protected $viewsUtility;
protected $viewUpService;
/**
* @var array
* @var ScoreUpServiceInterface