Skip to content

Test coverage: 46% of lines, 2 of 29 classes fully covered, no end-to-end test #32

Description

@loevgaard

Current state

vendor/bin/phpunit --coverage-text with pcov on PHP 8.4:

Classes:  6.90% (2/29)
Methods: 30.00% (21/70)
Lines:   45.91% (129/281)

Only ConfigurationBasedPixelProvider and SetonoMetaConversionsApiExtension are fully covered. Most subscriber coverage comes from getSubscribedEvents() being called during kernel boot, not from their behaviour being exercised.

The untested code is exactly where the issues from the review live:

Area Missing tests
Context\Fbc\*, Context\Fbp\* cookie parsing (valid, invalid, missing), query override, cache behaviour, no-request behaviour, reset
StoreFbpSubscriber, StoreFbcSubscriber cookie set and renewal after two hours, fbclid presence, consent gate, sub-requests, httpOnly=false
StoreTestEventCodeSubscriber, PopulateTestEventCodePropertySubscriber store, read, clear, no session, no previous session
PopulateRequestPropertiesSubscriber URL, IP and user agent populated; no request
PopulateFbpAndFbcPropertiesSubscriber, PopulatePixelsSubscriber values copied onto the event
FilterBotsSubscriber, FilterEmptyUserAgentSubscriber, StopPropagationIfNoPixelsHasBeenAddedSubscriber stop / do not stop
ConsentChecker disabled → granted; enabled without checker → granted; enabled with checker → delegated with the configured category
SendEventHandler delegates to ClientInterface; behaviour on ClientException
AddEventToTagBagSubscriber, AddLibraryToTagBagSubscriber tags added with the expected priorities and fingerprints, init tag replacement, consent gate, no pixels
Configuration defaults, client_side default depending on tag bag presence, pixels validation, filters.user_agent validation
SetonoMetaConversionsApiExtension::prepend() its behaviour, or its removal
End to end dispatch a ConversionsApiEventRaised through a booted kernel with a request on the stack and assert: (a) a stubbed ClientInterface receives the event with populated request properties, pixels and fbp; (b) with client side enabled the tag bag contains the pixel, init and track tags; (c) a bot user agent results in nothing being sent

Suggested approach

  • Unit tests with plain Request, RequestStack, RequestEvent and ResponseEvent objects are cheap for every subscriber; no kernel needed.
  • One KernelTestCase end-to-end test using Nyholm\BundleTest\TestKernel, a ClientInterface stub registered through a test compiler pass, and Messenger in sync mode. This single test would have caught prepend() replaces the application's default Messenger bus #12.
  • Make the CI coverage job fail below a threshold (Codecov status checks or a simple clover check) so coverage cannot regress silently.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions