Download the PHP package firehed/mocktrine without Composer
On this page you can find all versions of the php package firehed/mocktrine. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mocktrine
Mocktrine
A Doctrine mocking library for testing
Usage
In your unit tests that need an Entity Manager, use a new \Firehed\Mocktrine\InMemoryEntityManager
. Done!
Any object with Doctrine's entity annotations (@Entity
, @Id
, @Column
, etc) should work without modification.
This library aims to provide as much type information as possible, so that static analysis tools (such as PHPStan) work well without additional plugins.
Mapping support
As of version 0.5, any mapping driver supported by Doctrine can be used with this library.
The InMemoryEntityManager
accepts the driver as an optional parameter.
You can also grab the value directly from your Doctrine config:
If a driver is not provided, it will default to either SimpleAnnotationReader
or AnnotationReader
that's used via Setup::createAnnotationMetadataConfiguration
.
The former will be preferred, but the class has been removed in doctrine/annotations:2.0
; if your local dependencies allow that version then the latter will be used.
It is RECOMMENDED to always explicitly provide a driver, as that best matches Doctrine's own setup behavior. Future versions of this library may make this required.
Supported features
The following methods on Doctrine's EntityManagerInterface
should all work as expected:
- find
- persist
- remove
- merge
- flush
- getRepository
- getCache (will always return
null
) - isOpen (will always return
true
)
All methods on the ObjectRepository
(for various findBy operations) should also work, as well as the non-interface count($criteria)
method.
ObjectRepository
also implements the Selectable
interface (as EntityRepository
does, which is the returned type from EntityManager
), so it's also possible to use the matching(Criteria)
method.
The following methods are not supported at this time:
- clear
- detach
- refresh
- getClassMetadata
- getMetadataFactory
- initializeObject
- contains
- getConnection
- getExpressionBuilder
- beginTransaction
- transactional
- commit
- rollback
- createQuery
- createNamedQuery
- createNativeQuery
- createNamedNativeQuery
- getReference
- getPartialReference
- close
- copy
- lock
- getEventManager
- getConfiguration
- getUnitOfWork
- getHydrator
- newHydrator
- getProxyFactory
- getFilters
- isFiltersStateClean
- hasFilters
All versions of mocktrine with dependencies
doctrine/annotations Version ^1.10 || ^2.0
doctrine/collections Version ^1.6.8 || ^2.0
doctrine/orm Version ^2.9
doctrine/persistence Version ^1.3 || ^2.0 || ^3.0
symfony/polyfill-php80 Version ^1.20