Skip to content

test: raise the coverage to 90.7 % - #12

Open
ogorzalka wants to merge 2 commits into
mainfrom
cov/cli
Open

ogorzalka wants to merge 2 commits into
mainfrom
cov/cli

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Raises the coverage of the package from 40.5 % to 90.7 % (measured locally with PHP 8.4 and pcov; the recorded ratchet was 36.86), with tests only (src/ is untouched).

56 tests (57 to 113) in five new files: the install flow of NewCommand, SelfUpdateCommand, the prompts configuration, ProjectProxy and the version lookup. There is no network call: tests/Support/Sandbox.php puts fake composer, ddev, php and git first in the PATH of a temporary folder, and HTTPS_PROXY points to a closed local port, so Packagist always fails the same way; tests/Support/FileOverlay.php lets Version read an in-memory composer.lock or composer.json (it replaces the file stream wrapper for the duration of a test and each test that uses it calls uninstall() in afterEach). Mockery is not installed, so Prompt::fake() cannot be used: the prompts go through their fallbacks, with a stream set on the input.

Not covered: UpdateChecker (65.4 %) and SelfUpdateCommand (62 %) run their remaining lines only with a successful HTTPS answer from Packagist, and new Client is hard-coded in src/, so it cannot be replaced; a fake HTTPS server would need a certificate authority that Guzzle accepts, which depends on the machine and on the CI. A few isolated lines remain in NewCommand (Windows branches, a failed file read), RunsCommands and ProxyCommand.

Existing test not changed: UpdateCheckerTest ("does not crash when notifying") makes a real network call and writes to the real ~/.pollora/update-check.json.

The ratchet in .harness.json is not changed in this pull request: the figure measured locally before any test (40.5 %) is above the recorded one (36.86), so the CI and the local measure differ for this package. It will be set to the value the CI measures, in a follow-up. 113 tests pass in random orders; Pint, PHPStan, Rector (--dry-run), tests/Arch.php and the type coverage (100 %, threshold 98) are clean.

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.

1 participant