diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 944ca0c..0a3c7e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ jobs: strategy: fail-fast: true matrix: - php: [ "8.2" ] + php: [ "8.3" ] runs-on: [self-hosted, linux, x64] name: PHP@${{ matrix.php }} @@ -22,6 +22,8 @@ jobs: - name: Install composer dependencies run: composer install --prefer-dist --no-progress --no-suggest + env: + COMPOSER_ALLOW_SUPERUSER: 1 - name: Run Testsuite run: composer run-script test @@ -30,4 +32,7 @@ jobs: run: composer run-script lint - name: Run Static Analysis - run: composer run-script analyse \ No newline at end of file + run: composer run-script analyse + + - name: Run Type Coverage + run: composer run-script coverage:type \ No newline at end of file diff --git a/.gitignore b/.gitignore index 82246e9..f03b9a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /vendor/ composer.lock -.phpunit.result.cache +.phpunit.cache coverage.xml /coverage/ junit.xml \ No newline at end of file diff --git a/composer.json b/composer.json index 4c0a42e..cdeca1a 100644 --- a/composer.json +++ b/composer.json @@ -3,29 +3,29 @@ "type": "package", "description": "The Gaudigame Engine", "require": { - "php": "8.2.*" + "php": "8.3.*" }, "require-dev": { - "laravel/pint": "^1.4", - "pestphp/pest": "^1.22", - "phpstan/phpstan": "^1.9" + "laravel/pint": "^1.14", + "pestphp/pest": "^2.34", + "pestphp/pest-plugin-type-coverage": "^2.8", + "phpstan/phpstan": "^1.10.59" }, "autoload": { "psr-4": { "Lentex\\Gaudigame\\Engine\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "Tests\\": "tests/" - } - }, "scripts": { "analyse": "phpstan analyse src tests --memory-limit 512M", "lint": "pint --test", "lint:verbose": "pint -v --test", "fix": "pint", "test": "pest", + "test:all": "@test", + "test:unit": "pest --group=unit", + "test:architecture": "pest --group=architecture", + "coverage:type": "pest --type-coverage --min=100", "coverage": "pest --coverage --ci --coverage-html coverage --coverage-clover coverage.xml --log-junit junit.xml", "report": "pest --coverage", "report:html": "pest --coverage --coverage-html coverage" @@ -34,7 +34,8 @@ "optimize-autoloader": true, "sort-packages": true, "allow-plugins": { - "pestphp/pest-plugin": true + "pestphp/pest-plugin": true, + "pestphp/pest-plugin-type-coverage": true } }, "prefer-stable": true, diff --git a/phpstan.neon b/phpstan.neon index ccde519..9a59341 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -14,10 +14,14 @@ parameters: # @see https://pestphp.com/docs/underlying-test-case - message: '#^Undefined variable: \$this$#' - paths: - - tests/* + reportUnmatched: false + path: tests/* - - message: '#^Call to an undefined method Pest\\Expectation\|Pest\\Support\\Extendable\:\:[a-zA-Z]+\(\)\.$#' - paths: - - tests/* + message: '#^Call to an undefined method Pest\\Expectation<([a-zA-Z|\\\\]+)>\:\:[a-zA-Z]+\(\)\.$#' + reportUnmatched: false + path: tests/* + - + message: "#^Call to an undefined method Pest\\\\PendingCalls\\\\TestCall\\:\\:expect\\(\\)\\.$#" + reportUnmatched: false + path: tests/* diff --git a/phpunit.xml b/phpunit.xml index ec8702d..2616389 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,17 +1,16 @@ - - - - ./tests - - - - - ./src - - + + + + ./tests/Unit + + + ./tests/Architecture + + + + + ./src + + diff --git a/src/Contracts/CalculationModel.php b/src/Contracts/CalculationModel.php index 1710328..6f8d11e 100644 --- a/src/Contracts/CalculationModel.php +++ b/src/Contracts/CalculationModel.php @@ -1,5 +1,7 @@ setupCalculationBasis(); } diff --git a/tests/Architecture/ArchitectureTest.php b/tests/Architecture/ArchitectureTest.php new file mode 100644 index 0000000..093fa86 --- /dev/null +++ b/tests/Architecture/ArchitectureTest.php @@ -0,0 +1,16 @@ +expect('Lentex\Gaudigame\Engine') + ->toUseStrictTypes(); + +arch('contracts') + ->expect('Lentex\Gaudigame\Engine\Contracts') + ->toBeInterface(); + +arch('final') + ->expect('Lentex\Gaudigame\Engine') + ->classes() + ->toBeFinal(); diff --git a/tests/Pest.php b/tests/Pest.php index f3a783d..64c24a5 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,32 +1,13 @@ in('Feature'); - -/* -|-------------------------------------------------------------------------- -| Expectations -|-------------------------------------------------------------------------- -| -| When you're writing tests, you often need to check that values meet certain conditions. The -| "expect()" function gives you access to a set of "expectations" methods that you can use -| to assert different things. Of course, you may extend the Expectation API at any time. -| -*/ +declare(strict_types=1); use Lentex\Gaudigame\Engine\DefaultCalculationModel; use Lentex\Gaudigame\Engine\Score; +uses()->group('architecture')->in('Architecture'); +uses()->group('unit')->in('Unit'); + expect()->extend('toBeNoGuess', function () { $this->getPoints()->toEqual((float) (new DefaultCalculationModel())->getPointsForNoGuess()) ->isExact()->toBeFalse() diff --git a/tests/MatchCalculatorTest.php b/tests/Unit/MatchCalculatorTest.php similarity index 99% rename from tests/MatchCalculatorTest.php rename to tests/Unit/MatchCalculatorTest.php index ea3c8a7..24b06b3 100644 --- a/tests/MatchCalculatorTest.php +++ b/tests/Unit/MatchCalculatorTest.php @@ -1,6 +1,6 @@