EntityLookupServiceTest
class EntityLookupServiceTest extends CheckTestCase (View source)
Methods
Create a stubbed StubDataQueryInterface.
Create a StubDataQueryInterface mock, for tests that constrain arguments with with() or assert call counts with expects().
Create a mock PHPFunction with the given id/name.
Create a mock PHPClass with the given id/name.
Create a mock PHPClass with properties (isFinal, isReadonly, namespace, parentClass).
Create a mock PHPProperty with the given name and optional version bounds.
Create a mock PHPMethod with the given name.
Create a mock PHPParameter with the given name and type.
Create a StandaloneType with the given type name.
Create a mock type that returns a string representation.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
The index is cached per storage object and shared across service instances, because ValidatorTestBase builds a fresh check (and service) per data-provider row. Without sharing, every lookup rescanned the whole storage.
The correctness property that matters most: sharing must be keyed on the storage, so two storages never see each other's entities. A cache keyed on spl_object_id() could violate this once an id is reused after an object is freed.
Each entity kind is indexed independently, so indexing classes must not mask a later interface lookup on the same storage.
The storage is only scanned once per kind: the mock is configured to allow a single getClasses() call, so a second lookup that rescanned would fail the expectation.
No description
Details
protected StubDataQueryInterface&Stub
createMockStorageManager()
Create a stubbed StubDataQueryInterface.
A stub rather than a mock: these doubles only supply return values and never verify interactions, so createMock() made PHPUnit emit "No expectations were configured for the mock object" for every one of them — 1777 notices from this helper alone.
The return type names the double explicitly (&Stub) instead of just the interface,
so ->method(...) resolves for static analysis; previously every such call across
~90 test files was reported as an undefined method, burying real warnings.
protected StubDataQueryInterface&MockObject
createStorageManagerMock()
Create a StubDataQueryInterface mock, for tests that constrain arguments with with() or assert call counts with expects().
Those only work on a mock: on a stub, with() is silently ignored (PHPUnit deprecates it and will remove it in 13), so a test using the stub helper would appear to pin the argument while actually accepting anything.
protected PHPFunction
createMockFunction(string $name, array $parameters = [], $returnType = null)
Create a mock PHPFunction with the given id/name.
protected PHPClass
createMockClass(string $name, array $methods = [])
Create a mock PHPClass with the given id/name.
protected PHPClass
createMockClassWithProperties(string $name, string|null $namespace = null, bool|null $isFinal = null, bool|null $isReadonly = null, array $methods = [], PHPClass|null $parentClass = null, array $interfaces = [], array $properties = [])
Create a mock PHPClass with properties (isFinal, isReadonly, namespace, parentClass).
protected PHPProperty
createMockProperty(string $name, string|null $sinceVersion = null, string|null $removedVersion = null)
Create a mock PHPProperty with the given name and optional version bounds.
protected PHPMethod
createMockMethod(string $name, array $parameters = [], $returnType = null)
Create a mock PHPMethod with the given name.
protected PHPParameter
createMockParameter(string $name, mixed|null $type = null, string|null $sinceVersion = null, string|null $removedVersion = null, bool $isDeprecated = false, string|null $deprecatedSinceVersion = null)
Create a mock PHPParameter with the given name and type.
Note: Supports both getDeclaredType() and getType() methods to be compatible with different validators (ParameterNamesCheck uses getName, ParameterTypesCheck uses getType).
protected StandaloneType
createType(string $typeName)
Create a StandaloneType with the given type name.
protected object
createMockType(string $typeString)
Create a mock type that returns a string representation.
__construct(string $typeName)
No description
string
__toString()
No description
string
getTypeName()
No description
protected void
setUp()
No description
void
testFindClassByIdReturnsEntityWhenFound()
No description
void
testFindClassByIdReturnsNullWhenNotFound()
No description
void
testFindEnumByIdReturnsEntityWhenFound()
No description
void
testFindEnumByIdReturnsNullWhenNotFound()
No description
void
testFindInterfaceByIdReturnsEntityWhenFound()
No description
void
testFindInterfaceByIdReturnsNullWhenNotFound()
No description
void
testFindConstantByIdReturnsEntityWhenFound()
No description
void
testFindConstantByIdReturnsNullWhenNotFound()
No description
void
testFindFunctionByIdReturnsEntityWhenFound()
No description
void
testFindFunctionByIdReturnsNullWhenNotFound()
No description
void
testSecondCallWithSameStorageUsesCachedIndex()
No description
void
testDifferentStorageObjectsGetSeparateIndexes()
No description
void
testEntitiesWithNullIdAreSkippedDuringIndexing()
No description
void
testFindAnyEntityByIdReturnsClassWithCorrectType()
No description
void
testFindAnyEntityByIdReturnsInterfaceWithCorrectType()
No description
void
testFindAnyEntityByIdReturnsEnumWithCorrectType()
No description
void
testFindAnyEntityByIdReturnsFunctionWithCorrectType()
No description
void
testFindAnyEntityByIdReturnsNullWhenNotFound()
No description
void
testFindAnyEntityByIdPrefersClassOverOtherTypes()
No description
void
testIndexIsSharedAcrossServiceInstancesForTheSameStorage()
The index is cached per storage object and shared across service instances, because ValidatorTestBase builds a fresh check (and service) per data-provider row. Without sharing, every lookup rescanned the whole storage.
void
testIndexesOfDistinctStoragesDoNotLeakIntoEachOther()
The correctness property that matters most: sharing must be keyed on the storage, so two storages never see each other's entities. A cache keyed on spl_object_id() could violate this once an id is reused after an object is freed.
void
testKindsAreIndexedIndependently()
Each entity kind is indexed independently, so indexing classes must not mask a later interface lookup on the same storage.
void
testStorageIsScannedOnlyOncePerKind()
The storage is only scanned once per kind: the mock is configured to allow a single getClasses() call, so a second lookup that rescanned would fail the expectation.
void
testClearIndexCacheForcesAReindex()
No description