Download the PHP package mgleska/repositorymock without Composer
On this page you can find all versions of the php package mgleska/repositorymock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mgleska/repositorymock
More information about mgleska/repositorymock
Files in mgleska/repositorymock
Package repositorymock
Short Description A package to facilitate the testing of classes/methods which uses ORM Repository and ORM Entity objects.
License MIT
Informations about the package repositorymock
A package to facilitate the testing of classes/methods which uses ORM Repository and ORM Entity objects.
Installation
Features
-
Provides ready-made mocks for functions:
find()findOneBy()findBy()- by scalar value
- by list of values
- by object
save()remove()
-
Allow to create mocks for Entity objects from array of values.
- simple Entity (without relations)
- multi-level Entity
Doctrine\ORM\Mapping\OneToOneDoctrine\ORM\Mapping\ManyToOneDoctrine\ORM\Mapping\OneToMany
-
Full compatibility with PHPUnit mock. An object of type RepositoryMock can be treated as a regular mock created by PHPUnit.
For example, you can use$mockedRepository->method('myCustomMethod')->willReturn(...). -
Provides the
createFakeObject(string $className, array $objData)method which can be used to create Entity object for use inwillReturn().
Particularly useful for multi-level Entities and those where theidfield has no setter (because it is autoincrement). - Provides the ability to create test scenarios for update/edit and create/delete actions.
The mock for thesave()function stores the data sent towards the database. Which gives the possibility to observe the "state of the database" after the tested operation$sut->action()is completed.save()does:- update if entity exists
- insert with autoincrement for
id
- than
getStoreContent()method allow to make assertions on entities stored in database.
Usage
-
Mock for simple
find(). - More usage examples in file
tests/SutServiceTest.php.
All versions of repositorymock with dependencies
doctrine/collections Version ^2.2
doctrine/orm Version ^3
phpunit/phpunit Version ^11.1