public function testPostSubmitChildEvents() { $firstCalendar = new Calendar(); $firstCalendar->setName('1'); $secondCalendar = new Calendar(); $secondCalendar->setName('2'); $firstEvent = new CalendarEvent(); $firstEvent->setTitle('1')->setCalendar($firstCalendar); $secondEvent = new CalendarEvent(); $secondEvent->setTitle('2')->setCalendar($secondCalendar); $firstExistingEvent = new CalendarEvent(); $firstExistingEvent->setTitle('1_existing')->setCalendar($firstCalendar); $parentEvent = new CalendarEvent(); $parentEvent->addChildEvent($firstExistingEvent); $parentForm = $this->getMock('Symfony\\Component\\Form\\FormInterface'); $parentForm->expects($this->any())->method('getData')->will($this->returnValue($parentEvent)); $events = new ArrayCollection([$firstEvent, $secondEvent]); $form = $this->getMock('Symfony\\Component\\Form\\FormInterface'); $form->expects($this->any())->method('getData')->will($this->returnValue($events)); $this->type->preSubmit(new FormEvent($parentForm, [])); $this->type->postSubmitChildEvents(new FormEvent($form, [])); $this->assertCount(2, $events); $this->assertEquals($firstExistingEvent, $events[0]); $this->assertEquals($secondEvent, $events[1]); }