/** * @test */ public function setParticipantsUpdatesTotalPrice() { $this->subject = $this->getAccessibleMock(Reservation::class, ['getLesson']); $singlePrice = 123.45; $totalPrice = 2 * $singlePrice; $firstParticipant = new Person(); $secondParticipant = new Person(); $objectStorageContainingTwoParticipants = new ObjectStorage(); $objectStorageContainingTwoParticipants->attach($firstParticipant); $objectStorageContainingTwoParticipants->attach($secondParticipant); $lesson = $this->getMock(Schedule::class, ['getPrice']); $lesson->expects($this->any())->method('getPrice')->will($this->returnValue($singlePrice)); $this->subject->expects($this->any())->method('getLesson')->will($this->returnValue($lesson)); $this->subject->setParticipants($objectStorageContainingTwoParticipants); $this->assertSame($totalPrice, $this->subject->getTotalPrice()); }