Skip to content

Tests - #88

Merged
argo22-pavel-rampas merged 23 commits into
masterfrom
tests
Nov 18, 2026
Merged

argo22-pavel-rampas merged 23 commits into
masterfrom
tests

Conversation

@argo22-pavel-rampas

Copy link
Copy Markdown
Contributor

Testy

  • Testy rozdělené na dvě sady: unit (offline) a integration (proti sandboxu GoPay). Třídy se načítají přes PSR-4 místo require_once.
  • Nové unit testy pro GoPay, Config, OAuth2, CachedOAuth, Payments (všechny endpointy), payments() factory a kódování JSON se speciálními znaky. Síť nahrazuje testovací RecordingBrowser.
  • Integrační testy kontrolují víc: status kód, název chyby a obsah odpovědi. Jeden test (testNextOnDemandEET) dřív procházel i při chybě API.
  • Opravené rozbité testy. Test výpisu z účtu počítá s minulým měsícem místo pevného data. Testy, které se sandboxem už nefungují, se hlásí jako přeskočené.
  • Ladicí výpisy se zobrazí jen s proměnnou GOPAY_TEST_DEBUG. Test, který vypisuje na stdout, shodí běh.
  • Z testu kódování znaků jsou odstraněné údaje o zákazníkovi.

CI (GitHub Actions)

  • Nový job security-audit spouští composer audit --locked nad zamčenými závislostmi.
  • Unit testy běží na Ubuntu s PHP 8.1–8.5 a na Windows a macOS s PHP 8.1, celkem 7 jobů místo 12. Přibylo PHP 8.5.
  • Integrační testy běží jen jednou, v samostatném jobu. Ten zároveň měří pokrytí kódu (pcov) a ukládá report jako artefakt coverage.
  • PHPUnit běží s phpunit.xml.dist, takže deprecations, notices, warnings a risky testy shodí build.
  • actions/checkout povýšen z v6 na v7.

Závislosti (jen vývojové a composer.lock)

  • PHPUnit povýšen z 9.6 na 10.5 a phpunit.xml.dist převedený na nový formát. Verze 11 by vyžadovala PHP 8.2.
  • Patch a minor aktualizace PHPStanu, PHP-CS-Fixeru a CaptainHooku.
  • V composer.lock aktualizovaný Guzzle (7.7.0 → 7.16.1) a PSR-7 kvůli 13 bezpečnostním advisories. Minimum v composer.json se nemění, aktualizace Guzzlu zůstává na uživatelích SDK.
  • Odebrané nepoužívané závislosti phpspec/prophecy, phpspec/prophecy-phpunit, hamcrest/hamcrest-php a zastaralý composer.bak.
  • Nové Composer skripty test, test:unit, test:integration, test:coverage.

argo22-pavel-rampas and others added 22 commits November 12, 2026 15:02
Neither tests nor sources use Prophecy, the only mock is a native
PHPUnit mock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hardcoded 2026 range would go stale, the test now asks for
the previous calendar month. assertNotEmpty($response) was always
true for an object, the test now checks status code and body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test documentation named a merchant and its ID and the payload
used the merchant URL. Replaced by a generic description and
example.com.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- remove unused GivenGoPay helper (it was loaded by autoload-dev
  but no test extended it)
- report disabled tests as skipped instead of commenting them out
  (CardTokenTest) or misnaming them (tEETPaymentRefund)
- fix doc comments that referred to other payment IDs than the
  tests use, remove unused variable and redundant block
- cover empty array in addition to null in empty data test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CI ran PHPUnit with --no-configuration, so PHPUnit 9 defaults applied
and deprecations never failed the PHP version matrix. PHPUnit 9 can
convert deprecations to exceptions only in the XML configuration.

The configuration was invalid (syntaxCheck attribute, non-existent
tests/unit suite, env variables only used by the removed GivenGoPay).
It now validates against the schema and enables
convertDeprecationsToExceptions, failOnWarning and failOnRisky.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
UnicodeEncodingTest does not touch the network, it moves to
tests/unit. Test classes get their own namespaces and are autoloaded
via PSR-4, so the require_once calls between test files are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RecordingBrowser replaces JsonBrowser, records sent requests and
returns queued responses, so GoPay, OAuth2, CachedOAuth and Payments
are tested without network:

- URL building with and without /api, headers, Accept-Language,
  custom User-Agent, JSON and FORM body encoding
- config defaults, Config object, fromArray/toArray
- token request, expiration, failed authorization, cache key
- token caching, renewal of expired and failed tokens
- HTTP method, path, content type and body of every endpoint,
  createPayment defaults, OAuth error returned without calling
  the endpoint
- JsonBrowser transport error converted to status 500
- payments() factory and Api::payments()

JsonBrowser creates its Guzzle client internally, HTTP error
responses stay covered by integration tests only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Integration tests call the GoPay sandbox and create real sandbox
payments, running them in all 12 matrix jobs multiplied the load and
the chance of flaky failures. The matrix now runs the offline unit
suite, integration tests run once on Ubuntu with PHP 8.4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hamcrest was used only by the removed GivenGoPay helper, all tests
use PHPUnit asserts. Its functions file is no longer autoloaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The integration job installs pcov and runs both suites with coverage
of src and factory.php. The Clover report is uploaded as the coverage
artifact and the text summary is added to the job summary.

Composer scripts test, test:unit, test:integration and test:coverage
(HTML report in build/coverage/html) run bin/phpunit with the PHP
binary that runs Composer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Backup of composer.lock from 2020 (Guzzle 6), not used by Composer
or referenced anywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Integration tests printed every API response, which buried the
PHPUnit result. Output now goes through TestUtils::debug(), which
prints only when GOPAY_TEST_DEBUG is set:

    GOPAY_TEST_DEBUG=1 composer test:integration

It writes to STDERR, so PHPUnit does not capture it and the new
beStrictAboutOutputDuringTests setting (any stdout output makes the
test risky and fails the run) does not break debug runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tests mostly checked that the response body is not empty and has no
errors key, so they passed e.g. on an error response without that
key or with an unexpected status code. testNextOnDemandEET passed
even though the API returned PAYMENT_RECURRENCE_STOPPED.

IntegrationTestCase provides the client and assertions:

- assertSucceeded(): success, status code, JSON body without errors
- assertApiError(): status code, error name and code
- assertStatusCode(): numeric string on success, int on error
- assertPaymentCreated(): CREATED payment matching the sent amount,
  currency, order number, payment instruments and language, target
  defaulted to the goid from the SDK config, sandbox gateway URL

Endpoint specific checks: recurrence and preauthorization in the
response, card details, payment instruments, refund history items,
CSV account statement, EET receipts matching the filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- fix hasSucceed() and statusCode description
- remove link to the removed GivenGoPay test helper
- mention Guzzle as a required dependency
- add Development section
- formatting fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Require guzzlehttp/guzzle ^7.16.1 and update guzzlehttp/* in composer.lock,
so that composer audit reports no known vulnerabilities.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Run unit tests on Ubuntu with PHP 8.1-8.5 and on Windows and macOS
only with PHP 8.1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Migrate phpunit.xml.dist: convertDeprecationsToExceptions is replaced by
failOnDeprecation/failOnNotice, <coverage> filter moved to <source> and
the result cache goes to .phpunit.cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep the minimum Guzzle version for compatibility, updating Guzzle is
left to SDK users. composer.lock stays on Guzzle 7.16.1, so the CI
security audit still passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rattkin rattkin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR odpovídá popisu a CI prochází. Vydání PR nepotřebuje, protože se chování SDK nemění.

Comment thread README.md Resolved
…LAUDE.md

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@argo22-pavel-rampas
argo22-pavel-rampas merged commit c061150 into master Nov 18, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants