diff --git a/.github/docker/ci/Dockerfile b/.github/docker/ci/Dockerfile index 709d5fe2ad..6cc8bc4b0a 100644 --- a/.github/docker/ci/Dockerfile +++ b/.github/docker/ci/Dockerfile @@ -136,6 +136,9 @@ RUN set -eux; \ RUN printf '%s\n' 'swoole.use_shortname=Off' > /usr/local/etc/php/conf.d/99-swoole-shortname.ini +# The base image can ship an older Composer than the 2.11+ required for the cooldown. +COPY --from=composer/composer:latest-bin /composer /usr/local/bin/composer + # The development Composer root declares the FTP capability supplied by Swoole. RUN php -r 'if (! function_exists("ftp_connect") || extension_loaded("ftp")) { fwrite(STDERR, "Swoole FTP support without the separate FTP extension is required for filesystem tests.\n"); exit(1); }' diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock new file mode 100644 index 0000000000..2e3fb3258b --- /dev/null +++ b/.github/workflows/actions.lock @@ -0,0 +1,109 @@ +# This file is machine-generated by `gh actions-lock`. +# Do not edit by hand; run `gh actions-lock` to update. +# Docs: https://gh.io/actions-lockfile +version: 'v0.0.3' +workflows: + '.github/workflows/ci-images.yml': + - 'actions/checkout@v7.0.1' + - 'actions/delete-package-versions@v5.0.0' + - 'docker/login-action@v4.6.0' + '.github/workflows/databases-nightly.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/databases.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/doctum.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-node@v7.1.0' + '.github/workflows/engine.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/framework.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/grpc.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-go@v7.0.0' + '.github/workflows/mercure.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/publishing-tests.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/redis.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/release.yml': + - 'actions/checkout@v7.0.1' + - 'actions/github-script@v9.0.0' + - 'softprops/action-gh-release@v3.0.3' + - 'stefanzweifel/git-auto-commit-action@v7.2.1' + '.github/workflows/reverb.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/scout.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/skeletons.yml': + - 'actions/checkout@v7.0.1' + - 'actions/setup-node@v7.1.0' + '.github/workflows/split.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/static-analysis.yml': + - 'actions/checkout@v7.0.1' + '.github/workflows/submission-maintenance.yml': + - 'actions/checkout@v7.0.1' + - 'actions/github-script@v9.0.0' + - 'actions/setup-node@v7.1.0' + '.github/workflows/sync-grpc-health-protocol.yml': + - 'actions/checkout@v7.0.1' + - 'peter-evans/create-pull-request@v8.1.1' + '.github/workflows/sync-passkeys-aaguids.yml': + - 'actions/checkout@v7.0.1' + - 'peter-evans/create-pull-request@v8.1.1' + '.github/workflows/tests.yml': + - 'actions/checkout@v7.0.1' + - 'voidzero-dev/setup-vp@v1.22.0' +dependencies: + 'actions/checkout@v7.0.1': + ref: 'v7.0.1' + commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1' + owner_id: 44036562 + repo_id: 197814629 + 'actions/delete-package-versions@v5.0.0': + ref: 'v5.0.0' + commit: 'sha1-e5bc658cc4c965c472efe991f8beea3981499c55' + owner_id: 44036562 + repo_id: 237012274 + 'actions/github-script@v9.0.0': + ref: 'v9.0.0' + commit: 'sha1-3a2844b7e9c422d3c10d287c895573f7108da1b3' + owner_id: 44036562 + repo_id: 205262760 + 'actions/setup-go@v7.0.0': + ref: 'v7.0.0' + commit: 'sha1-b7ad1dad31e06c5925ef5d2fc7ad053ef454303e' + owner_id: 44036562 + repo_id: 192624594 + 'actions/setup-node@v7.1.0': + ref: 'v7.1.0' + commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1' + owner_id: 44036562 + repo_id: 189476904 + 'docker/login-action@v4.6.0': + ref: 'v4.6.0' + commit: 'sha1-dbcb813823bdd20940b903addbd779551569679f' + owner_id: 5429470 + repo_id: 287743349 + 'peter-evans/create-pull-request@v8.1.1': + ref: 'v8.1.1' + commit: 'sha1-5f6978faf089d4d20b00c7766989d076bb2fc7f1' + owner_id: 18365890 + repo_id: 197176365 + 'softprops/action-gh-release@v3.0.3': + ref: 'v3.0.3' + commit: 'sha1-efb35369e0ad2afab669f228072c1b0d510eae64' + owner_id: 2242 + repo_id: 204253808 + 'stefanzweifel/git-auto-commit-action@v7.2.1': + ref: 'v7.2.1' + commit: 'sha1-d0b01107b5db882071f96de5dd4b54961ea93f4c' + owner_id: 1080923 + repo_id: 191163758 + 'voidzero-dev/setup-vp@v1.22.0': + ref: 'v1.22.0' + commit: 'sha1-cab1ab9eaff52d4857875f4f2c016e36af8f2c76' + owner_id: 149750581 + repo_id: 1133264797 diff --git a/.github/workflows/ci-images.yml b/.github/workflows/ci-images.yml index d30f1319ce..c21bd0395d 100644 --- a/.github/workflows/ci-images.yml +++ b/.github/workflows/ci-images.yml @@ -35,12 +35,12 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Log in to GitHub Container Registry - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 + uses: docker/login-action@v4.6.0 with: registry: ghcr.io username: ${{ github.actor }} @@ -74,7 +74,7 @@ jobs: steps: - name: Remove old untagged images - uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0 + uses: actions/delete-package-versions@v5.0.0 with: package-name: components-ci package-type: container diff --git a/.github/workflows/databases-nightly.yml b/.github/workflows/databases-nightly.yml index 20727cb6c3..d873e77a4a 100644 --- a/.github/workflows/databases-nightly.yml +++ b/.github/workflows/databases-nightly.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -84,7 +84,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/databases.yml b/.github/workflows/databases.yml index 882c36a641..b297940d88 100644 --- a/.github/workflows/databases.yml +++ b/.github/workflows/databases.yml @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -100,7 +100,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -168,7 +168,7 @@ jobs: # steps: # - name: Checkout code - # uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + # uses: actions/checkout@v7.0.1 # with: # persist-credentials: false @@ -223,7 +223,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -276,7 +276,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -329,7 +329,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -381,7 +381,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -429,7 +429,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -464,7 +464,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/doctum.yml b/.github/workflows/doctum.yml index f4a41ae4b6..d591580181 100644 --- a/.github/workflows/doctum.yml +++ b/.github/workflows/doctum.yml @@ -17,7 +17,7 @@ jobs: contents: read steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: fetch-depth: 0 persist-credentials: false @@ -42,7 +42,7 @@ jobs: php -d memory_limit=-1 /tmp/doctum update doctum.php --force - name: Setup Node.js - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + uses: actions/setup-node@v7.1.0 with: node-version: 24 diff --git a/.github/workflows/engine.yml b/.github/workflows/engine.yml index 704d0d4d86..4e22910b9e 100644 --- a/.github/workflows/engine.yml +++ b/.github/workflows/engine.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/framework.yml b/.github/workflows/framework.yml index 14325162a5..80a1baf160 100644 --- a/.github/workflows/framework.yml +++ b/.github/workflows/framework.yml @@ -24,7 +24,7 @@ jobs: HYPERVEL_INSTALL_DIR: ${{ github.workspace }}/.tmp/framework-install COMPOSER_MEMORY_LIMIT: '-1' steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/grpc.yml b/.github/workflows/grpc.yml index cccfc6343e..7dcf12034a 100644 --- a/.github/workflows/grpc.yml +++ b/.github/workflows/grpc.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -37,7 +37,7 @@ jobs: uses: ./.github/actions/log-trigger-context - name: Setup Go - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + uses: actions/setup-go@v7.0.0 with: go-version-file: tests/Integration/Grpc/Fixtures/Interop/go.mod cache-dependency-path: tests/Integration/Grpc/Fixtures/Interop/go.sum diff --git a/.github/workflows/mercure.yml b/.github/workflows/mercure.yml index d2a0df5029..f70a167257 100644 --- a/.github/workflows/mercure.yml +++ b/.github/workflows/mercure.yml @@ -48,7 +48,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/publishing-tests.yml b/.github/workflows/publishing-tests.yml index 9b321256ed..6a8ba13cfb 100644 --- a/.github/workflows/publishing-tests.yml +++ b/.github/workflows/publishing-tests.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 - name: Check shell syntax run: | bash -n bin/split.sh diff --git a/.github/workflows/redis.yml b/.github/workflows/redis.yml index 78e64a7456..21d811a699 100644 --- a/.github/workflows/redis.yml +++ b/.github/workflows/redis.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -52,22 +52,7 @@ jobs: REDIS_PORT: 6379 REDIS_DB: 0 REDIS_TEST_SECONDARY_DB: 1 - # Cap ParaTest's auto-detected workers: database 1 is reserved via - # REDIS_TEST_SECONDARY_DB, leaving 15 worker databases in the 0-15 range. - run: | - vendor/bin/paratest --max-processes=15 tests/Integration/Auth/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Broadcasting/Redis - CACHE_STORE=redis vendor/bin/paratest --max-processes=15 tests/Integration/Cache - vendor/bin/paratest --max-processes=15 tests/Integration/Horizon - vendor/bin/paratest --max-processes=15 tests/Integration/Http/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/OpenTelemetry/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Pennant/Redis - CACHE_STORE=redis vendor/bin/paratest --max-processes=15 tests/Permission - QUEUE_CONNECTION=redis vendor/bin/paratest --max-processes=15 tests/Integration/Queue - vendor/bin/paratest --max-processes=15 tests/Integration/RateLimiter/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Saloon/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Session/Redis + run: bin/run-redis-tests.sh standalone redis_cluster: runs-on: ubuntu-latest @@ -92,7 +77,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -204,33 +189,7 @@ jobs: ' - name: Execute Redis Cluster integration tests - run: | - vendor/bin/phpunit --no-progress tests/Integration/Auth/Redis - vendor/bin/phpunit --no-progress tests/Integration/Broadcasting/Redis - CACHE_STORE=redis vendor/bin/phpunit --no-progress tests/Integration/Cache - vendor/bin/phpunit --no-progress tests/Integration/Horizon - vendor/bin/phpunit --no-progress tests/Integration/Http/Redis - vendor/bin/phpunit --no-progress tests/Integration/OpenTelemetry/Redis - vendor/bin/phpunit --no-progress tests/Integration/Pennant/Redis - QUEUE_CONNECTION=redis vendor/bin/phpunit --no-progress tests/Integration/Queue - vendor/bin/phpunit --no-progress tests/Integration/RateLimiter/Redis - vendor/bin/phpunit --no-progress tests/Integration/Saloon/Redis - vendor/bin/phpunit --no-progress tests/Integration/Session/Redis - # This explicit list contains the topology-neutral Redis tests; the remaining files require standalone-only behavior. - vendor/bin/phpunit --no-progress \ - tests/Integration/Redis/ConcurrencyLimiterIntegrationTest.php \ - tests/Integration/Redis/DurationLimiterIntegrationTest.php \ - tests/Integration/Redis/EvalWithShaCacheIntegrationTest.php \ - tests/Integration/Redis/RedisClusterIntegrationTest.php \ - tests/Integration/Redis/RedisConnectionTest.php \ - tests/Integration/Redis/RedisEventsIntegrationTest.php \ - tests/Integration/Redis/RedisPoolHeartbeatIntegrationTest.php \ - tests/Integration/Redis/RedisPoolTeardownLifecycleTest.php \ - tests/Integration/Redis/RedisSubscribeIntegrationTest.php \ - tests/Integration/Redis/SafeScanIntegrationTest.php - vendor/bin/phpunit --no-progress \ - tests/Integration/Reverb/RedisSharedStateTest.php \ - tests/Integration/Reverb/WebhookBatchBufferTest.php + run: bin/run-redis-tests.sh cluster valkey_9: runs-on: ubuntu-latest @@ -258,7 +217,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -274,19 +233,4 @@ jobs: REDIS_PORT: 6379 REDIS_DB: 0 REDIS_TEST_SECONDARY_DB: 1 - # Cap ParaTest's auto-detected workers: database 1 is reserved via - # REDIS_TEST_SECONDARY_DB, leaving 15 worker databases in the 0-15 range. - run: | - vendor/bin/paratest --max-processes=15 tests/Integration/Auth/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Broadcasting/Redis - CACHE_STORE=redis vendor/bin/paratest --max-processes=15 tests/Integration/Cache - vendor/bin/paratest --max-processes=15 tests/Integration/Horizon - vendor/bin/paratest --max-processes=15 tests/Integration/Http/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/OpenTelemetry/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Pennant/Redis - QUEUE_CONNECTION=redis vendor/bin/paratest --max-processes=15 tests/Integration/Queue - vendor/bin/paratest --max-processes=15 tests/Integration/RateLimiter/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Redis - vendor/bin/phpunit --no-progress tests/Integration/Reverb/ClearStateCommandTest.php - vendor/bin/paratest --max-processes=15 tests/Integration/Saloon/Redis - vendor/bin/paratest --max-processes=15 tests/Integration/Session/Redis + run: bin/run-redis-tests.sh standalone diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cb37321fe3..8a1e225b63 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,7 +27,7 @@ jobs: container: image: ghcr.io/hypervel/components-ci:php8.4-swoole6.3.0-rc1 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install dependencies @@ -41,7 +41,7 @@ jobs: timeout-minutes: 30 steps: - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: fetch-depth: 0 # Version commits and framework tag pushes authenticate through origin. @@ -75,7 +75,7 @@ jobs: - name: Fail if branch and release tag do not match if: ${{ steps.guard.outputs.VERSION_MISMATCH == 'true' }} - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + uses: actions/github-script@v9.0.0 with: script: | core.setFailed('Workflow failed. Release version does not match with selected target branch. Did you select the correct branch?') @@ -100,7 +100,7 @@ jobs: VERSION: ${{ steps.version.outputs.version }} - name: Commit version change - uses: stefanzweifel/git-auto-commit-action@d0b01107b5db882071f96de5dd4b54961ea93f4c # v7.2.1 + uses: stefanzweifel/git-auto-commit-action@v7.2.1 with: commit_message: "Update version to v${{ steps.version.outputs.version }}" @@ -118,7 +118,7 @@ jobs: VERSION: ${{ steps.version.outputs.version }} - name: Create release notes - uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 + uses: softprops/action-gh-release@v3.0.3 with: generate_release_notes: true name: v${{ steps.version.outputs.version }} diff --git a/.github/workflows/reverb.yml b/.github/workflows/reverb.yml index f3293e0532..1529216b64 100644 --- a/.github/workflows/reverb.yml +++ b/.github/workflows/reverb.yml @@ -41,7 +41,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/scout.yml b/.github/workflows/scout.yml index 2caf99906f..863a5f61b1 100644 --- a/.github/workflows/scout.yml +++ b/.github/workflows/scout.yml @@ -38,7 +38,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -78,7 +78,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -112,7 +112,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/skeletons.yml b/.github/workflows/skeletons.yml index 1fe4d0e50a..c6c5b903f1 100644 --- a/.github/workflows/skeletons.yml +++ b/.github/workflows/skeletons.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -66,7 +66,7 @@ jobs: php artisan migrate --force --no-interaction - name: Setup Node.js - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + uses: actions/setup-node@v7.1.0 with: node-version: 24 diff --git a/.github/workflows/split.yml b/.github/workflows/split.yml index 1f77358807..0c692562b5 100644 --- a/.github/workflows/split.yml +++ b/.github/workflows/split.yml @@ -26,7 +26,7 @@ jobs: container: image: ghcr.io/hypervel/components-ci:php8.4-swoole6.3.0-rc1 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - name: Install dependencies @@ -41,7 +41,7 @@ jobs: timeout-minutes: 30 steps: - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: fetch-depth: 0 # The split script reads the public origin anonymously and pushes split repositories over SSH. diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 1b5f4733fc..bf0e40293a 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,6 +10,27 @@ permissions: contents: read jobs: + actions_lockfile: + name: Verify Actions Lockfile + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Checkout code + uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + - name: Log trigger context + uses: ./.github/actions/log-trigger-context + + - name: Verify Actions lockfile + env: + GH_TOKEN: ${{ github.token }} + run: | + gh extension install github/gh-actions-lock --pin v0.4.1 + gh actions-lock --verify + types: runs-on: ubuntu-latest timeout-minutes: 10 @@ -22,6 +43,8 @@ jobs: config: phpstan.neon.dist - name: Types config: phpstan.types.neon.dist + - name: Test Rules + config: phpstan.tests.neon.dist name: ${{ matrix.name }} @@ -30,7 +53,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false diff --git a/.github/workflows/submission-maintenance.yml b/.github/workflows/submission-maintenance.yml index b5378ad23a..0ef73b3b71 100644 --- a/.github/workflows/submission-maintenance.yml +++ b/.github/workflows/submission-maintenance.yml @@ -30,10 +30,10 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: persist-credentials: false - - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + - uses: actions/setup-node@v7.1.0 with: node-version: 24 - run: node --test .github/scripts/submission-cleanup.test.cjs @@ -54,12 +54,12 @@ jobs: pull-requests: write steps: # The write-enabled job only loads scripts from the trusted default branch. - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: actions/checkout@v7.0.1 with: ref: ${{ github.event.repository.default_branch }} persist-credentials: false sparse-checkout: .github/scripts - - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + - uses: actions/github-script@v9.0.0 env: CLEANUP_DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run }} with: diff --git a/.github/workflows/sync-grpc-health-protocol.yml b/.github/workflows/sync-grpc-health-protocol.yml index 471bb9b5f7..77a0c5aa27 100644 --- a/.github/workflows/sync-grpc-health-protocol.yml +++ b/.github/workflows/sync-grpc-health-protocol.yml @@ -25,7 +25,7 @@ jobs: apt-get install -y -qq curl git rsync unzip > /dev/null - name: Checkout default branch - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false ref: ${{ github.event.repository.default_branch }} @@ -50,7 +50,7 @@ jobs: vendor/bin/paratest tests/Grpc - name: Open update pull request - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + uses: peter-evans/create-pull-request@v8.1.1 with: add-paths: | src/grpc/resources/proto/README.md diff --git a/.github/workflows/sync-passkeys-aaguids.yml b/.github/workflows/sync-passkeys-aaguids.yml index a21206a92a..b2809064e4 100644 --- a/.github/workflows/sync-passkeys-aaguids.yml +++ b/.github/workflows/sync-passkeys-aaguids.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Checkout default branch - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false ref: ${{ github.event.repository.default_branch }} @@ -32,7 +32,7 @@ jobs: run: php src/passkeys/scripts/sync-aaguids.php - name: Open update pull request - uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + uses: peter-evans/create-pull-request@v8.1.1 with: base: ${{ github.event.repository.default_branch }} branch: sync-passkeys-aaguids diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a8c20e1536..896751ec48 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,24 +13,19 @@ env: RUN_BLOCKING_TESTS: true jobs: - linux_tests: + code_style: runs-on: ubuntu-latest timeout-minutes: 20 if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" - strategy: - fail-fast: false - matrix: - php: ["8.4", "8.5"] - - name: PHP ${{ matrix.php }} (Swoole 6.3.0 RC1) + name: Code Style and Skeleton Config container: - image: ghcr.io/hypervel/components-ci:php${{ matrix.php }}-swoole6.3.0-rc1 + image: ghcr.io/hypervel/components-ci:php8.4-swoole6.3.0-rc1 steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -38,8 +33,7 @@ jobs: uses: ./.github/actions/log-trigger-context - name: Install dependencies - run: | - COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o + run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o - name: Check code style run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --dry-run --diff @@ -47,12 +41,65 @@ jobs: - name: Check skeleton configuration run: composer check:skeleton-config + framework_tests: + runs-on: ubuntu-latest + timeout-minutes: 20 + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + + strategy: + fail-fast: false + matrix: &runtime_matrix + php: ["8.4", "8.5"] + + name: Framework Tests (PHP ${{ matrix.php }}, Swoole 6.3.0 RC1) + + container: + image: ghcr.io/hypervel/components-ci:php${{ matrix.php }}-swoole6.3.0-rc1 + + steps: + - name: Checkout code + uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + - name: Log trigger context + uses: ./.github/actions/log-trigger-context + + - name: Install dependencies + run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o + - name: Run framework test suite run: vendor/bin/paratest -c phpunit.xml.dist - name: Run Permission suite with the database cache store run: CACHE_STORE=database vendor/bin/paratest -c phpunit.xml.dist tests/Permission + package_tests: + runs-on: ubuntu-latest + timeout-minutes: 20 + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + + strategy: + fail-fast: false + matrix: *runtime_matrix + + name: PHPStan and Package Tests (PHP ${{ matrix.php }}, Swoole 6.3.0 RC1) + + container: + image: ghcr.io/hypervel/components-ci:php${{ matrix.php }}-swoole6.3.0-rc1 + + steps: + - name: Checkout code + uses: actions/checkout@v7.0.1 + with: + persist-credentials: false + + - name: Log trigger context + uses: ./.github/actions/log-trigger-context + + - name: Install dependencies + run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o + - name: Run PHPStan analyzer suite run: vendor/bin/paratest -c phpunit.phpstan.xml.dist @@ -89,7 +136,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + uses: actions/checkout@v7.0.1 with: persist-credentials: false @@ -103,7 +150,7 @@ jobs: run: COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o - name: Setup Vite+ and install dependencies - uses: voidzero-dev/setup-vp@cab1ab9eaff52d4857875f4f2c016e36af8f2c76 # v1.22.0 + uses: voidzero-dev/setup-vp@v1.22.0 with: node-version-file: package.json cache: true diff --git a/AGENTS.md b/AGENTS.md index 2e6e288931..2d3edaf1ee 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -442,7 +442,15 @@ In any test, PHPUnit assertion failures, skips, and incomplete markers extend `A Laravel-ported tests follow upstream placement; the rules below apply to Hypervel-only test files. All tests live in `tests/{PackageName}/` (PascalCase). Tests that require external services go in `tests/Integration/{PackageName}/` — see Integration tests below. When only some integration tests for a package require one service, group them in `tests/Integration/{PackageName}/{ServiceName}/`. When every integration test for the package requires that service, keep them directly in the package directory. -Package-specific tests that require one database driver go in `tests/Integration/{PackageName}/Database/{Postgres|MySql|MariaDb|Sqlite}/`. The database workflows discover these directories by convention. +Use these paths for service-specific test directories under `tests/Integration/{PackageName}/`. CI discovers them automatically. + +| Path | Runs on | +| --- | --- | +| `Database/*Test.php` | MySQL, MariaDB, PostgreSQL, and SQLite | +| `Database/{MySql\|MariaDb\|Postgres\|Sqlite}/` | The matching database | +| `Redis/` | Redis, Valkey, and Redis Cluster | + +Put a test class shared by multiple databases directly in `Database/`. Use `#[RequiresDatabase(...)]` on the class or individual methods when only some drivers apply. Use a driver directory for a class specific to one database. ### Base classes @@ -596,7 +604,7 @@ A per-package base class is only justified when there is shared setUp logic — Use Double for test doubles in new tests. When porting, convert direct Mockery mocks and spies to Double regardless of the upstream library; keep upstream PHPUnit doubles. Retain Mockery where required to use or test framework APIs backed by it, such as `$this->mock()`, facade expectations and `Sanctum::actingAs()`. Add `JMac\Testing\Integrations\PHPUnit\VerifiesDoubles` to each test class using Double; it owns verification and cleanup. -Double is lenient by default. Use `expects('method')->never()` to forbid a call, or `unused()` after exercising the code to assert no calls occurred. `allows()->with(...)` neither requires a matching call nor rejects other arguments. `expects()->with(...)` requires the call and rejects unmatched arguments for that method. Use `strict()` unless the test deliberately ignores unrelated calls; this applies equally to tests ported from upstream. +Double is lenient by default. Use `expects('method')->never()` to forbid a call, or `unused()` after exercising the code to assert no calls occurred. `allows()->with(...)` neither requires a matching call nor rejects other arguments. `expects()->with(...)` requires the call and rejects unmatched arguments for that method. Use `strict()` unless the test deliberately ignores unrelated calls; this applies equally to tests ported from upstream. For an intentionally lenient double, use `@phpstan-ignore hypervel.implicitDoubleMode (reason)` for the factory call. `with()` compares objects, including doubles, using `==`. Use `Argument::same($object)` when the exact instance matters or to preserve Mockery’s default identity check. @@ -717,7 +725,7 @@ Tests requiring separately configured services or public APIs go in `tests/Integ **Optimize integration tests for parallel testing** — ParaTest runs tests concurrently. Use `RefreshDatabase` by default and `DatabaseTruncation` when transaction depth zero is required; reserve `DatabaseMigrations` for migration behavior or a genuinely fresh migrated schema/baseline. Set up only the tables and services each test needs. Keep database cases in one data-provider test when splitting them would make schema setup compete. Load the full schema only when testing migrations or schema parity; do not hide avoidable slowness with longer timeouts. -Service workflows enumerate their test directories explicitly. Adding a service-specific directory requires adding it to the matching workflow; using the service trait provides isolation and skip behavior but does not make CI discover the test. +For service suites outside the directory conventions above, register new test directories in the matching workflow or the runner script it calls. The service trait handles isolation and skips. CI discovers tests by their paths. #### External service test traits @@ -747,7 +755,7 @@ When adding integration tests for a new service type that has no trait yet, crea #### GH workflows -Check `.github/workflows/` to determine which workflow runs the affected integration tests. When adding a test directory, update the appropriate workflow so CI actually runs it. +Check `.github/workflows/` to determine which workflow runs the affected integration tests. When adding integration tests that need a new service, either add them to an existing workflow or create a new one. The workflow must start the service and set the appropriate env vars. @@ -765,7 +773,7 @@ Components is analyzed with its own `hypervel/phpstan` extension. [Static Analys **Keep `hypervel/phpstan` evolving** — Codify framework contracts and useful conventions. Prefer a simple framework fix when it prevents the mistake. Add rules for mistakes likely to recur in packages or apps, even when existing cases are already fixed. Check each proposed rule against real mistakes and realistic correct usage. Reject rules that flag correct code or need a growing list of exceptions to avoid doing so. Keep inference limits explicit. Reach peer consensus, then seek owner approval for a new rule. If an existing rule flags correct code, fix the analyzer and leave the correct code alone. -The `tests/` directory is excluded from phpstan. Do not run phpstan on tests. +The main PHPStan configuration excludes `tests/`. Use `composer analyse:tests` for test-only rules. Run full PHPStan checks with `composer analyse`. During implementation, use targeted PHPStan only when investigating or validating a specific type issue. diff --git a/bin/run-database-tests.sh b/bin/run-database-tests.sh index 8acc01d925..d66ac633fc 100755 --- a/bin/run-database-tests.sh +++ b/bin/run-database-tests.sh @@ -6,78 +6,20 @@ # ./bin/run-database-tests.sh mysql # ./bin/run-database-tests.sh pgsql -p 3 --filter=EloquentPrunableTest # -# Supported connection names are mysql, mariadb, pgsql, and sqlite. The runner -# sets DB_CONNECTION from this argument. Every run executes the shared tests in -# tests/Integration/Database first. It then discovers package-specific tests -# using this exact directory convention: -# -# tests/Integration//Database/ -# -# DriverDirectory is MySql, MariaDb, Postgres, or Sqlite, as mapped below. The -# package name must occupy exactly one directory segment below Integration; -# deeper directory structures are not discovered. For example, PostgreSQL -# tests for a Permission package belong in: -# -# tests/Integration/Permission/Database/Postgres -# -# Arguments after the connection name are forwarded to every ParaTest command. -# Runs with extra options tolerate an empty individual suite because selection -# options may match only one directory; runs without extra options remain strict. +# The shared suite covers core database tests and package Database/*Test.php +# files. The connection's suite adds tests under its matching driver directory. set -euo pipefail -if [[ $# -lt 1 ]]; then - echo "Usage: $0 [ParaTest options]" >&2 - exit 2 -fi - -script_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -project_directory="$(dirname "$script_directory")" -connection=$1 -shift - -case "$connection" in - mysql) driver_directory=MySql ;; - mariadb) driver_directory=MariaDb ;; - pgsql) driver_directory=Postgres ;; - sqlite) driver_directory=Sqlite ;; +case "${1:-}" in + mysql|mariadb|pgsql|sqlite) export DB_CONNECTION="$1" ;; *) - echo "Unsupported database connection: $connection" >&2 echo "Usage: $0 [ParaTest options]" >&2 exit 2 ;; esac +shift -export DB_CONNECTION="$connection" - -paratest_options=("$@") - -# CI passes no extra options, so an unexpectedly empty suite still fails there. -# Ad-hoc selection options can legitimately match only one independently invoked suite. -if [[ $# -gt 0 ]]; then - paratest_options+=(--do-not-fail-on-empty-test-suite) -fi - -cd "$project_directory" - -printf 'Running %s\n' 'tests/Integration/Database' -vendor/bin/paratest "${paratest_options[@]}" tests/Integration/Database - -shopt -s nullglob -candidate_directories=(tests/Integration/*/Database/"$driver_directory") -test_directories=() - -for test_directory in "${candidate_directories[@]}"; do - if [[ -d "$test_directory" ]]; then - test_directories+=("$test_directory") - fi -done - -if [[ ${#test_directories[@]} -eq 0 ]]; then - printf 'No package-specific %s database test directories found.\n' "$driver_directory" -fi +cd "$(dirname "${BASH_SOURCE[0]}")/.." -for test_directory in "${test_directories[@]}"; do - printf 'Running %s\n' "$test_directory" - vendor/bin/paratest "${paratest_options[@]}" "$test_directory" -done +exec vendor/bin/paratest --testsuite="database,$DB_CONNECTION" "$@" diff --git a/bin/run-redis-tests.sh b/bin/run-redis-tests.sh new file mode 100755 index 0000000000..ce4f186e4f --- /dev/null +++ b/bin/run-redis-tests.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# Run Redis or Valkey integration tests in standalone or cluster mode. +# Package suites in tests/Integration//Redis are discovered automatically. +# Configure the test service first; arguments after the mode go to the test runner. + +set -euo pipefail + +mode=${1:-} +case "$mode" in + standalone) + # CI reserves database 1 for tests that switch databases, leaving 15 for workers. + runner=(vendor/bin/paratest --max-processes=15) + ;; + cluster) + # Cluster only supports database zero, so tests must run serially. + runner=(vendor/bin/phpunit --no-progress) + ;; + *) + echo "Usage: $0 [test runner options]" >&2 + exit 2 + ;; +esac +shift + +if (( $# )); then + # A local filter may select tests in only one of the package suites. + runner+=("$@" --do-not-fail-on-empty-test-suite) +else + runner+=(--fail-on-empty-test-suite) +fi + +cd "$(dirname "${BASH_SOURCE[0]}")/.." + +run_suite() { + printf 'Running %s\n' "$*" + "${runner[@]}" "$@" +} + +for package in tests/Integration/*; do + case "$package" in + tests/Integration/Cache) CACHE_STORE=redis run_suite "$package" ;; + tests/Integration/Horizon) run_suite "$package" ;; + tests/Integration/Queue) QUEUE_CONNECTION=redis run_suite "$package" ;; + *) + if [[ -d "$package/Redis" ]]; then + run_suite "$package/Redis" + fi + ;; + esac +done + +if [[ "$mode" == standalone ]]; then + CACHE_STORE=redis run_suite tests/Permission + run_suite tests/Integration/Redis +else + # Run only the core tests that support Cluster. The others require standalone Redis. + run_suite \ + tests/Integration/Redis/ConcurrencyLimiterIntegrationTest.php \ + tests/Integration/Redis/DurationLimiterIntegrationTest.php \ + tests/Integration/Redis/EvalWithShaCacheIntegrationTest.php \ + tests/Integration/Redis/RedisClusterIntegrationTest.php \ + tests/Integration/Redis/RedisConnectionTest.php \ + tests/Integration/Redis/RedisEventsIntegrationTest.php \ + tests/Integration/Redis/RedisPoolHeartbeatIntegrationTest.php \ + tests/Integration/Redis/RedisPoolTeardownLifecycleTest.php \ + tests/Integration/Redis/RedisSubscribeIntegrationTest.php \ + tests/Integration/Redis/SafeScanIntegrationTest.php +fi diff --git a/composer.json b/composer.json index b21386286e..7256c98969 100644 --- a/composer.json +++ b/composer.json @@ -405,7 +405,12 @@ "php-http/discovery": true, "tbachert/spi": true }, - "sort-packages": true + "sort-packages": true, + "policy": { + "cooldown": { + "period": "3 days" + } + } }, "extra": { "branch-alias": { @@ -494,9 +499,14 @@ "Composer\\Config::disableProcessTimeout", "phpstan analyse", "phpstan analyse -c phpstan.types.neon.dist", + "@analyse:tests @no_additional_args", "@analyse:skeletons @no_additional_args" ], "analyse:skeletons": "@composer --working-dir=skeletons/hypervel analyse", + "analyse:tests": [ + "Composer\\Config::disableProcessTimeout", + "phpstan analyse -c phpstan.tests.neon.dist" + ], "check": [ "@check:skeleton-config", "@test", diff --git a/dogfood/ai/composer.json b/dogfood/ai/composer.json index bf45086337..dd97115878 100644 --- a/dogfood/ai/composer.json +++ b/dogfood/ai/composer.json @@ -32,6 +32,11 @@ "allow-plugins": { "php-http/discovery": true, "tbachert/spi": true + }, + "policy": { + "cooldown": { + "period": "3 days" + } } }, "require-dev": { diff --git a/dogfood/mcp/composer.json b/dogfood/mcp/composer.json index 6b2f3eb994..52c3d85cd3 100644 --- a/dogfood/mcp/composer.json +++ b/dogfood/mcp/composer.json @@ -30,6 +30,11 @@ "allow-plugins": { "php-http/discovery": true, "tbachert/spi": true + }, + "policy": { + "cooldown": { + "period": "3 days" + } } }, "scripts": { diff --git a/dogfood/testbench-package/composer.json b/dogfood/testbench-package/composer.json index 7967a55565..1190710370 100644 --- a/dogfood/testbench-package/composer.json +++ b/dogfood/testbench-package/composer.json @@ -19,7 +19,10 @@ "type": "path", "url": "../..", "options": { - "symlink": true + "symlink": true, + "versions": { + "hypervel/components": "0.4.x-dev" + } } } ], @@ -38,6 +41,13 @@ "phpunit/phpunit": "~13.4.3", "symfony/yaml": "^8.1" }, + "config": { + "policy": { + "cooldown": { + "period": "3 days" + } + } + }, "extra": { "hypervel": { "providers": [ diff --git a/phpstan.tests.neon.dist b/phpstan.tests.neon.dist new file mode 100644 index 0000000000..79d6ab9c01 --- /dev/null +++ b/phpstan.tests.neon.dist @@ -0,0 +1,23 @@ +parameters: + customRulesetUsed: true + tmpDir: .cache/phpstan-tests + paths: + - tests + # Analyzer fixtures exercise other rules and type configurations. + excludePaths: + analyse: + - tests/PHPStan/*/data/* + - tests/PHPStan/Fixtures + - tests/PHPStan/application + # Inline ignores in shared test files may belong to the other configurations. + reportUnmatchedIgnoredErrors: false + ignoreErrors: + # PHPStan API compatibility is separate from the test authoring checks. + - + identifiers: + - phpstanApi.method + - phpstanApi.classConstant + path: tests/PHPStan/* + +rules: + - Hypervel\PHPStan\Rules\Testing\RequireExplicitDoubleModeRule diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a39713c97d..a2880ee3da 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,6 @@ ./tests/PHPStan + + ./tests/Integration/Database + ./tests/Integration/*/Database + + ./tests/Integration/*/Database/*/ + + + ./tests/Integration/*/Database/MySql + + + ./tests/Integration/*/Database/MariaDb + + + ./tests/Integration/*/Database/Postgres + + + ./tests/Integration/*/Database/Sqlite + diff --git a/skeletons/hypervel/composer.json b/skeletons/hypervel/composer.json index d650f9ec9d..85cf6594d5 100644 --- a/skeletons/hypervel/composer.json +++ b/skeletons/hypervel/composer.json @@ -48,6 +48,11 @@ "sort-packages": true, "allow-plugins": { "phpstan/extension-installer": true + }, + "policy": { + "cooldown": { + "period": "3 days" + } } }, "extra": { diff --git a/src/docs/contributions.md b/src/docs/contributions.md index 3e311615d7..8daf65638a 100644 --- a/src/docs/contributions.md +++ b/src/docs/contributions.md @@ -198,7 +198,9 @@ bin/run-database-tests.sh pgsql bin/run-database-tests.sh sqlite ``` -The runner sets `DB_CONNECTION` from this argument. Configure the remaining database environment variables (see `.env.example`) before running the command. Any additional ParaTest options are forwarded to each database test suite. For example, you may use `bin/run-database-tests.sh pgsql -p 3 --filter=EloquentPrunableTest` to control the worker count and select a specific test. +The runner sets `DB_CONNECTION` from this argument. Configure the remaining database environment variables (see `.env.example`) before running the command. Each run includes tests directly under `tests/Integration//Database/` and the matching `MySql/`, `MariaDb/`, `Postgres/`, or `Sqlite/` subdirectory. Additional options are passed to ParaTest. For example, you may use `bin/run-database-tests.sh pgsql -p 3 --filter=EloquentPrunableTest` to control the worker count and select a specific test. + +Configure the Redis test environment variables (see `.env.example`). Run `bin/run-redis-tests.sh standalone` for Redis or Valkey, or `bin/run-redis-tests.sh cluster` for Redis Cluster. Both modes discover `tests/Integration//Redis/` and accept test runner options such as `--filter=RedisSharedStateTest`. Do not disable checks, skip affected tests, or weaken assertions to make a pull request pass. diff --git a/src/docs/static-analysis.md b/src/docs/static-analysis.md index 9855302bb7..29304049ea 100644 --- a/src/docs/static-analysis.md +++ b/src/docs/static-analysis.md @@ -3,6 +3,7 @@ - [Introduction](#introduction) - [Installation](#installation) - [Analyzing Packages](#analyzing-packages) + - [Checking Test Doubles](#checking-test-doubles) - [Runtime Requirements](#runtime-requirements) - [Configuration](#configuration) - [What the Analysis Knows](#what-the-analysis-knows) @@ -82,7 +83,7 @@ Hypervel's `hypervel/phpstan` package extends [PHPStan](https://phpstan.org) wit ## Installation -New applications include the package already, so you may run `composer analyse` right away. To add it to an existing application or package, install it as a development dependency. The package requires PHPStan 2.3.5 or later: +New applications include the package already, so you may run `composer analyse` right away. To add it to an existing application or package, install it as a development dependency. The package requires PHPStan 2.3.6 or later: ```shell composer require hypervel/phpstan --dev @@ -114,6 +115,29 @@ You should load the extension whenever you analyze Hypervel code. Without it, PH To analyze a package, install `hypervel/testbench` as a development dependency. PHPStan uses the providers, configuration and package discovery settings in your `testbench.yaml` file, just like your package's tests. Authentication types come from the Testbench application, where `AUTH_MODEL` or the workbench `User` model selects the user model. + +### Checking Test Doubles + +Double accepts unexpected calls by default. To check that your tests choose `strict()` or `passthru()` before using a double, add a separate `phpstan.tests.neon.dist` file: + +```neon +parameters: + customRulesetUsed: true + tmpDir: .cache/phpstan-tests + paths: + - tests + +rules: + - Hypervel\PHPStan\Rules\Testing\RequireExplicitDoubleModeRule +``` + +Run `vendor/bin/phpstan analyse -c phpstan.tests.neon.dist`. If a test intentionally ignores unrelated calls, explain why with a local ignore: + +```php +// @phpstan-ignore hypervel.implicitDoubleMode (Logging is incidental to this test.) +$logger = Double::for(LoggerInterface::class); +``` + ### Runtime Requirements diff --git a/src/phpstan/src/Rules/Testing/RequireExplicitDoubleModeRule.php b/src/phpstan/src/Rules/Testing/RequireExplicitDoubleModeRule.php new file mode 100644 index 0000000000..86d4a1ae28 --- /dev/null +++ b/src/phpstan/src/Rules/Testing/RequireExplicitDoubleModeRule.php @@ -0,0 +1,261 @@ + + */ +class RequireExplicitDoubleModeRule implements Rule +{ + /** + * Get the node type handled by the rule. + */ + public function getNodeType(): string + { + return FileNode::class; + } + + /** + * Report doubles that can be used without choosing a mode. + */ + public function processNode(Node $node, Scope $scope): array + { + $finder = new NodeFinder; + $nodes = $node->getNodes(); + $pending = []; + + $calls = $finder->find($nodes, static fn (Node $node): bool => $node instanceof StaticCall || $node instanceof MethodCall || $node instanceof NullsafeMethodCall); + foreach ($calls as $call) { + if ($call instanceof StaticCall && $call->class instanceof Name && $call->class->toLowerString() === strtolower(Double::class) + && $call->name instanceof Identifier && $call->name->toLowerString() === 'for' + && ! $call->isFirstClassCallable()) { + $pending[spl_object_id($call)] = $call; + } + } + + if ($pending === []) { + return []; + } + + foreach ($calls as $call) { + if (($call instanceof MethodCall || $call instanceof NullsafeMethodCall) && $this->isModeCall($call)) { + foreach ($this->pendingFactories($call->var, $pending) as $factory) { + unset($pending[spl_object_id($factory)]); + } + } + } + + if ($pending !== []) { + $this->checkAssignments($nodes, $pending, $finder); + $blocks = $finder->find($nodes, static fn (Node $node): bool => property_exists($node, 'stmts')); + foreach ($blocks as $block) { + $this->checkAssignments($block->stmts ?? [], $pending, $finder); + if ($pending === []) { + break; + } + } + } + + $errors = []; + foreach ($pending as $factory) { + $errors[] = RuleErrorBuilder::message('Choose strict() or passthru() before using this double.') + ->identifier('hypervel.implicitDoubleMode') + ->tip('For an intentionally lenient double, use @phpstan-ignore hypervel.implicitDoubleMode (reason).') + ->line($factory->getStartLine()) + ->build(); + } + + return $errors; + } + + /** + * Find bare factories whose result becomes the value of this expression. + * + * @param array $pending + * @return list + */ + private function pendingFactories(Expr $value, array $pending): array + { + if ($value instanceof Ternary) { + return [...$this->pendingFactories($value->if ?? $value->cond, $pending), ...$this->pendingFactories($value->else, $pending)]; + } + + if ($value instanceof Match_) { + $factories = []; + foreach ($value->arms as $arm) { + array_push($factories, ...$this->pendingFactories($arm->body, $pending)); + } + return $factories; + } + + $id = spl_object_id($value); + return isset($pending[$id]) ? [$pending[$id]] : []; + } + + /** + * Check split setup only within the statement list that created the double. + * + * @param Node[] $statements + * @param array $pending + */ + private function checkAssignments(array $statements, array &$pending, NodeFinder $finder): void + { + foreach ($statements as $index => $statement) { + if (! $statement instanceof Expression || ! $statement->expr instanceof Assign) { + continue; + } + + $factories = $this->pendingFactories($statement->expr->expr, $pending); + if ($factories === [] || ($key = $this->binding($statement->expr->var)) === null) { + continue; + } + + if ($this->selectsModeBeforeUse($statements, $index + 1, $key, $finder)) { + foreach ($factories as $factory) { + unset($pending[spl_object_id($factory)]); + } + } + } + } + + /** + * Allow expectation setup and unrelated statements before the first use. + * + * @param Node[] $statements + */ + private function selectsModeBeforeUse(array $statements, int $next, string $key, NodeFinder $finder): bool + { + $mentionsBinding = fn (Node $node): bool => $this->binding($node) === $key; + + for (; isset($statements[$next]); ++$next) { + $statement = $statements[$next]; + $mentions = $finder->find($statement, $mentionsBinding); + if ($mentions === []) { + continue; + } + + $value = $statement instanceof Expression || $statement instanceof Return_ ? $statement->expr : null; + $call = $value; + while (($call instanceof MethodCall || $call instanceof NullsafeMethodCall) && $call->var !== $mentions[0]) { + $call = $call->var; + } + if ((! $call instanceof MethodCall && ! $call instanceof NullsafeMethodCall) || $call->isFirstClassCallable()) { + // A nullsafe call can skip the rest of its chain, including its arguments. + return count($mentions) === 1 + && $value !== null + && $this->evaluatesModeCall($value, $mentions[0]) + && $finder->findFirst($value, static fn (Node $node): bool => $node instanceof NullsafeMethodCall || $node instanceof NullsafePropertyFetch) === null; + } + if ($this->isModeCall($call)) { + // The arguments to passthru() run before it changes the mode. + return $finder->findFirst($call->args, $mentionsBinding) === null; + } + if (count($mentions) !== 1 || ! $call->name instanceof Identifier || ! in_array($call->name->toLowerString(), ['allows', 'expects'], true)) { + return false; + } + } + + return false; + } + + /** + * Determine whether evaluating the expression always selects the binding's mode. + */ + private function evaluatesModeCall(Expr $value, Node $binding): bool + { + if ($value instanceof Assign) { + return $this->evaluatesModeCall($value->expr, $binding); + } + if ($value instanceof Array_) { + return array_any($value->items, fn (ArrayItem $item): bool => $this->evaluatesModeCall($item->value, $binding)); + } + if (! $value instanceof CallLike || $value->isFirstClassCallable()) { + return false; + } + + if ($value instanceof MethodCall) { + if ($value->var === $binding && $this->isModeCall($value)) { + return true; + } + if ($this->evaluatesModeCall($value->var, $binding)) { + return true; + } + } + + return array_any($value->getArgs(), fn (Arg $arg): bool => $this->evaluatesModeCall($arg->value, $binding)); + } + + /** + * Determine whether the method selects a mode on its receiver. + */ + private function isModeCall(MethodCall|NullsafeMethodCall $call): bool + { + return $call->name instanceof Identifier + && in_array($call->name->toLowerString(), ['strict', 'passthru'], true) + && ! $call->isFirstClassCallable(); + } + + /** + * Identify a local variable or a property on the test itself. + */ + private function binding(Node $node): ?string + { + if ($node instanceof Variable && is_string($node->name)) { + return '$' . $node->name; + } + + if ($node instanceof PropertyFetch && $node->var instanceof Variable && $node->var->name === 'this' && $node->name instanceof Identifier) { + return '$this->' . $node->name->name; + } + + if ($node instanceof StaticPropertyFetch && $node->class instanceof Name && $node->name instanceof Identifier + && in_array($node->class->toLowerString(), ['self', 'static'], true)) { + return $node->class->toLowerString() . '::$' . $node->name->name; + } + + return null; + } +} diff --git a/tests/Auth/AuthEloquentUserProviderCacheTest.php b/tests/Auth/AuthEloquentUserProviderCacheTest.php index 99cefb5a85..4598e59527 100644 --- a/tests/Auth/AuthEloquentUserProviderCacheTest.php +++ b/tests/Auth/AuthEloquentUserProviderCacheTest.php @@ -60,7 +60,7 @@ protected function setUp(): void $container = Container::setInstance(new Container); $this->cacheManager = Double::for(CacheManager::class)->strict(); - // Cache tests ignore store validation unless they explicitly check it. + // @phpstan-ignore hypervel.implicitDoubleMode (Cache tests ignore store validation unless they explicitly check it.) $this->storeValidator = Double::for(ModelCacheStoreValidator::class); $this->cacheCoordinator = Double::for(ModelCacheCoordinator::class)->strict(); $container->instance('cache', $this->cacheManager); diff --git a/tests/Integration/Ai/Database/ConversationConcurrencyTestCase.php b/tests/Integration/Ai/Database/ConversationConcurrencyTest.php similarity index 97% rename from tests/Integration/Ai/Database/ConversationConcurrencyTestCase.php rename to tests/Integration/Ai/Database/ConversationConcurrencyTest.php index 04e500f889..ee4e7fd177 100644 --- a/tests/Integration/Ai/Database/ConversationConcurrencyTestCase.php +++ b/tests/Integration/Ai/Database/ConversationConcurrencyTest.php @@ -21,13 +21,15 @@ use Hypervel\Engine\Channel; use Hypervel\Foundation\Testing\DatabaseTruncation; use Hypervel\Support\Facades\DB; +use Hypervel\Testbench\Attributes\RequiresDatabase; use Hypervel\Tests\Ai\TestCase; use JMac\Testing\Double; use JMac\Testing\Integrations\PHPUnit\VerifiesDoubles; use function Hypervel\Coroutine\parallel; -abstract class ConversationConcurrencyTestCase extends TestCase +#[RequiresDatabase(['mysql', 'mariadb', 'pgsql'])] +class ConversationConcurrencyTest extends TestCase { use DatabaseTruncation; use VerifiesDoubles; diff --git a/tests/Integration/Ai/Database/ConversationStorageTestCase.php b/tests/Integration/Ai/Database/ConversationStorageTest.php similarity index 95% rename from tests/Integration/Ai/Database/ConversationStorageTestCase.php rename to tests/Integration/Ai/Database/ConversationStorageTest.php index c92c27a85d..948517e57e 100644 --- a/tests/Integration/Ai/Database/ConversationStorageTestCase.php +++ b/tests/Integration/Ai/Database/ConversationStorageTest.php @@ -21,11 +21,13 @@ use Hypervel\Contracts\Foundation\Application; use Hypervel\Foundation\Testing\RefreshDatabase; use Hypervel\Support\Str; +use Hypervel\Testbench\Attributes\RequiresDatabase; use Hypervel\Tests\Ai\TestCase; use JMac\Testing\Double; use JMac\Testing\Integrations\PHPUnit\VerifiesDoubles; -abstract class ConversationStorageTestCase extends TestCase +#[RequiresDatabase(['mysql', 'mariadb', 'pgsql'])] +class ConversationStorageTest extends TestCase { use RefreshDatabase; use VerifiesDoubles; diff --git a/tests/Integration/Ai/Database/MariaDb/ConversationConcurrencyTest.php b/tests/Integration/Ai/Database/MariaDb/ConversationConcurrencyTest.php deleted file mode 100644 index 1afbb30ca5..0000000000 --- a/tests/Integration/Ai/Database/MariaDb/ConversationConcurrencyTest.php +++ /dev/null @@ -1,13 +0,0 @@ -=8.0')] -class NestedSetSchemaTest extends BaseNestedSetSchemaTest -{ -} diff --git a/tests/Integration/NestedSet/Database/MariaDb/NestedSetSchemaTest.php b/tests/Integration/NestedSet/Database/NestedSetSchemaTest.php similarity index 67% rename from tests/Integration/NestedSet/Database/MariaDb/NestedSetSchemaTest.php rename to tests/Integration/NestedSet/Database/NestedSetSchemaTest.php index c40c65fe96..a12f6062a3 100644 --- a/tests/Integration/NestedSet/Database/MariaDb/NestedSetSchemaTest.php +++ b/tests/Integration/NestedSet/Database/NestedSetSchemaTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\NestedSet\Database\MariaDb; +namespace Hypervel\Tests\Integration\NestedSet\Database; use Hypervel\Testbench\Attributes\RequiresDatabase; use Hypervel\Tests\NestedSet\NestedSetSchemaTest as BaseNestedSetSchemaTest; -#[RequiresDatabase('mariadb')] +#[RequiresDatabase(['mysql', 'mariadb', 'pgsql'])] class NestedSetSchemaTest extends BaseNestedSetSchemaTest { } diff --git a/tests/Integration/NestedSet/Database/MariaDb/NodeTest.php b/tests/Integration/NestedSet/Database/NodeTest.php similarity index 64% rename from tests/Integration/NestedSet/Database/MariaDb/NodeTest.php rename to tests/Integration/NestedSet/Database/NodeTest.php index c194c20472..56fcbf3a6e 100644 --- a/tests/Integration/NestedSet/Database/MariaDb/NodeTest.php +++ b/tests/Integration/NestedSet/Database/NodeTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\NestedSet\Database\MariaDb; +namespace Hypervel\Tests\Integration\NestedSet\Database; use Hypervel\Testbench\Attributes\RequiresDatabase; use Hypervel\Tests\NestedSet\NodeTest as BaseNodeTest; -#[RequiresDatabase('mariadb')] +#[RequiresDatabase(['mariadb', 'pgsql'])] class NodeTest extends BaseNodeTest { } diff --git a/tests/Integration/NestedSet/Database/Postgres/NodeUuidTest.php b/tests/Integration/NestedSet/Database/NodeUuidTest.php similarity index 66% rename from tests/Integration/NestedSet/Database/Postgres/NodeUuidTest.php rename to tests/Integration/NestedSet/Database/NodeUuidTest.php index e4a48c7aba..c3bf12e5a1 100644 --- a/tests/Integration/NestedSet/Database/Postgres/NodeUuidTest.php +++ b/tests/Integration/NestedSet/Database/NodeUuidTest.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace Hypervel\Tests\Integration\NestedSet\Database\Postgres; +namespace Hypervel\Tests\Integration\NestedSet\Database; use Hypervel\Testbench\Attributes\RequiresDatabase; use Hypervel\Tests\NestedSet\NodeUuidTest as BaseNodeUuidTest; -#[RequiresDatabase('pgsql')] +#[RequiresDatabase(['mariadb', 'pgsql'])] class NodeUuidTest extends BaseNodeUuidTest { } diff --git a/tests/Integration/NestedSet/Database/Postgres/NestedSetSchemaTest.php b/tests/Integration/NestedSet/Database/Postgres/NestedSetSchemaTest.php deleted file mode 100644 index 75b9e37383..0000000000 --- a/tests/Integration/NestedSet/Database/Postgres/NestedSetSchemaTest.php +++ /dev/null @@ -1,13 +0,0 @@ -create(); - $rows = []; - - for ($index = 0; $index < 65_538; ++$index) { - $rows[] = ['id' => sprintf('token-%05d', $index), 'client_id' => $client->id, 'revoked' => false]; - - if (count($rows) === 1000 || $index === 65_537) { - Token::query()->insert($rows); - $rows = []; - } - } - - $this->assertFalse(DB::connection()->getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES)); - $invalidated = []; - $affected = $this->app->make(ModelCacheCoordinator::class)->mutate( - $client->tokens()->orderBy('id')->offset(65_536)->getQuery(), - static fn (Builder $query): int => $query->delete(), - static function (array $ids) use (&$invalidated): void { - $invalidated = array_merge($invalidated, $ids); - }, - ); - - $this->assertSame(2, $affected); - $this->assertSame(['token-65536', 'token-65537'], $invalidated); - $this->assertSame(65_536, $client->tokens()->count()); - } -} diff --git a/tests/Integration/Passport/Database/MySql/TokenPersistenceTest.php b/tests/Integration/Passport/Database/MySql/TokenPersistenceTest.php deleted file mode 100644 index b6c6a72912..0000000000 --- a/tests/Integration/Passport/Database/MySql/TokenPersistenceTest.php +++ /dev/null @@ -1,13 +0,0 @@ -loadMigrationsFrom(dirname(__DIR__, 4) . '/src/passport/database/migrations'); } + #[RequiresDatabase('mysql')] + public function testCachedMutationOffsetsDoNotBecomeOversizedBindingLists(): void + { + $client = Client::factory()->create(); + $rows = []; + + for ($index = 0; $index < 65_538; ++$index) { + $rows[] = ['id' => sprintf('token-%05d', $index), 'client_id' => $client->id, 'revoked' => false]; + + if (count($rows) === 1000 || $index === 65_537) { + Token::query()->insert($rows); + $rows = []; + } + } + + $this->assertFalse(DB::connection()->getPdo()->getAttribute(PDO::ATTR_EMULATE_PREPARES)); + $invalidated = []; + $affected = $this->app->make(ModelCacheCoordinator::class)->mutate( + $client->tokens()->orderBy('id')->offset(65_536)->getQuery(), + static fn (Builder $query): int => $query->delete(), + static function (array $ids) use (&$invalidated): void { + $invalidated = array_merge($invalidated, $ids); + }, + ); + + $this->assertSame(2, $affected); + $this->assertSame(['token-65536', 'token-65537'], $invalidated); + $this->assertSame(65_536, $client->tokens()->count()); + } + #[TestWith(['users'])] #[TestWith(['staff'])] public function testPersonalAccessSelectionFiltersGrantAndProviderBeforeCheckingClientAccess(string $provider): void diff --git a/tests/Integration/Passport/Database/Postgres/GrantConcurrencyTest.php b/tests/Integration/Passport/Database/Postgres/GrantConcurrencyTest.php deleted file mode 100644 index 2fff5284fc..0000000000 --- a/tests/Integration/Passport/Database/Postgres/GrantConcurrencyTest.php +++ /dev/null @@ -1,13 +0,0 @@ -assertSame('varchar', Schema::getColumnType('sessions', 'auth_provider')); } + #[RequiresDatabase('pgsql')] + public function testSessionSchemaUsesTheNativeIpAddressType(): void + { + $this->assertSame('inet', Schema::getColumnType('sessions', 'ip_address')); + } + public function testUserIndexUsesAvailableSparseIndexSupport(): void { $index = array_find( diff --git a/tests/Integration/Session/Database/MariaDb/DatabaseSessionHandlerTest.php b/tests/Integration/Session/Database/MariaDb/DatabaseSessionHandlerTest.php deleted file mode 100644 index 718bf234b3..0000000000 --- a/tests/Integration/Session/Database/MariaDb/DatabaseSessionHandlerTest.php +++ /dev/null @@ -1,15 +0,0 @@ -assertSame('inet', Schema::getColumnType('sessions', 'ip_address')); - } -} diff --git a/tests/Integration/Session/Database/Sqlite/DatabaseSessionHandlerTest.php b/tests/Integration/Session/Database/Sqlite/DatabaseSessionHandlerTest.php deleted file mode 100644 index bbf82c53bb..0000000000 --- a/tests/Integration/Session/Database/Sqlite/DatabaseSessionHandlerTest.php +++ /dev/null @@ -1,15 +0,0 @@ - */ +class RequireExplicitDoubleModeRuleTest extends RuleTestCase +{ + /** + * Create the test-only Double rule. + */ + protected function getRule(): Rule + { + return new RequireExplicitDoubleModeRule; + } + + public function testRule(): void + { + $this->analyse([__DIR__ . '/data/explicit-double-mode.php'], array_map( + static fn (int $line): array => [ + 'Choose strict() or passthru() before using this double.', + $line, + 'For an intentionally lenient double, use @phpstan-ignore hypervel.implicitDoubleMode (reason).', + ], + [22, 40, 44, 49, 53, 56, 59, 61, 65, 88, 91, 94], + )); + } +} diff --git a/tests/PHPStan/Rules/Testing/data/explicit-double-mode.php b/tests/PHPStan/Rules/Testing/data/explicit-double-mode.php new file mode 100644 index 0000000000..45200305a4 --- /dev/null +++ b/tests/PHPStan/Rules/Testing/data/explicit-double-mode.php @@ -0,0 +1,110 @@ +strict(); + $this->exercise(TestDouble::for(Repository::class)->passthru()); + $this->exercise(TestDouble::for(Repository::class)); + $factory = TestDouble::for(...); + Sleep::for(0); + ($useCache ? TestDouble::for(Repository::class) : TestDouble::for(Repository::class))->strict(); + TestDouble::for(Repository::class, override: true)->strict()->instance(); + + $this->repository = TestDouble::for(Repository::class); + self::$cache = TestDouble::for(Repository::class); + $this->repository->allows('get')->returns(null); + self::$cache->passthru(); + $this->repository->strict(); + + if ($useCache) { + $double = $useCache ? TestDouble::for(Repository::class) : TestDouble::for(Repository::class); + $double->expects('get')->returns('value'); + $double->strict(); + } + + $used = TestDouble::for(Repository::class); + $this->exercise($used); + $used->strict(); + + $conditional = TestDouble::for(Repository::class); + if ($useCache) { + $conditional->strict(); + } + + $replaced = TestDouble::for(Repository::class); + $replaced = TestDouble::for(Repository::class); + $replaced->strict(); + + $callable = TestDouble::for(Repository::class); + $callable->strict(...); + + $this->repository = TestDouble::for(Repository::class); + self::$cache->strict(); + + TestDouble::for(Repository::class)->strict()->allows('get')->returns(TestDouble::for(Repository::class)); + + $late = TestDouble::for(Repository::class); + $late->allows('get')->returns($late->get('fallback')); + $late->strict(); + + $deferred = fn () => \JMac\Testing\Double::for(Repository::class); + $deferred()->strict(); + } + + public function configuredFactory(bool $useCache): Repository + { + $double = match ($useCache) { + true => TestDouble::for(Repository::class), + false => TestDouble::for(Repository::class), + }; + + return $double->strict(); + } + + public function modeInArguments(bool $useCache, ?self $optional): void + { + $repository = TestDouble::for(Repository::class); + $repository->expects('get'); + $this->exercise($repository->strict()); + + $forConstructor = TestDouble::for(Repository::class); + $iterator = new ArrayIterator($forConstructor->passthru()); + + $conditional = TestDouble::for(Repository::class); + $useCache && $conditional->strict(); + + $alreadyUsed = TestDouble::for(Repository::class); + $this->exercise($alreadyUsed->get('key'), $alreadyUsed->strict()); + + $skipped = TestDouble::for(Repository::class); + $optional?->exercise($skipped->strict()); + } + + /** @return list */ + public function repositories(): array + { + $repository = TestDouble::for(Repository::class); + $repository->expects('get'); + + return [$repository->strict()]; + } + + public function exercise(mixed ...$values): void + { + } +} diff --git a/tests/Testbench/HelpersTest.php b/tests/Testbench/HelpersTest.php index bebcfd1299..002f33db91 100644 --- a/tests/Testbench/HelpersTest.php +++ b/tests/Testbench/HelpersTest.php @@ -106,19 +106,20 @@ public function itCanEvaluateProvidedPackageVersion(): void $this->assertTrue(package_version_compare('hypervel/support', $version)); $this->assertTrue(package_version_compare('hypervel/support', $version, '=')); - $this->assertTrue(package_version_compare('hypervel/support', $version, '<=')); - $this->assertTrue(package_version_compare('hypervel/support', $version, '>=')); - $this->assertFalse(package_version_compare('hypervel/support', $version, '<')); - $this->assertFalse(package_version_compare('hypervel/support', $version, '>')); + $this->assertTrue(package_version_compare('psr/clock-implementation', '1.0', '<=')); + $this->assertTrue(package_version_compare('psr/clock-implementation', '1.0', '>=')); - $this->assertTrue(package_version_compare('hypervel/support', $version, 'eq')); - $this->assertTrue(package_version_compare('hypervel/support', $version, 'le')); - $this->assertTrue(package_version_compare('hypervel/support', $version, 'ge')); + $this->assertFalse(package_version_compare('psr/clock-implementation', '1.0', '<')); + $this->assertFalse(package_version_compare('psr/clock-implementation', '1.0', '>')); - $this->assertFalse(package_version_compare('hypervel/support', $version, 'lt')); - $this->assertFalse(package_version_compare('hypervel/support', $version, 'gt')); - $this->assertFalse(package_version_compare('hypervel/support', $version, 'ne')); + $this->assertTrue(package_version_compare('psr/clock-implementation', '1.0', 'eq')); + $this->assertTrue(package_version_compare('psr/clock-implementation', '1.0', 'le')); + $this->assertTrue(package_version_compare('psr/clock-implementation', '1.0', 'ge')); + + $this->assertFalse(package_version_compare('psr/clock-implementation', '1.0', 'lt')); + $this->assertFalse(package_version_compare('psr/clock-implementation', '1.0', 'gt')); + $this->assertFalse(package_version_compare('psr/clock-implementation', '1.0', 'ne')); $this->assertTrue(package_version_compare('psr/http-message-implementation', '1.0', '>=')); $this->assertTrue(package_version_compare('psr/http-message-implementation', '1.0', 'ge')); diff --git a/tests/Tinker/TinkerCasterTest.php b/tests/Tinker/TinkerCasterTest.php index f7b9a0b002..c651b91697 100644 --- a/tests/Tinker/TinkerCasterTest.php +++ b/tests/Tinker/TinkerCasterTest.php @@ -27,7 +27,7 @@ public function testCanCastCollection(): void public function testApplicationPropertyErrorsDoNotSuppressLaterValues(): void { - // The caster also reads application properties unrelated to this failure. + // @phpstan-ignore hypervel.implicitDoubleMode (The caster also reads application properties unrelated to this failure.) $application = Double::for(Application::class, override: true); $application->expects('configurationIsCached')->throws(new Error('Unavailable')); $application->expects('version')->returns('1.0.0');