Hello,
My title is not very descriptive, but I hope, that after I will explain my problem, I would get some help.
I describe a symfony2 controller, and in my let function I have something like that:
$container->get('doctrine')->willReturn($doctrine);
$doctrine->getManager()->willReturn($entityManager);
$entityManager->getRepository(Argument::any())->willReturn($repository);
among others.
Now when in the function where I was specking the behaviour that when form is valid it will save my object in the database,
I have among other, something like this:
$entityManager->persist($reader)->shouldBeCalled();
$entityManager->flush()->shouldBeCalled();
And now it' ok, but if either in my spec I add this line $reader->setSalt(Argument::any()); or in my code this line $reader->setSalt(md5(time()));
then when I run my spec I got this kind of error, in the both cases
method call:
Double\Doctrine\ORM\EntityManager\P205362297->persist(BddSBP\ReaderBundle\Entity\Reader:00000000250f842f00000000098356d6)
was not expected.
Expected calls are:
- getRepository(*)
- persist(exact(BddSBP\ReaderBundle\Entity\Reader:00000000250f838200000000098356d6))
- flush()
So basically, if change my entity object, then my spec will be broken.
Thank you.