Commit 1d7695d
authored
test(jsonld,hydra,hal): migrate behat features to ApiTestCase (#7957)
* test(jsonld): migrate trivial behat features to ApiTestCase
Replaces 9 jsonld behat features with ApiTestCase functional tests
backed by isolated static-provider fixtures (no Doctrine entities,
except PropertyCollectionIriOnlyTest which keeps the existing entities
to preserve Link/uriVariables semantics). Covers disable_id_generation,
no_output, getter_setter_renaming, interface_as_resource,
interface_dto_output, max_depth, json_serializable, iri_only and drops
the debug-only inheritance scenarios.
* test(jsonld): migrate context/non-resource and abs/net URL features
Replaces context.feature (entrypoint, resource, embed-relation,
extended jsonldContext), non_resource.feature (genid, sparse fieldsets,
DateTime, plain object, non-resource relation), absolute_url.feature,
network_path.feature and hydra/absolute.feature (paged hydra:view).
Per-operation urlGenerationStrategy replaces the legacy app-level
configuration; new fixtures use static providers and ArrayPaginator.
* test(hydra): migrate entrypoint, error and item_uri_template features
Replaces the entrypoint, error and item_uri_template hydra behat
features with ApiTestCase functional tests. Error scenarios use
ValidationException + BadRequestHttpException via dedicated processors;
item_uri_template covers cars/brands plus the existing issue5662 and
CollectionReferencingItem fixtures registered through SetupClassResources.
* test(hydra): migrate collection, docs and input_output features
Replaces the remaining hydra/jsonld behat features:
* hydra/collection.feature: pagination, filters, partial pagination,
no-prefix mode and cursor pagination (cursor variant uses SoMany).
* hydra/docs.feature: simplified to assert vocabulary, supportedClass,
property/operation surface and deprecations on a dedicated fixture.
* jsonld/input_output.feature: custom input/output DTO, output: false,
input: false, full input/output cycle.
Drops legacy @V3 / messenger / DataTransformer scenarios that no
longer reflect 4.x semantics.
* test(jsonld): close coverage gaps left by behat migration
* abs/network URL tests now run against http://example.com via base_uri
override, matching the original behat host.
* HydraDocsTest exercises the original assertions on a richer fixture:
subClassOf via types, range/maxCardinality on relations, schema:FindAction
type on GET, per-method hydra:title and description, deprecation
propagating from a deprecated resource into the entrypoint.
* InputOutputDtoTest restores the three legacy @V3 collection-DTO scenarios
(genid for resource without id, custom itemUriTemplate, identifier-bearing
resource still falling back to genid when no item operation exists).
* New EntityClassWithDateTimeTest covers JSON-LD on a resource backed by
a Doctrine entity through stateOptions.
* HydraCollectionTest now uses a partial-only paginator implementation,
asserting that hydra:view drops first/last and keeps next/previous.
* RenamedGetterSetterTest restores the exact @id assertion (collection URI
fallback when the resource has no identifier).
* chore(tests): remove fixtures orphaned by jsonld behat migration
EntityWithRenamedGetterAndSetter, EntityWithDtoOutput,
JsonldContextDummy and MaxDepthEagerDummy (entity + document)
were only referenced by the deleted behat features. Other
fixtures touched by the migration (IriOnlyDummy, AbsoluteUrlDummy,
NetworkPathDummy, MaxDepthDummy, ContainNonResource, PlainObjectDummy,
NonRelationResource, DisableIdGeneration) are still referenced from
DoctrineContext, the JSON Schema command test, the jsonapi feature
suite or HAL tests, so they stay.
* chore(tests): fix references orphaned by jsonld behat migration
DtoOutput was defined inside EntityWithDtoOutput.php (deleted in
fbfe043); src/JsonSchema/Tests/DefinitionNameFactoryTest.php still
imports it as a class-string for definition-name generation. Re-adds a
minimal class. Also narrows InterfaceTaxonImpl::getCode() to non-nullable
string (covariant) which phpstan now catches.
* test(jsonld): fix CI failures from behat migration
Two fixes for the JsonLd functional tests added yesterday:
* Consolidate dual #[ApiResource] declarations sharing the same
shortName on AbsoluteUrlChild, NetworkPathResource and UriTemplateCar
into a single attribute with all operations. Avoids the 4.2-deprecated
duplicate-shortName path that was failing the no-deprecation and
Symfony-dev PHPUnit jobs.
* Skip MongoDB-only paths in ItemUriTemplateHydraTest and the
UserResource branch of InputOutputDtoTest where the underlying
fixtures live in the Entity namespace and aren't loaded under the
Document kernel; skip InputOutputDtoTest::testCreateNoInputResource
in event-listener mode where PlaceholderAction cannot resolve $data
for input:false POST.
* test(hal): migrate behat features to ApiTestCase
Replaces the eleven hal behat features with ApiTestCase functional tests
under tests/Functional/Hal, mirroring the jsonld/hydra migration done
yesterday. Most use static-provider fixtures; PropertyCollectionIriOnly
and TableInheritance keep the existing entity fixtures (still referenced
by features/main/table_inheritance.feature). MaxDepthEagerDummy was
already deleted in fbfe043 — this restores coverage for that scenario
under HalMaxDepth.
With features/hal, features/jsonld and features/hydra all gone, the
ld-api-hal-hydra shard reduced to features/jsonapi alone; renames the
shard accordingly.
* cs: enforce yoda style in JsonLd CollectionPagedResource
* chore(tests): move root JSON-LD tests into JsonLd/ subdir
* HydraTest -> JsonLd/HydraHideFromDocsTest (descriptive name reflects what
the single test asserts: hiding hydra:supportedClass and operations)
* LinkedDataPlatformTest -> JsonLd/LinkedDataPlatformTest (LDP is JSON-LD)
* ItemUriTemplateTest -> JsonLd/ItemUriTemplateNotFoundTest (rename
testIssue6718 to testNotFoundOnInvalidItemUriTemplateRelation)
* chore(tests): split monolithic JsonLdTest into per-feature files
Replace the 9-method root JsonLdTest.php with 6 focused JsonLd/* test
files, one per feature:
* InputDtoIriDenormalizationTest (input DTO with IRI relation)
* ContextOutputTest (output DTO @context shape, ignored properties)
* GenIdFalseTest (genId:false at resource and nested levels)
* PolymorphicResourceCollectionTest (per-item @type in collections)
* ItemUriTemplateCollectionTest (itemUriTemplate as @id, with stateOptions)
* MultiResourceContextTest (correct shortName per ApiResource variant)
Each file scopes its setUp/recreateSchema to only the entities it uses,
and replaces issue-numbered method names with descriptive ones.
* chore(tests): split monolithic JsonApiTest into JsonApi/ subdir
Replace the 8-method root JsonApiTest.php with 4 focused JsonApi/* test
files, mirroring the JsonLd/ and Hal/ subdir layout:
* JsonApi/ErrorTest (ErrorResource rendered in vnd.api+json)
* JsonApi/IdentifierModeTest (4 use_iri_as_id:false tests sharing the
bootJsonApiKernel helper)
* JsonApi/IriModeTest (default use_iri_as_id:true mode)
* JsonApi/InputDtoTest (POST with input DTOs, preserved attributes and
required constructor args)
Each file scopes its fixtures to only what its tests use.
* test(security): migrate authorization behat features to ApiTestCase
Replaces features/authorization/{deny,legacy_deny}.feature with functional
tests under tests/Functional/Authorization, preserving full scenario
coverage. Each @link_security scenario lives in its own test so the
positive and negative paths are asserted independently.
Drops features/authorization from the misc behat shard; the
SecuredDummy-with-related-dummies fixture step stays since
features/graphql/authorization.feature still uses it.
* test(jsonapi): migrate behat features to ApiTestCase
Replaces 13 jsonapi behat features with ApiTestCase functional tests
backed by static-provider fixtures (CollectionUriTemplateTest reuses
the existing PropertyCollectionIriOnly entities to preserve Link
semantics). Covers errors, absolute/network URLs, item/collection
URI templates, circular refs, non-resource handling, DTO output,
ordering, filtering with sparse fieldsets, pagination, entrypoint,
CRUD with relationships, and include= related-resources resolution.
* test(jsonapi): back CRUD and inclusion tests with Doctrine persistence
CrudTest now uses Dummy/RelatedDummy/ThirdLevel/RelationEmbedder
entities through recreateSchema/persist/flush instead of static
processors that fabricated ids, matching the authorization migration
pattern. RelatedResourcesInclusionTest grows from 5 partial scenarios
to all 15 original behat scenarios (many-to-one, many-to-many, dedup,
path-based, collection variants) backed by DummyProperty/DummyGroup/
FourthLevel/RelatedOwningDummy. The 6 now-unused static JsonApi
fixtures are dropped.
* chore(ci): fix jsonapi migration follow-ups
* Drop empty `jsonapi` behat shard from CI matrix (features/jsonapi
was deleted in 0bf7af5).
* PHPStan: replace `is_int($offset)` always-true narrowing with an
upfront page-range guard in PaginationDummy.
* CS: prefix `array_slice` with `\` in OrderingTest per project style.
* test(security): skip DenyTest ORM-id-bound scenarios on MongoDB
Seven DenyTest cases assume the freshly-seeded SecuredDummy gets id=1
on every run. The MongoDB ODM INCREMENT strategy keeps its counter
outside the dropped document collection, so subsequent test runs
re-target a non-existent id and the API returns 404 instead of the
expected 403 / 200. Skip them on MongoDB to match the existing
isMongoDB() pattern used by the link-security tests in this file.
Also baseline the multi-shortName deprecation triggered by
RelatedLinkedDummy (used only by DenyTest now) so the
phpunit-no-deprecations CI job stays green.
* test(security): modernize DenyTest fixtures, drop INCREMENT id assumptions
* RelatedLinkedDummy (Entity + Document) gives each #[ApiResource] a
distinct shortName so the multi-shortName 4.2 deprecation no longer
fires. The baseline entry added in 8f0cb09 is reverted.
* DenyTest / LegacyDenyTest no longer hard-code /secured_dummies/1:
POSTs now return the IRI which subsequent GET/PUT calls consume.
seedLinkedDummy switches to API POST and returns the created ids,
so the helper works on both ORM and ODM. This removes seven
isMongoDB() skips and the failures from the MongoDB CI job (the
ODM INCREMENT counter survives collection drops and never gives id=1
twice in a row).
Verified locally against both APP_ENV=test and APP_ENV=mongodb.
* test(hal,jsonld): close remaining behat migration coverage gaps
Add PUT/PATCH on HAL relation embedder, PUT on HAL max-depth resource,
JSON-LD messenger and DataTransformerInitializer scenarios. Restore the
PropertyFilter on JsonLdNonResourceContainer (lost during migration) and
tighten the sparse-fieldset assertion so excluded keys are checked.
* test(jsonld): cover Issue5438 inheritance IRIs
The deleted features/jsonld/inheritance.feature only had
"print last JSON response" steps. Replace with a real assertion
that confirms each collection member uses its concrete subtype's
URI template (Contractor5438 → /contractor_5438/{id}, Employee5438
→ /employee_5438/{id}) — the original behavior fixed in #5449.1 parent 406ae36 commit 1d7695d
191 files changed
Lines changed: 11410 additions & 8130 deletions
File tree
- .github/workflows
- features
- authorization
- hal
- hydra
- jsonapi
- jsonld
- tests
- Fixtures
- TestBundle
- ApiResource
- Hal
- JsonApi
- JsonLd
- Document
- Entity
- State
- app/config
- Functional
- Authorization
- Hal
- JsonApi
- JsonLd
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
459 | | - | |
460 | 459 | | |
461 | 460 | | |
462 | 461 | | |
| |||
496 | 495 | | |
497 | 496 | | |
498 | 497 | | |
499 | | - | |
500 | 498 | | |
501 | | - | |
| 499 | + | |
502 | 500 | | |
503 | 501 | | |
504 | 502 | | |
| |||
This file was deleted.
0 commit comments