S
S
Steve2021-09-17 13:45:06
symfony
Steve, 2021-09-17 13:45:06

Voter and unit test. Mistake?

I have a voter that works great, but the problem is that I still have unit tests (php unittest) and this is where I got the error.
The scheme is as follows: the controller selector checks whether the $user object belongs to the User entity, if yes - the program goes further, if not - false.

if (!$user instanceof User) {
            return false;
        }


My test object is related to the InMemoryUser test entity so the test fails.
Tell me, please, how to fix the situation?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim, 2021-09-17
@CenterJoin

Use mocks and stubs for test doubles. Submit the desired object and check the condition.

A
Alexander Balashov, 2014-09-21
@benjaminsmith

Make the link block, set the desired size, background, etc.
For an icon in a button, you need to put the i tag in the link, make it block, put the background.
And the text can simply be left as text.

P
Pavel Yakovlev, 2014-09-22
@Kith_Debeetham

Isn't it easier to install a firebug and stupidly look at how it's done on the site?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question