Add Behat support#194
Open
hhamon wants to merge 1 commit into
Open
Conversation
627010f to
1d91ba1
Compare
- `BrowserOptions` (readonly value object) — env-var-driven configuration
- `BrowserRegistry` — replaces the static state previously held by `LegacyExtension`
- `KernelBooter` interface + `Test/PhpUnitKernelBooter` (closure-fed, captures the trait's privileged scope)
- `BrowserFactory` — builds `KernelBrowser` / `PantherBrowser` from a booter
- `Artifact/{ArtifactSink, ArtifactCollector, EchoArtifactSink, FailureType}` — the lifecycle/artifact-capture logic extracted out of `LegacyExtension`
- `HasBrowser` trait: now ~95 lines, delegates to `BrowserFactory` with closures granting protected-static access
- `LegacyExtension` / `BootstrappedExtension`: thin adapters forwarding events to `ArtifactCollector`
- `BrowserExtension`: unchanged externally — same `phpunit.xml.dist` snippet works
- `BrowserExtension` — Behat `ServiceContainer` Extension wiring everything
- `Context/{BrowserAware, BrowserAwareTrait}` — drop-in analog of `HasBrowser`
- `Initializer/BrowserContextInitializer` — injects services via Behat's standard DI
- `EventListener/ArtifactListener` — Suite + Scenario events drive `ArtifactCollector`
- `Output/BehatOutputArtifactSink` — STDOUT-direct summary writer
- `Kernel/{KernelBooter implementations}` — `StandaloneKernelBooter` (env-var) and `SymfonyExtensionKernelBooter` (FoB), selected at compile time via class_exists; PantherClientFactory adapter to bypass Panther's protected statics
- `composer.json`: `behat/behat ^3.13|^4.0@dev` added to `require-dev`; both behat and FoB extension listed in suggest
- `tests/Behat/{behat.dist.php, behat.yml.dist, Context/BrowserContext.php, features/browser.feature}` — exercises the bridge end-to-end against the existing fixture kernel
- `README.md`: new "Using with Behat" section with context + config examples
Known caveat documented in the plan: `friends-of-behat/symfony-extension` doesn't yet support Symfony 8, so I could only end-to-end verify the `StandaloneKernelBooter` path. The `SymfonyExtensionKernelBooter` is code-complete and PHPStan-clean, but will need either a downgraded composer profile or a FoB release that supports Symfony 8 to verify in CI. The class is wired conditionally so it doesn't break consumers without FoB installed.
1d91ba1 to
a5617e9
Compare
Author
|
@kbond I've tested this branch on a personal private project and it works :) Edit: I'ven't tested with Panther yet. |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Framework-agnostic core (
src/Browser/)BrowserOptions(readonly value object) — env-var-driven configurationBrowserRegistry— replaces the static state previously held byLegacyExtensionKernelBooterinterface +Test/PhpUnitKernelBooter(closure-fed, captures the trait's privileged scope)BrowserFactory— buildsKernelBrowser/PantherBrowserfrom a booterArtifact/{ArtifactSink, ArtifactCollector, EchoArtifactSink, FailureType}— the lifecycle/artifact-capture logic extracted out ofLegacyExtensionPHPUnit Decoupling
HasBrowsertrait: now ~95 lines, delegates toBrowserFactorywith closures granting protected-static accessLegacyExtension/BootstrappedExtension: thin adapters forwarding events toArtifactCollectorBrowserExtension: unchanged externally — samephpunit.xml.distsnippet worksBehat Bridge
BrowserExtension— BehatServiceContainerExtension wiring everythingContext/{BrowserAware, BrowserAwareTrait}— drop-in analog ofHasBrowserInitializer/BrowserContextInitializer— injects services via Behat's standard DIEventListener/ArtifactListener— Suite + Scenario events driveArtifactCollectorOutput/BehatOutputArtifactSink— STDOUT-direct summary writerKernel/{KernelBooter implementations}—StandaloneKernelBooter(env-var) andSymfonyExtensionKernelBooter(FoB), selected at compile time via class_exists; PantherClientFactory adapter to bypass Panther's protected staticsComposer Update
composer.json:behat/behat ^3.13|^4.0@devadded torequire-dev; both behat and FoB extension listed in suggesttests/Behat/{behat.dist.php, behat.yml.dist, Context/BrowserContext.php, features/browser.feature}— exercises the bridge end-to-end against the existing fixture kernelREADME.md: new "Using with Behat" section with context + config examplesKnown caveat documented in the plan:
friends-of-behat/symfony-extensiondoesn't yet support Symfony 8, so I could only end-to-end verify theStandaloneKernelBooterpath. TheSymfonyExtensionKernelBooteris code-complete and PHPStan-clean, but will need either a downgraded composer profile or a FoB release that supports Symfony 8 to verify in CI. The class is wired conditionally so it doesn't break consumers without FoB installed.Co-Authored with Claude Code