Answer the question
In order to leave comments, you need to log in
Why is only one Mock object created?
The situation is this. For testing, you need several Mock objects of the same class.
We create a method:
protected function createBagMock(
?delivery $delivery = null,
?string $barcode = null,
?int $weight = null,
array $products =[]
): Bag {
$bag = $this->getMockBuilder(Bag::class)
->setConstructorArgs([
'pickUpDelivery' => is_null($delivery) ? $this->dliveryMock() : $delivery,
'barcode' => is_null($barcode) ? TestValues::TEST_BARCODE : $barcode,
'weight' => is_null($weight) ? 1000 : $weight,
'products' => empty($products) ? [] : $products,
])->getMock();
return $bag;
}
dump($this->createBagMock()); //тут Mock_Bag_edb40126
dump($this->createBagMock()); //и тут Mock_Bag_edb40126
dump($this->createBagMock()); //и тут тоже Mock_Bag_edb40126
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question