Ejemplo n.º 1
0
 /**
  * @param string $filename
  * @param string $expectedName
  * @return Event[]
  */
 private function import($filename, $expectedName)
 {
     $entityManagerMock = $this->getMock(\Doctrine\ORM\EntityManager::class, ['persist', 'flush'], [], '', false);
     $importer = new Importer();
     $importer->setEntityManager($entityManagerMock);
     $calendar = new Calendar();
     $calendar->setUrl(realpath($filename));
     $this->assertEmpty($calendar->getEvents());
     $importer->import($calendar);
     $this->assertSame($expectedName, $calendar->getName());
     // Sort events
     $events = $calendar->getEvents()->toArray();
     usort($events, function ($event1, $event2) {
         return $event1->compare($event2);
     });
     return $events;
 }
Ejemplo n.º 2
0
 public function testStuff()
 {
     $entityManagerMock = $this->getMock(\Doctrine\ORM\EntityManager::class, ['persist', 'flush'], [], '', false);
     $importer = new Importer();
     $importer->setEntityManager($entityManagerMock);
     $calendar = new Calendar();
     $calendar->setUrl('tests/data/calendar.ics');
     $importer->import($calendar);
     $place = new Place(['fr' => 'The Rock, Zamzibar']);
     $place->setLocation(new \CrEOF\Spatial\PHP\Types\Geography\Point(39.519313, -6.152079));
     $calendar->setPlace($place);
     $renderer = new CalendarRenderer();
     $viewModel = new CalendarModel($calendar);
     $actual = $renderer->render($viewModel);
     // Log actual result for easier comparison when debugging
     @mkdir('logs/tests');
     file_put_contents('logs/tests/export.ics', $actual);
     $expected = file_get_contents('tests/data/export.ics');
     $this->assertSame($expected, $actual);
 }