S
S
Steve2021-09-17 16:19:25
symfony
Steve, 2021-09-17 16:19:25

Fake phpunit entity?

New to PHPUnit. I have a User entity and also an InMemoryUser entity, the latter creates a dummy user and is for testing purposes.
But I need to send a request on behalf of a user which is User, not InMemoryUser

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2021-09-17
@Maksclub

Why do you need a dummy one if you need an ordinary entity in the test? :)
The question is not quite clear, you need User - take User

P
part_os, 2021-09-18
@part_os

Start using mocks. https://phpunit.readthedocs.io/en/latest/test-doub...
The memory in and memory in entities approach also works, then you need to use an interface and implement the necessary logic in these entities.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question