예제 #1
0
 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]);
 }
예제 #2
0
 public function testGetChildEventByCalendar()
 {
     $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);
     $masterEvent = new CalendarEvent();
     $masterEvent->addChildEvent($firstEvent)->addChildEvent($secondEvent);
     $this->assertEquals($firstEvent, $masterEvent->getChildEventByCalendar($firstCalendar));
     $this->assertEquals($secondEvent, $masterEvent->getChildEventByCalendar($secondCalendar));
     $this->assertNull($masterEvent->getChildEventByCalendar(new Calendar()));
 }
예제 #3
0
 public function testToString()
 {
     $obj = new Calendar();
     $obj->setName('testName');
     $this->assertEquals($obj->getName(), (string) $obj);
 }