Skip to content

Move the tests into tests/Unit and add missing unit tests - #12

Merged
loevgaard merged 7 commits into
masterfrom
tests/unit-suite
Oct 26, 2026
Merged

loevgaard merged 7 commits into
masterfrom
tests/unit-suite

Conversation

@loevgaard

@loevgaard loevgaard commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

The tests move to tests/Unit, so the functional tests in #13 can go into tests/Functional next to them. This PR also adds unit tests for behaviour that no test asserted yet.

Changes

  • The tests move from tests/ to tests/Unit/, in the Setono\ClientBundle\Tests\Unit namespace, and run as the unit test suite. Apart from the namespace, the only change to a moved test is the package root path in SetonoClientBundleTest.
  • New unit tests:
    • Configuration (new ConfigurationTest): defaults, overrides, and a partial cookie configuration that keeps the other default. It uses matthiasnoback/symfony-config-test, which was already installed through symfony-dependency-injection-test and is now declared.
    • SetonoClientExtension: custom values end up in the container parameters. The two subscribers, the value resolver and the Doctrine listener carry their tags; without those tags the bundle silently does nothing.
    • StoreCookieSubscriber: an existing cookie gets a new last seen timestamp and keeps its first seen timestamp. The configured cookie name and expiration are used.
    • CachedCookieProvider: a missing cookie is cached too, and each request is resolved separately.
    • DoctrineOrmBasedMetadataProvider: nothing is queried before the metadata is used, the decorated provider's metadata is used when the client has no row, and loaded metadata isn't dirty.
    • DoctrineOrmBasedMetadataPersister: lazy metadata that was only read isn't written, and lazy metadata that was changed is.

Testing

  • PHPUnit: 61 tests (49 before), on PHP 8.4 with Symfony 7.4, and with the lowest dependencies on PHP 8.1 with Symfony 6.4 and on PHP 8.2 with Symfony 7.0
  • PHPStan, ECS, composer-dependency-analyser, composer validate --strict and composer normalize --dry-run pass
  • Infection: 76 of 76 mutants killed

Stack

Five PRs that add tests to the bundle and fix what the tests and their review found. Review and merge them in this order. #14, #15 and #20 are independent of each other and all build on #13.

  1. Move the tests into tests/Unit and add missing unit tests #12: move the existing tests into tests/Unit and add the unit tests that were missing
  2. Add functional tests that run the bundle with a database #13: functional tests that run the bundle in a Symfony application with a database
  3. Fix configuring a metadata class that extends the bundle's Metadata #14: fix a custom metadata_class that extends the bundle's Metadata, found by the functional tests
  4. Reset the cached client between requests and key the cookie cache by request #15: reset the cached client between requests in long-running runtimes, and key the cookie cache by request, found by the functional tests
  5. Reject unusable client ids and look up the entity manager lazily #20: reject unusable client ids and look up the entity manager lazily, found in the review of Move the tests into tests/Unit and add missing unit tests #12 and Add functional tests that run the bundle with a database #13

The tests now live in the Setono\ClientBundle\Tests\Unit namespace and run as the Unit test suite, which makes room for a Functional suite next to it.
- Configuration: defaults, overrides and partial cookie configuration
- Extension: custom values become parameters, and the subscribers, value resolver and Doctrine listener are tagged
- StoreCookieSubscriber: the last seen timestamp is refreshed, and the configured cookie name and expiration are used
- CachedCookieProvider: a missing cookie is cached, and each request is resolved separately
- DoctrineOrmBasedMetadataProvider: no query before the metadata is used, the fallback to the decorated provider, and loaded metadata is not dirty
- DoctrineOrmBasedMetadataPersister: lazy metadata that was only read is not written, and lazy metadata that was changed is
Comment thread phpunit.xml.dist Outdated
Comment thread tests/Unit/CookieProvider/CachedCookieProviderTest.php
Comment thread tests/Unit/Context/CachedClientContextTest.php
Comment thread tests/Unit/DependencyInjection/SetonoClientExtensionTest.php
Comment thread tests/Unit/CookieProvider/RequestBasedCookieProviderTest.php
Comment thread tests/Unit/CookieProvider/CachedCookieProviderTest.php
Comment thread tests/Unit/CookieProvider/CachedCookieProviderTest.php Outdated
Comment thread tests/Unit/MetadataPersister/DoctrineOrmBasedMetadataPersisterTest.php Outdated
Comment thread tests/Unit/MetadataProvider/DoctrineOrmBasedMetadataProviderTest.php Outdated
Comment thread tests/Unit/EventSubscriber/StoreCookieSubscriberTest.php Outdated
Comment thread tests/Unit/DependencyInjection/ConfigurationTest.php
Comment thread tests/Unit/MetadataPersister/DoctrineOrmBasedMetadataPersisterTest.php Outdated
Comment thread CLAUDE.md
@loevgaard
loevgaard merged commit d1708f0 into master Oct 26, 2026
18 checks passed
@loevgaard
loevgaard deleted the tests/unit-suite branch October 26, 2026 10:56
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