コード例 #1
0
 public function testCanSaveLocationInDatabase()
 {
     $location = new \CrEOF\Spatial\PHP\Types\Geography\Point(151.2094, 33.865, 4326);
     $place = new Place(['fr' => 'test place']);
     $place->setLocation($location);
     $this->getEntityManager()->persist($place);
     $this->getEntityManager()->flush();
     // Test we can reload
     $this->getEntityManager()->clear();
     $placeRepository = $this->getEntityManager()->getRepository(Place::class);
     $reloadedPlace = $placeRepository->findOneById($place->getId());
     $reloadedLocation = $reloadedPlace->getLocation();
     $this->assertSame($location->getX(), $reloadedLocation->getX());
     $this->assertSame($location->getY(), $reloadedLocation->getY());
 }
コード例 #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);
 }