Skip to content

Commit

Permalink
Add basic testing infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Richter committed Apr 15, 2024
1 parent dd2b02e commit 6914bc3
Show file tree
Hide file tree
Showing 14 changed files with 1,813 additions and 156 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.idea/
.Build/
.idea/
.cache/
Build/testing-docker/.env
composer.lock
bin/
public/
typo3temp/
vendor/
composer.lock
1,036 changes: 1,036 additions & 0 deletions Build/Scripts/runTests.sh

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Build/phpstan/phpstan.local.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
level: 0
paths:
- ../../Classes
- ../../Tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
bootstrap="../../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php"
cacheResult="false"
colors="true"
failOnRisky="true"
failOnWarning="true"
>
<testsuites>
<testsuite name="MpdbCore">
<directory>../Tests/Functional</directory>
<directory>../../Tests/Functional</directory>
</testsuite>
</testsuites>

Expand Down
4 changes: 2 additions & 2 deletions config/UnitTests.xml → Build/phpunit/UnitTests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
backupGlobals="true"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
bootstrap="../../vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php"
cacheResult="false"
colors="true"
failOnRisky="true"
failOnWarning="true"
>
<testsuites>
<testsuite name="MpdbCore">
<directory>../Tests/Unit</directory>
<directory>../../Tests/Unit</directory>
</testsuite>
</testsuites>

Expand Down
188 changes: 188 additions & 0 deletions Build/testing-docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
version: '2.3'
services:
mariadb10:
image: mariadb:10
environment:
MYSQL_ROOT_PASSWORD: funcp
tmpfs:
- /var/lib/mysql/:rw,noexec,nosuid

postgres10:
image: postgres:10-alpine
environment:
POSTGRES_PASSWORD: funcp
POSTGRES_USER: ${HOST_USER}
tmpfs:
- /var/lib/postgresql/data:rw,noexec,nosuid

composer_update:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: "${HOST_UID}"
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
environment:
COMPOSER_CACHE_DIR: ".cache/composer"
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
php -v | grep '^PHP';
if [ ${TYPO3_VERSION} -eq 11 ]; then
composer req --dev --no-update \
typo3/cms-composer-installers:^3.0
composer req typo3/cms-core:^11.5 --no-update
fi
if [ ${TYPO3_VERSION} -eq 12 ]; then
composer req --dev --no-update \
"typo3/cms-composer-installers:^5.0" \
typo3/cms-backend:^12.4 \
typo3/cms-frontend:^12.4 \
typo3/cms-extbase:^12.4 \
typo3/cms-fluid:^12.4 \
typo3/cms-install:^12.4
composer req typo3/cms-core:^12.4 -W --no-update
fi
composer update --no-progress --no-interaction;
"
functional_mariadb10:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
links:
- mariadb10
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
environment:
typo3DatabaseName: func_test
typo3DatabaseUsername: root
typo3DatabasePassword: funcp
typo3DatabaseHost: mariadb10
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
echo Waiting for database start...;
while ! nc -z mariadb10 3306; do
sleep 1;
done;
echo Database is up;
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
fi
"
functional_postgres10:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
links:
- postgres10
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
environment:
typo3DatabaseDriver: pdo_pgsql
typo3DatabaseName: bamboo
typo3DatabaseUsername: ${HOST_USER}
typo3DatabaseHost: postgres10
typo3DatabasePassword: funcp
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
echo Waiting for database start...;
while ! nc -z postgres10 5432; do
sleep 1;
done;
echo Database is up;
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-postgres ${TEST_FILE};
fi
"
functional_sqlite:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
tmpfs:
- ${ROOT_DIR}/.Build/Web/typo3temp/var/tests/functional-sqlite-dbs/:rw,noexec,nosuid,uid=${HOST_UID}
environment:
typo3DatabaseDriver: pdo_sqlite
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
php -v | grep '^PHP';
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
.Build/bin/phpunit -c Build/FunctionalTests.xml ${EXTRA_TEST_OPTIONS} --exclude-group not-sqlite ${TEST_FILE};
fi
"
lint:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
php -v | grep '^PHP';
find . -name \\*.php ! -path "./.Build/\\*" -print0 | xargs -0 -n1 -P4 php -dxdebug.mode=off -l >/dev/null
"
unit:
image: typo3/core-testing-${DOCKER_PHP_IMAGE}:latest
user: ${HOST_UID}
volumes:
- ${ROOT_DIR}:${ROOT_DIR}
working_dir: ${ROOT_DIR}
command: >
/bin/sh -c "
if [ ${SCRIPT_VERBOSE} -eq 1 ]; then
set -x
fi
php -v | grep '^PHP'
if [ ${PHP_XDEBUG_ON} -eq 0 ]; then
XDEBUG_MODE=\"off\" \
.Build/bin/phpunit -c Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
else
DOCKER_HOST=`route -n | awk '/^0.0.0.0/ { print $$2 }'`
XDEBUG_MODE=\"debug,develop\" \
XDEBUG_TRIGGER=\"foo\" \
XDEBUG_CONFIG=\"client_port=${PHP_XDEBUG_PORT} client_host=$${DOCKER_HOST}\" \
.Build/bin/phpunit -c Build/UnitTests.xml ${EXTRA_TEST_OPTIONS} ${TEST_FILE};
fi
"
2 changes: 1 addition & 1 deletion Classes/Command/CompleteGndWorksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function initialize(InputInterface $input, OutputInterface $output) {
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$countWorks = $this->workRepository->findAll()->count();
$nonTitleWorks = $this->workRepository->findByTitle('');
Expand Down
7 changes: 4 additions & 3 deletions Classes/Domain/Model/PublishedItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,9 @@ public function getIsPianoReduction(): bool
public function setMvdbId(): void
{
$minPlateId = $this->getPlateIds()->min();
$this->mvdbId = $this->publisher->getShorthand() .
'_' . $minPlateId;
$this->mvdbId = $this->publisher ?
$this->publisher->getShorthand() . '_' : '';
$this->mvdbId .= $minPlateId;

Collection::wrap($this->publishedSubitems->toArray())->
each( function($subitem) { $this->setSubitemMvdbId($subitem); } );
Expand Down Expand Up @@ -959,7 +960,7 @@ public function setFirstComposer(ObjectStorage $firstComposer): void
*/
public function getComposers(): string
{
$composers = Collection::wrap($this->firstComposer);
$composers = Collection::wrap($this->firstComposer->toArray());
if ($composers->count() > 0) {
return $composers->map( function ($composer) { return self::getComposerName($composer); } )->
unique()->
Expand Down
3 changes: 3 additions & 0 deletions Tests/Functional/Domain/Model/Fixtures/empty_persons.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"tx_dmnorm_domain_model_gndperson"
,"uid"
,1
3 changes: 3 additions & 0 deletions Tests/Functional/Domain/Model/Fixtures/empty_works.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"tx_dmnorm_domain_model_gndwork"
,"uid","alt_instrumentation"
,1,""
Loading

0 comments on commit 6914bc3

Please sign in to comment.