Open
Description
Q | A |
---|---|
PHPUnit version | 9.2.6 |
PHP version | 7.4.8 |
Installation Method | Composer |
Summary
Mocking same method with different "with" and different "return"
Current behavior
Expectation failed for method name is "getRepository" when invoked zero or more times
Parameter 0 for invocation Doctrine\ORM\EntityManager::getRepository('Op\AppBundle\Entity\Order') does not match expected value.
Failed asserting that two strings are equal.
Expected :'Op\AppBundle\Entity\Customer'
Actual :'Op\AppBundle\Entity\Order'
How to reproduce
$this->em
->method('getRepository')
->with(Customer::class)
->willReturn($this->customerRepository);
$this->em
->method('getRepository')
->with(Order::class)
->willReturn($this->orderRepository);
$this->em->getRepository(Order::class)->findOneByOrderId($id);
Expected behavior
If "matcher" did not throw an exception on the second "match" (invoke), we should not throw an exception