Skip to content

Polish code and add github actions for running tests - #19

Merged
duxthefux merged 15 commits into
masterfrom
worktree-mop-review-the-repo-and-sugg-2c82
Nov 9, 2026
Merged

duxthefux merged 15 commits into
masterfrom
worktree-mop-review-the-repo-and-sugg-2c82

Conversation

@duxthefux

Copy link
Copy Markdown
Contributor

No description provided.

* Per-method timeout now defaults to null so setTimeout() applies
* Catch all Guzzle bad responses (4xx and 5xx), not only 4xx
* Added ConnectionException for network failures
* Error messages include method, path and response body
* Guzzle client can be injected via the constructor
* Added ClientUnitTest using Guzzle MockHandler
* Live tests are skipped when no token or endpoint is set
* Split phpunit.xml into unit and api suites
* Clean up created data in ProductsTest with finally
* Made data providers static, removed brittle assertions
* Updated Guzzle, PHPUnit, php-cs-fixer, phpdotenv, var-dumper
* Added phpstan and composer scripts for test, lint and analyse
* Added ext-mbstring requirement and keywords
* Moved test namespace to autoload-dev
* Cache file of php-cs-fixer stays in the project
* Runs composer validate, php-cs-fixer, phpstan and unit tests
* PHP 8.3 and 8.4
* Documented ConnectionException
* Documented live API tests and the endpoint they use
* New live-api job runs composer test:api with R2O_API_TOKEN secret and R2O_API_ENDPOINT variable
* Skipped for fork PRs, runs are serialized to avoid clashes on the test account
* Added workflow_dispatch trigger
* Tests read env vars via getenv() as well, since $_ENV is empty in CI
Comment thread .github/workflows/ci.yml Resolved
Comment thread src/Client.php Resolved
Comment thread src/Client.php Resolved
Comment thread composer.json Resolved
Comment thread src/Exceptions/ConnectionException.php Resolved
* New php74 job lints src on PHP 7.4
* Installs the library into a throwaway project like a consumer would, since require-dev (PHPUnit 12) cannot resolve on 7.4
* Runs a smoke test that makes a mocked request through Client
* live-api needs checks, so a commit failing lint or phpstan never touches the test account
* Catch TransferException so timeouts, connection resets and redirect loops become ConnectionException, not raw Guzzle exceptions
* Static default headers (User-Agent, Accept, Cache-Control) live on the default Guzzle client, so an injected client keeps its own
* Added Ready2OrderException as common base class of all library exceptions
* Added unit tests for each case, documented in README
* Error messages fall back to status and body when the JSON has no msg, array msg is JSON-encoded
* Force http_errors per request so an injected client cannot turn error responses into successes
* Normalized slashes when joining endpoint and path
* Narrowed Ready2OrderException docs, added Upgrading and Development notes to README
* Added unit tests for verbs, URL join, default headers, error fallbacks and truncation
* Registered AccountTest in the api suite
* Live job runs with --fail-on-skipped so a missing secret fails instead of skipping
* Added Guzzle 7.16 unit test job and job timeouts
* Made ProductsTest cleanup per-resource, language test compares localized messages
* Added .gitattributes to keep dev files out of dist archives
* URL join uses preg_replace, as php-cs-fixer rewrote rtrim/ltrim to mb_rtrim/mb_ltrim on PHP 8.4, which do not exist on 7.4
* testFluentInterfaceChaining requests products instead of company, which regular tokens cannot read
* It requests the company endpoint, which regular tokens cannot read
* POST, PUT, PATCH and DELETE use RequestOptions::JSON, matching the documented JSON API
* Unit test asserts JSON body and Content-Type, README Upgrading notes the change
@ready2order ready2order deleted a comment from r2omvavra Nov 9, 2026
@duxthefux
duxthefux merged commit e00aa0b into master Nov 9, 2026
5 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