Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.x dev codeception #131

Merged
merged 10 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest

- name: Coding Guideline
run: .build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./
run: vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./

code-quality:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,4 +77,43 @@ jobs:
composer require --no-interaction --prefer-dist --no-progress "typo3/cms-core:${{ matrix.typo3-version }}" "typo3/cms-extbase:${{ matrix.typo3-version }}" "typo3/cms-frontend:${{ matrix.typo3-version }}"

- name: Code Quality (by PHPStan)
run: .build/bin/phpstan analyse -c Build/phpstan.neon
run: vendor/bin/phpstan analyse -c Build/phpstan.neon

tests-acceptance:
runs-on: ubuntu-latest
needs:
- coding-guideline
- code-quality
steps:
- uses: actions/checkout@v3

- uses: cachix/install-nix-action@v17
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Run Unit Tests PHP8.1
run: nix-shell --arg phpVersion \"php81\" --pure --run project-test-unit

- name: Run Unit Tests PHP8.2
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-unit

- name: Run Unit Tests PHP8.3
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-unit

- name: Run Functional Tests PHP8.1
run: nix-shell --arg phpVersion \"php81\" --pure --run project-test-functional

- name: Run Functional Tests PHP8.2
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-functional

- name: Run Functional Tests PHP8.3
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-functional

- name: Run Acceptance Tests PHP8.1
run: nix-shell --arg phpVersion \"php81\" --pure --run project-test-acceptance

- name: Run Acceptance Tests PHP8.2
run: nix-shell --arg phpVersion \"php82\" --pure --run project-test-acceptance

- name: Run Acceptance Tests PHP8.3
run: nix-shell --arg phpVersion \"php83\" --pure --run project-test-acceptance
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.build
composer.lock

.php_cs.cache
.php-cs-fixer.cache
.phplint.cache
Build/.phpunit.cache

Expand All @@ -12,6 +12,7 @@ Documentation-GENERATED-temp/
.idea

var/
vendor/

phpunit.coverage.xml
phpunit.report.xml
110 changes: 68 additions & 42 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,22 @@ stages:
- analysis

lint:cgl:
image: php:8.1-alpine
image: $CI_REGISTRY/containers/phpunit-with-php-8.1:main
stage: lint
before_script:
- apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini zlib-dev icu-dev g++
- docker-php-ext-install mysqli && docker-php-ext-configure intl && docker-php-ext-install intl && docker-php-ext-enable intl
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- sed -i -e "s#ssh://git@code.extco.de:22722#https://gitlab-ci-token:$CI_JOB_TOKEN@code.extco.de#g" composer.json
- composer config platform.php 8.1
- composer remove typo3/cms-core --no-update
- composer install --no-progress --no-ansi --no-interaction
script:
- .build/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./
- vendor/bin/php-cs-fixer fix --config=Build/.php-cs-fixer.dist.php -v --dry-run --using-cache=no --path-mode=intersection ./

lint:typoscriptcgl:
image: php:8.1-alpine
stage: lint
before_script:
- apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini zlib-dev icu-dev g++
- docker-php-ext-install mysqli && docker-php-ext-configure intl && docker-php-ext-install intl && docker-php-ext-enable intl
- apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini zlib-dev libzip-dev zip icu-dev g++
- docker-php-ext-install mysqli && docker-php-ext-install zip && docker-php-ext-configure intl && docker-php-ext-install intl && docker-php-ext-enable intl
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Expand All @@ -57,7 +50,7 @@ lint:typoscriptcgl:
- composer remove typo3/cms-core --no-update
- composer install --no-progress --no-ansi --no-interaction
script:
- .build/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration
- vendor/bin/typoscript-lint -c Build/typoscriptlint.yaml Configuration

lint:yaml:
stage: lint
Expand Down Expand Up @@ -86,55 +79,36 @@ lint:php83:
- find . -name \*.php -exec php -l "{}" \;

phpstan:analyse:
image: php:8.1-alpine
image: $CI_REGISTRY/containers/phpunit-with-php-8.1:main
stage: lint
before_script:
- apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini zlib-dev icu-dev g++
- docker-php-ext-install mysqli && docker-php-ext-configure intl && docker-php-ext-install intl && docker-php-ext-enable intl
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- sed -i -e "s#ssh://git@code.extco.de:22722#https://gitlab-ci-token:$CI_JOB_TOKEN@code.extco.de#g" composer.json
- composer config platform.php 8.1
- composer install --no-progress --no-ansi --no-interaction
script:
- .build/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M
- vendor/bin/phpstan analyse -c Build/phpstan.neon --memory-limit 256M

.test: &test_php
.test_php: &test_php
stage: test
services:
- mysql:5
image: php:$DOCKER_TAG
image: $CONTAINER_IMAGE
only:
- branches
before_script:
- apk add --no-cache bash curl git mercurial openssh openssl parallel subversion tini zlib-dev icu-dev g++
- >
if [[ "$COVERAGE" == "1" ]]; then
apk add --no-cache linux-headers $PHPIZE_DEPS
pecl install xdebug && docker-php-ext-enable xdebug
fi
- docker-php-ext-install mysqli && docker-php-ext-configure intl && docker-php-ext-install intl && docker-php-ext-enable intl
- wget https://composer.github.io/installer.sig -O - -q | tr -d '\n' > installer.sig
- php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
- php -r "if (hash_file('SHA384', 'composer-setup.php') === trim(file_get_contents('installer.sig'))) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
- php composer-setup.php --no-ansi --install-dir=/usr/bin --filename=composer
- php -r "unlink('composer-setup.php'); unlink('installer.sig');"
- sed -i -e "s#ssh://git@code.extco.de:22722#https://gitlab-ci-token:$CI_JOB_TOKEN@code.extco.de#g" composer.json
- composer config --no-plugins allow-plugins.typo3/cms-composer-installers true
- composer config --no-plugins allow-plugins.typo3/class-alias-loader true
- composer require typo3/cms-core="${TYPO3_VERSION}"
script:
- >
if [[ "$COVERAGE" == "0" ]]; then
.build/bin/phpunit -c Build/UnitTests.xml
vendor/bin/phpunit -c Build/UnitTests.xml
fi
- >
if [[ "$COVERAGE" == "1" ]]; then
XDEBUG_MODE=coverage TYPO3_PATH_WEB=${TYPO3_PATH_WEB} .build/bin/phpunit --coverage-clover=phpunit.coverage.xml --log-junit=phpunit.report.xml -c Build/UnitTests.xml Tests/Unit
XDEBUG_MODE=coverage TYPO3_PATH_WEB=${TYPO3_PATH_WEB} vendor/bin/phpunit --coverage-clover=phpunit.coverage.xml --log-junit=phpunit.report.xml -c Build/UnitTests.xml Tests/Unit
fi
# - typo3DatabaseDriver=pdo_sqlite .build/bin/phpunit -c Build/FunctionalTests.xml
- typo3DatabaseDriver=pdo_sqlite vendor/bin/phpunit -c Build/FunctionalTests.xml
artifacts:
paths:
- phpunit.coverage.xml
Expand All @@ -146,26 +120,78 @@ phpstan:analyse:
test:php81:typo3_12:
<<: *test_php
variables:
DOCKER_TAG: 8.1-alpine
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.1:main
TYPO3_VERSION: ^12.4
COVERAGE: 0

# Build in PHP 8.2 and TYPO3 12.4
test:php82:typo3_12:
<<: *test_php
variables:
DOCKER_TAG: 8.2-alpine
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.2:main
TYPO3_VERSION: ^12.4
COVERAGE: 0

# Build in PHP 8.3 and TYPO3 12.4
test:php83:typo3_12:
<<: *test_php
variables:
DOCKER_TAG: 8.3-alpine
CONTAINER_IMAGE: $CI_REGISTRY/containers/phpunit-with-php-8.3:main
TYPO3_VERSION: ^12.4
COVERAGE: 1

.test_codeception: &test_codeception
stage: test
image: $CONTAINER_IMAGE
only:
- branches
before_script:
- sed -i -e "s#ssh://git@code.extco.de:22722#https://gitlab-ci-token:$CI_JOB_TOKEN@code.extco.de#g" composer.json
- composer config --no-plugins allow-plugins.typo3/cms-composer-installers true
- composer config --no-plugins allow-plugins.typo3/class-alias-loader true
- composer require typo3/cms-core="${TYPO3_VERSION}"
script:
- mkdir -p .build/public/typo3temp/var/tests/acceptance-sqlite-dbs
- export typo3DatabaseDriver=pdo_sqlite
- export PROJECT_ROOT="$(pwd)"
- export INSTANCE_PATH="$(pwd)/.build/web/typo3temp/var/tests/acceptance"
- mkdir -p "$INSTANCE_PATH"
- mkdir -p "$PROJECT_ROOT/.build/web/typo3temp/var/tests/acceptance-logs/"
- vendor/bin/codecept run
artifacts:
paths:
- .build
expire_in: 1 day
when: always

# Build in PHP 8.1 and TYPO3 12.4
test:codception:php81:typo3_12:
<<: *test_codeception
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.1:main
TYPO3_VERSION: ^12.4
GECKODRIVER_VERSION: v0.34.0

# Build in PHP 8.2 and TYPO3 12.4
test:codception:php82:typo3_12:
<<: *test_codeception
needs:
- test:codception:php81:typo3_12
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.2:main
TYPO3_VERSION: ^12.4
GECKODRIVER_VERSION: v0.34.0

# Build in PHP 8.3 and TYPO3 12.4
test:codception:php83:typo3_12:
<<: *test_codeception
needs:
- test:codception:php82:typo3_12
variables:
CONTAINER_IMAGE: $CI_REGISTRY/containers/codeception-with-php-8.3:main
TYPO3_VERSION: ^12.4
GECKODRIVER_VERSION: v0.34.0

documentation:
stage: documentation
image:
Expand Down
4 changes: 2 additions & 2 deletions Build/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
'@PER' => true,
'@PER-CS' => true,
'array_syntax' => ['syntax' => 'short'],
'cast_spaces' => ['space' => 'none'],
'concat_space' => ['spacing' => 'one'],
'declare_equal_normalize' => ['space' => 'none'],
'declare_parentheses' => true,
'dir_constant' => true,
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
'function_typehint_space' => true,
'modernize_strpos' => true,
'modernize_types_casting' => true,
'native_function_casing' => true,
Expand Down Expand Up @@ -58,6 +57,7 @@
'single_space_around_construct' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'type_declaration_spaces' => true,
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],
]);
2 changes: 1 addition & 1 deletion Build/FunctionalTests.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" colors="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php" colors="true" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" beStrictAboutTestsThatDoNotTestAnything="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" requireCoverageMetadata="false">
<coverage/>
<testsuites>
<testsuite name="Cart Products Extension">
Expand Down
2 changes: 1 addition & 1 deletion Build/UnitTests.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../.build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false" requireCoverageMetadata="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="true" bootstrap="../vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" colors="true" processIsolation="false" stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" stopOnSkipped="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false" requireCoverageMetadata="false">
<coverage/>
<testsuites>
<testsuite name="Cart Products Extension">
Expand Down
2 changes: 2 additions & 0 deletions Build/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ parameters:
- ../Tests
- ../ext_emconf.php
- ../ext_localconf.php
excludePaths:
- ../Tests/Acceptance
4 changes: 2 additions & 2 deletions Classes/Domain/Repository/Product/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public function findDemanded(ProductDemand $demand)
$categoryConstraints[] = $query->contains('category', $category);
$categoryConstraints[] = $query->contains('categories', $category);
}
$constraints = $query->logicalOr($categoryConstraints);
$constraints[] = $query->logicalOr(...array_values($categoryConstraints));
}

if (!empty($constraints)) {
$query->matching(
$query->logicalAnd($constraints)
$query->logicalAnd(...array_values($constraints))
);
}

Expand Down
Empty file added Tests/Acceptance/Data/.gitkeep
Empty file.
Loading
Loading