/**
  *
  */
 function test1()
 {
     $feature = new \sitefeatures\EditCommentsFeature();
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $siteFeatureRepo = new SiteFeatureRepository($this->app);
     // Test Get Default Option
     $this->app['timesource']->mock(2015, 1, 1, 1, 1, 1);
     $data = $siteFeatureRepo->getForSiteAsTree($site);
     $this->assertEquals(false, $data[$feature->getExtensionId()][$feature->getFeatureId()]->isOn());
     // Test Set True
     $this->app['timesource']->mock(2015, 1, 1, 1, 1, 2);
     $siteFeatureRepo->setFeature($site, $feature, true, $user);
     $data = $siteFeatureRepo->getForSiteAsTree($site);
     $this->assertEquals(true, $data[$feature->getExtensionId()][$feature->getFeatureId()]->isOn());
     // Test Set False
     $this->app['timesource']->mock(2015, 1, 1, 1, 1, 3);
     $siteFeatureRepo->setFeature($site, $feature, false, $user);
     $data = $siteFeatureRepo->getForSiteAsTree($site);
     $this->assertEquals(false, $data[$feature->getExtensionId()][$feature->getFeatureId()]->isOn());
     // Test Set False whilst already false
     $this->app['timesource']->mock(2015, 1, 1, 1, 1, 4);
     $siteFeatureRepo->setFeature($site, $feature, false, $user);
     $data = $siteFeatureRepo->getForSiteAsTree($site);
     $this->assertEquals(false, $data[$feature->getExtensionId()][$feature->getFeatureId()]->isOn());
 }
コード例 #2
0
 function test1()
 {
     TimeSource::mock(2014, 5, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0));
     $event->setUrl("http://www.info.com");
     $event->setTicketUrl("http://www.tickets.com");
     $eventDupe = new EventModel();
     $eventDupe->setSummary("test");
     $eventDupe->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0));
     $eventDupe->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0));
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user, $group);
     $eventRepository->create($eventDupe, $site, $user, $group);
     TimeSource::mock(2014, 5, 1, 7, 1, 0);
     $eventRepository->markDuplicate($eventDupe, $event);
     $userAtEvent = new \models\UserAtEventModel();
     $userAtEvent->setEventId($event->getId());
     $userAtEvent->setUserAccountId($user->getId());
     $userAtEvent->setIsPlanAttending(true);
     $userAtEventRepo = new \repositories\UserAtEventRepository();
     $userAtEventRepo->create($userAtEvent);
     $curatedList = new CuratedListModel();
     $curatedList->setTitle("test");
     $curatedList->setDescription("test this!");
     $clRepo = new CuratedListRepository();
     $clRepo->create($curatedList, $site, $user);
     $clRepo->addEventtoCuratedList($event, $curatedList, $user);
     $tag = new TagModel();
     $tag->setTitle("Test");
     $tagRepo = new TagRepository();
     $tagRepo->create($tag, $site, $user);
     $tagRepo->addTagToEvent($tag, $event, $user);
     ## TEST
     $this->assertNotNull($eventRepository->loadBySlug($site, $event->getSlug()));
     ## PURGE!
     $eventRepository->purge($event);
     ## TEST
     $this->assertNull($eventRepository->loadBySlug($site, $event->getSlug()));
 }
コード例 #3
0
 function test1()
 {
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $this->checkGroupInTest1($groupRepo->loadById($group->getId()));
     $this->checkGroupInTest1($groupRepo->loadBySlug($site, $group->getSlug()));
     $grb = new GroupRepositoryBuilder();
     $grb->setFreeTextsearch('test');
     $this->assertEquals(1, count($grb->fetchAll()));
     $grb = new GroupRepositoryBuilder();
     $grb->setFreeTextsearch('cats');
     $this->assertEquals(0, count($grb->fetchAll()));
 }
コード例 #4
0
 function testWinterTime()
 {
     TimeSource::mock(2014, 5, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt($this->mktime(2014, 11, 10, 19, 0, 0, 'Europe/London'));
     $event->setEndAt($this->mktime(2014, 11, 10, 21, 0, 0, 'Europe/London'));
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals("test test", $event->getDescription());
     $this->assertEquals("test", $event->getSummary());
     $startAtShouldBe = $this->mktime(2014, 11, 10, 19, 0, 0, 'UTC');
     $startAtIs = clone $event->getStartAt();
     $startAtIs->setTimezone(new \DateTimeZone('UTC'));
     $this->assertEquals($startAtShouldBe->format("c"), $startAtIs->format("c"));
 }
コード例 #5
0
 function test1()
 {
     $this->addCountriesToTestDB();
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venue->setDescription("test test");
     $venue->setCountryId($gb->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     $this->checkVenueInTest1($venueRepo->loadById($venue->getId()));
     $this->checkVenueInTest1($venueRepo->loadBySlug($site, $venue->getSlug()));
     $grb = new VenueRepositoryBuilder();
     $grb->setFreeTextsearch('test');
     $this->assertEquals(1, count($grb->fetchAll()));
     $grb = new VenueRepositoryBuilder();
     $grb->setFreeTextsearch('cats');
     $this->assertEquals(0, count($grb->fetchAll()));
 }
コード例 #6
0
 function test1()
 {
     \TimeSource::mock(2014, 1, 1, 0, 0, 0);
     $this->addCountriesToTestDB();
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venue->setDescription("test test");
     $venue->setCountryId($gb->getId());
     \TimeSource::mock(2014, 1, 1, 1, 0, 0);
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     \TimeSource::mock(2014, 1, 1, 2, 0, 0);
     $venueRepo->delete($venue, $user);
     $this->checkVenueInTest1($venueRepo->loadById($venue->getId()));
     $this->checkVenueInTest1($venueRepo->loadBySlug($site, $venue->getSlug()));
     $vrb = new VenueRepositoryBuilder();
     $vrb->setIncludeDeleted(true);
     $this->assertEquals(1, count($vrb->fetchAll()));
     $vrb = new VenueRepositoryBuilder();
     $vrb->setIncludeDeleted(false);
     $this->assertEquals(0, count($vrb->fetchAll()));
 }
 function testIntegration1()
 {
     $this->addCountriesToTestDB();
     \TimeSource::mock(2014, 1, 1, 12, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     ## Create area
     \TimeSource::mock(2014, 1, 1, 13, 0, 0);
     $area = new AreaModel();
     $area->setTitle("test");
     $area->setDescription("test test");
     $area->setCountryId($gb->getId());
     $areaRepo = new AreaRepository();
     $areaRepo->create($area, null, $site, $gb, $user);
     ## Edit area
     \TimeSource::mock(2014, 1, 1, 14, 0, 0);
     $area = $areaRepo->loadById($area->getId());
     $area->setDescription("testy");
     $areaRepo->edit($area, $user);
     ## Now save changed flags on these .....
     $areaHistoryRepo = new AreaHistoryRepository();
     $stat = $this->app['db']->prepare("SELECT * FROM area_history");
     $stat->execute();
     while ($data = $stat->fetch()) {
         $areaHistory = new AreaHistoryModel();
         $areaHistory->setFromDataBaseRow($data);
         $areaHistoryRepo->ensureChangedFlagsAreSet($areaHistory);
     }
     ## Now load and check
     $historyRepo = new HistoryRepositoryBuilder();
     $historyRepo->setIncludeEventHistory(false);
     $historyRepo->setIncludeVenueHistory(false);
     $historyRepo->setIncludeGroupHistory(false);
     $historyRepo->setIncludeAreaHistory(true);
     $histories = $historyRepo->fetchAll();
     $this->assertEquals(2, count($histories));
     #the edit
     $this->assertEquals(FALSE, $histories[0]->getTitleChanged());
     $this->assertEquals(true, $histories[0]->getDescriptionChanged());
     $this->assertEquals(false, $histories[0]->getCountryIdChanged());
     $this->assertEquals(false, $histories[0]->getParentAreaIdChanged());
     $this->assertEquals(false, $histories[0]->getIsDeletedChanged());
     #the create
     $this->assertEquals(true, $histories[1]->getTitleChanged());
     $this->assertEquals(true, $histories[1]->getDescriptionChanged());
     $this->assertEquals(true, $histories[1]->getCountryIdChanged());
     $this->assertEquals(false, $histories[1]->getParentAreaIdChanged());
     $this->assertEquals(false, $histories[1]->getIsDeletedChanged());
 }
コード例 #8
0
 function test1()
 {
     \TimeSource::mock(2014, 1, 1, 0, 0, 0);
     $user1 = new UserAccountModel();
     $user1->setEmail("*****@*****.**");
     $user1->setUsername("test");
     $user1->setPassword("password");
     $user2 = new UserAccountModel();
     $user2->setEmail("*****@*****.**");
     $user2->setUsername("test2");
     $user2->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user1);
     $userRepo->create($user2);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user1, array(), $this->getSiteQuotaUsedForTesting());
     $group1 = new GroupModel();
     $group1->setTitle("test1");
     $group1->setDescription("test test");
     $group1->setUrl("http://www.group.com");
     $group2 = new GroupModel();
     $group2->setTitle("test this looks similar");
     $group2->setDescription("test test");
     $group2->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     \TimeSource::mock(2014, 1, 1, 1, 0, 0);
     $groupRepo->create($group1, $site, $user1);
     $groupRepo->create($group2, $site, $user2);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0));
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user1, $group2);
     $uwgr = new UserWatchesGroupRepository();
     // Test before
     $erb = new \repositories\builders\EventRepositoryBuilder();
     $erb->setGroup($group1);
     $this->assertEquals(0, count($erb->fetchAll()));
     $this->assertNull($uwgr->loadByUserAndGroup($user2, $group1));
     $group2 = $groupRepo->loadById($group2->getId());
     $this->assertFalse($group2->getIsDeleted());
     $this->assertNull($group2->getIsDuplicateOfId());
     // Mark
     \TimeSource::mock(2014, 1, 1, 2, 0, 0);
     $groupRepo->markDuplicate($group2, $group1, $user1);
     // Test Duplicate
     $erb = new \repositories\builders\EventRepositoryBuilder();
     $erb->setGroup($group1);
     $this->assertEquals(1, count($erb->fetchAll()));
     $uwg = $uwgr->loadByUserAndGroup($user2, $group1);
     $this->assertNotNull($uwg);
     $group2 = $groupRepo->loadById($group2->getId());
     $this->assertTrue($group2->getIsDeleted());
     $this->assertEquals($group1->getId(), $group2->getIsDuplicateOfId());
 }
コード例 #9
0
 function create(Request $request, Application $app)
 {
     $siteRepository = new SiteRepository();
     $form = $app['form.factory']->create(new CreateForm());
     if ('POST' == $request->getMethod()) {
         $form->bind($request);
         $data = $form->getData();
         $site = $siteRepository->loadBySlug($data['slug']);
         if ($site) {
             $form->addError(new FormError('That address is already taken'));
         }
         if ($form->isValid()) {
             $site = new SiteModel();
             $site->setSlug($data['slug']);
             $site->setTitle($data['title']);
             if ($data['read'] == 'public') {
                 $site->setIsListedInIndex(true);
                 $site->setIsWebRobotsAllowed(true);
             } else {
                 $site->setIsListedInIndex(false);
                 $site->setIsWebRobotsAllowed(false);
             }
             if ($data['write'] == 'public') {
                 $isAllUsersEditors = true;
             } else {
                 $isAllUsersEditors = false;
             }
             $site->setPromptEmailsDaysInAdvance($app['config']->newSitePromptEmailsDaysInAdvance);
             $countryRepository = new CountryRepository();
             $siteQuotaRepository = new SiteQuotaRepository();
             $siteRepository->create($site, $app['currentUser'], array($countryRepository->loadByTwoCharCode("GB")), $siteQuotaRepository->loadByCode($app['config']->newSiteHasQuotaCode), $isAllUsersEditors);
             if ($app['config']->hasSSL) {
                 return $app->redirect("https://" . $site->getSlug() . "." . $app['config']->webSiteDomainSSL);
             } else {
                 return $app->redirect("http://" . $site->getSlug() . "." . $app['config']->webSiteDomain);
             }
         }
     }
     $sites = array();
     $repo = new SiteRepository();
     if (isset($_COOKIE['sitesSeen'])) {
         foreach (explode(",", $_COOKIE['sitesSeen']) as $siteID) {
             if (intval($siteID) > 0) {
                 $site = $repo->loadById($siteID);
                 if ($site && !$site->getIsClosedBySysAdmin() && $site->getSlug() != $app['config']->siteSlugDemoSite) {
                     $sites[$site->getId()] = $site;
                 }
             }
         }
     }
     $srb = new SiteRepositoryBuilder();
     $srb->setIsOpenBySysAdminsOnly(true);
     $srb->setUserInterestedIn($app['currentUser']);
     foreach ($srb->fetchAll() as $site) {
         $sites[$site->getId()] = $site;
     }
     return $app['twig']->render('index/index/create.html.twig', array('form' => $form->createView(), 'sites' => $sites));
 }
 function testBasic()
 {
     global $CONFIG;
     \TimeSource::mock(2013, 10, 1, 1, 1, 1);
     $CONFIG->importURLAllowEventsSecondsIntoFuture = 7776000;
     // 90 days
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $importURLRepository = new ImportURLRepository();
     $importURL = new ImportURLModel();
     $importURL->setIsEnabled(true);
     $importURL->setSiteId($site->getId());
     $importURL->setGroupId($group->getId());
     $importURL->setTitle("Test");
     $importURL->setUrl("http://test.com");
     $importURLRepository->create($importURL, $site, $user);
     // Import
     $importURLRun = new ImportURLRun($importURL, $site);
     $importURLRun->setTemporaryFileStorageForTesting(dirname(__FILE__) . '/data/Lanyrd1.ical');
     $importURLRun->setFlag(ImportURLRun::$FLAG_ADD_UIDS);
     $i = new ImportURLICalHandler();
     $i->setImportURLRun($importURLRun);
     $this->assertTrue($i->canHandle());
     $r = $i->handle();
     // Load!
     $erb = new EventRepositoryBuilder();
     $erb->setSite($site);
     $events = $erb->fetchAll();
     $this->assertEquals(1, count($events));
     $event = $events[0];
     $this->assertEquals("State of the Map Scotland 2013", $event->getSummary());
     $this->assertEquals('2013-10-11 00:00:00', $event->getStartAt()->format('Y-m-d H:i:s'));
     $this->assertEquals('2013-10-14 23:59:59', $event->getEndAt()->format('Y-m-d H:i:s'));
     $this->assertEquals("http://sotms.eventbrite.com/\n\nhttp://lanyrd.com/crkmt", $event->getDescription());
     $this->assertEquals('http://lanyrd.com/2013/sotmscot2013/', $event->getURL());
     $this->assertFalse($event->getIsDeleted());
     // Look for event
     $erb = new EventRepositoryBuilder();
     $erb->setSite($site);
     $erb->setImportURL($importURL);
     $this->assertEquals(1, count($erb->fetchAll()));
 }
 function testIntegration1()
 {
     \TimeSource::mock(2014, 1, 1, 12, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     ## Create group
     \TimeSource::mock(2014, 1, 1, 13, 0, 0);
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     ## Edit group
     \TimeSource::mock(2014, 1, 1, 14, 0, 0);
     $group = $groupRepo->loadById($group->getId());
     $group->setTwitterUsername("testy");
     $groupRepo->edit($group, $user);
     ## Now save changed flags on these .....
     $groupHistoryRepo = new GroupHistoryRepository();
     $stat = $this->app['db']->prepare("SELECT * FROM group_history");
     $stat->execute();
     while ($data = $stat->fetch()) {
         $groupHistory = new GroupHistoryModel();
         $groupHistory->setFromDataBaseRow($data);
         $groupHistoryRepo->ensureChangedFlagsAreSet($groupHistory);
     }
     ## Now load and check
     $historyRepo = new HistoryRepositoryBuilder();
     $historyRepo->setGroup($group);
     $historyRepo->setIncludeEventHistory(false);
     $historyRepo->setIncludeVenueHistory(false);
     $historyRepo->setIncludeGroupHistory(true);
     $histories = $historyRepo->fetchAll();
     $this->assertEquals(2, count($histories));
     #the edit
     $this->assertEquals(FALSE, $histories[0]->getTitleChanged());
     $this->assertEquals(false, $histories[0]->getDescriptionChanged());
     $this->assertEquals(false, $histories[0]->getUrlChanged());
     $this->assertEquals(true, $histories[0]->getTwitterUsernameChanged());
     $this->assertEquals(false, $histories[0]->getIsDeletedChanged());
     #the create
     $this->assertEquals(true, $histories[1]->getTitleChanged());
     $this->assertEquals(true, $histories[1]->getDescriptionChanged());
     $this->assertEquals(true, $histories[1]->getUrlChanged());
     $this->assertEquals(false, $histories[1]->getTwitterUsernameChanged());
     $this->assertEquals(false, $histories[1]->getIsDeletedChanged());
 }
 function testBasic()
 {
     global $CONFIG;
     \TimeSource::mock(2013, 10, 1, 1, 1, 1);
     $CONFIG->importURLAllowEventsSecondsIntoFuture = 7776000;
     // 90 days
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $importURLRepository = new ImportURLRepository();
     $importURL = new ImportURLModel();
     $importURL->setIsEnabled(true);
     $importURL->setSiteId($site->getId());
     $importURL->setGroupId($group->getId());
     $importURL->setTitle("Test");
     $importURL->setUrl("http://test.com");
     $importURLRepository->create($importURL, $site, $user);
     // Import
     $importURLRun = new ImportURLRun($importURL, $site);
     $importURLRun->setTemporaryFileStorageForTesting(dirname(__FILE__) . '/data/Eventbrite1.ical');
     $importURLRun->setFlag(ImportURLRun::$FLAG_ADD_UIDS);
     $importURLRun->setFlag(ImportURLRun::$FLAG_SET_TICKET_URL_AS_URL);
     $i = new ImportURLICalHandler();
     $i->setImportURLRun($importURLRun);
     $this->assertTrue($i->canHandle());
     $r = $i->handle();
     // Load!
     $erb = new EventRepositoryBuilder();
     $erb->setSite($site);
     $events = $erb->fetchAll();
     $this->assertEquals(1, count($events));
     $event = $events[0];
     $this->assertEquals("Computing At School Scotland Conference 2013", $event->getSummary());
     $this->assertEquals('2013-10-26 07:30:00', $event->getStartAt()->format('Y-m-d H:i:s'));
     $this->assertEquals('2013-10-26 16:00:00', $event->getEndAt()->format('Y-m-d H:i:s'));
     $this->assertEquals('For details, click here: https://casscot13.eventbrite.co.uk', $event->getDescription());
     $this->assertEquals('https://casscot13.eventbrite.co.uk', $event->getURL());
     $this->assertEquals('https://casscot13.eventbrite.co.uk', $event->getTicketURL());
     $this->assertFalse($event->getIsDeleted());
 }
コード例 #13
0
 function test1()
 {
     $this->addCountriesToTestDB();
     \TimeSource::mock(2014, 10, 1, 1, 1, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     $area = new AreaModel();
     $area->setTitle("test");
     $area->setDescription("test test");
     $areaRepo = new \repositories\AreaRepository();
     $areaRepo->create($area, null, $site, $gb, $user);
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venue->setDescription("test test");
     $venue->setCountryId($gb->getId());
     $venue->setAreaId($area->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     $venueDuplicate = new VenueModel();
     $venueDuplicate->setTitle("test Duplicate");
     $venueRepo->create($venueDuplicate, $site, $user);
     \TimeSource::mock(2014, 10, 1, 1, 2, 0);
     $venueRepo->markDuplicate($venueDuplicate, $venue, $user);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0, 'Europe/London'));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0, 'Europe/London'));
     $event->setVenueId($venue->getId());
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     ## Test
     $this->assertNotNull($venueRepo->loadBySlug($site, $venue->getSlug()));
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($venue->getId(), $event->getVenueId());
     ## Now Purge!
     $venueRepo->purge($venue);
     ## Test
     $this->assertNull($venueRepo->loadBySlug($site, $venue->getSlug()));
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertNull($event->getVenueId());
 }
コード例 #14
0
 function index(Request $request, Application $app)
 {
     $form = $app['form.factory']->create(new NewSiteForm());
     if ('POST' == $request->getMethod()) {
         $form->bind($request);
         $data = $form->getData();
         $siteRepository = new SiteRepository();
         $site = $siteRepository->loadBySlug($data['slug']);
         if ($site) {
             $form->addError(new FormError('That address is already taken'));
         }
         if ($form->isValid()) {
             $userRepo = new UserAccountRepository();
             $user = $userRepo->loadByEmail($data['email']);
             if ($user) {
                 $data = $form->getData();
                 $site = new SiteModel();
                 $site->setSlug($data['slug']);
                 $site->setTitle($data['title']);
                 if ($data['read'] == 'public') {
                     $site->setIsListedInIndex(true);
                     $site->setIsWebRobotsAllowed(true);
                 } else {
                     $site->setIsListedInIndex(false);
                     $site->setIsWebRobotsAllowed(false);
                 }
                 if ($data['write'] == 'public') {
                     $site->setIsAllUsersEditors(true);
                     $site->setIsRequestAccessAllowed(false);
                 } else {
                     $site->setIsAllUsersEditors(false);
                     $site->setIsRequestAccessAllowed(true);
                 }
                 $site->setIsFeatureCuratedList($app['config']->newSiteHasFeatureCuratedList);
                 $site->setIsFeatureImporter($app['config']->newSiteHasFeatureImporter);
                 $site->setIsFeatureMap($app['config']->newSiteHasFeatureMap);
                 $site->setIsFeatureVirtualEvents($app['config']->newSiteHasFeatureVirtualEvents);
                 $site->setIsFeaturePhysicalEvents($app['config']->newSiteHasFeaturePhysicalEvents);
                 $site->setIsFeatureGroup($app['config']->newSiteHasFeatureGroup);
                 $site->setPromptEmailsDaysInAdvance($app['config']->newSitePromptEmailsDaysInAdvance);
                 $site->setIsFeatureTag($app['config']->newSiteHasFeatureTag);
                 $countryRepository = new CountryRepository();
                 $siteQuotaRepository = new SiteQuotaRepository();
                 $siteRepository->create($site, $user, array($countryRepository->loadByTwoCharCode("GB")), $siteQuotaRepository->loadByCode($app['config']->newSiteHasQuotaCode));
                 return $app->redirect("/sysadmin/site/" . $site->getId());
             } else {
                 $app['flashmessages']->addError('Existing user not found!');
             }
         }
     }
     return $app['twig']->render('sysadmin/sitenew/index.html.twig', array('form' => $form->createView()));
 }
 function testBasic()
 {
     global $CONFIG;
     \TimeSource::mock(2013, 10, 1, 1, 1, 1);
     $CONFIG->importURLAllowEventsSecondsIntoFuture = 7776000;
     // 90 days
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $importURLRepository = new ImportURLRepository();
     $importURL = new ImportURLModel();
     $importURL->setIsEnabled(true);
     $importURL->setSiteId($site->getId());
     $importURL->setGroupId($group->getId());
     $importURL->setTitle("Test");
     $importURL->setUrl("http://test.com");
     $importURLRepository->create($importURL, $site, $user);
     // Import
     $importURLRun = new ImportURLRun($importURL, $site);
     $importURLRun->setTemporaryFileStorageForTesting(dirname(__FILE__) . '/data/Meetup1.ics');
     $importURLRun->setFlag(ImportURLRun::$FLAG_ADD_UIDS);
     $i = new ImportURLICalHandler();
     $i->setImportURLRun($importURLRun);
     $this->assertTrue($i->canHandle());
     $r = $i->handle();
     // Load!
     $erb = new EventRepositoryBuilder();
     $erb->setSite($site);
     $events = $erb->fetchAll();
     $this->assertEquals(1, count($events));
     $event = $events[0];
     $this->assertEquals("Talk & Build AngularJS", $event->getSummary());
     $this->assertEquals('2013-10-17 18:00:00', $event->getStartAt()->format('Y-m-d H:i:s'));
     $this->assertEquals('2013-10-17 21:00:00', $event->getEndAt()->format('Y-m-d H:i:s'));
     $this->assertEquals("AngularJS - Edinburgh\nThursday, October 17 at 7:00 PM\n\nDetails: http://www.meetup.com/AngularJS-Edinburgh/events/141654792/", $event->getDescription());
     $this->assertEquals('http://www.meetup.com/AngularJS-Edinburgh/events/141654792/', $event->getURL());
     $this->assertFalse($event->getIsDeleted());
 }
コード例 #16
0
 function test1()
 {
     \TimeSource::mock(2014, 1, 1, 0, 0, 0);
     $this->addCountriesToTestDB();
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     $venue1 = new VenueModel();
     $venue1->setTitle("test");
     $venue1->setDescription("test test");
     $venue1->setCountryId($gb->getId());
     $venue2 = new VenueModel();
     $venue2->setTitle("test this looks similar");
     $venue2->setDescription("test test");
     $venue2->setCountryId($gb->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue1, $site, $user);
     $venueRepo->create($venue2, $site, $user);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0));
     $event->setVenueId($venue2->getId());
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     // Test before
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($venue2->getId(), $event->getVenueId());
     $venue2 = $venueRepo->loadById($venue2->getId());
     $this->assertFalse($venue2->getIsDeleted());
     $this->assertNull($venue2->getIsDuplicateOfId());
     // Mark
     \TimeSource::mock(2014, 1, 1, 2, 0, 0);
     $venueRepo->markDuplicate($venue2, $venue1, $user);
     // Test Duplicate
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $this->assertEquals($venue1->getId(), $event->getVenueId());
     $venue2 = $venueRepo->loadById($venue2->getId());
     $this->assertTrue($venue2->getIsDeleted());
     $this->assertEquals($venue1->getId(), $venue2->getIsDuplicateOfId());
 }
 function testEventAndNotEvent1()
 {
     TimeSource::mock(2013, 7, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2013, 8, 1, 19, 0, 0));
     $event->setEndAt(getUTCDateTime(2013, 8, 1, 21, 0, 0));
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     ## Test event not in group
     $grb = new GroupRepositoryBuilder();
     $grb->setEvent($event);
     $this->assertEquals(0, count($grb->fetchAll()));
     $grb = new GroupRepositoryBuilder();
     $grb->setNotEvent($event);
     $this->assertEquals(1, count($grb->fetchAll()));
     ## Add event to group, test
     $groupRepo->addEventToGroup($event, $group, $user);
     $grb = new GroupRepositoryBuilder();
     $grb->setEvent($event);
     $this->assertEquals(1, count($grb->fetchAll()));
     $grb = new GroupRepositoryBuilder();
     $grb->setNotEvent($event);
     $this->assertEquals(0, count($grb->fetchAll()));
     ## remove event from group
     $groupRepo->removeEventFromGroup($event, $group, $user);
     $grb = new GroupRepositoryBuilder();
     $grb->setEvent($event);
     $this->assertEquals(0, count($grb->fetchAll()));
     $grb = new GroupRepositoryBuilder();
     $grb->setNotEvent($event);
     $this->assertEquals(1, count($grb->fetchAll()));
 }
コード例 #18
0
 function testLoadEventJustBeforeEdit()
 {
     \TimeSource::mock(2014, 1, 1, 1, 1, 1);
     $this->addCountriesToTestDB();
     $countryRepo = new CountryRepository();
     $userRepo = new UserAccountRepository();
     $siteRepo = new SiteRepository();
     $eventRepo = new EventRepository();
     $eventHistoryRepo = new EventHistoryRepository();
     #### Setup
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo->create($site, $user, array($countryRepo->loadByTwoCharCode('GB')), $this->getSiteQuotaUsedForTesting());
     #### Create Event
     \TimeSource::mock(2014, 1, 1, 1, 2, 1);
     $event = new EventModel();
     $event->setSummary("Cats");
     $event->setDescription("Go Miaow");
     $event->setStartAt(getUTCDateTime(2014, 1, 10, 9, 0, 0));
     $event->setEndAt(getUTCDateTime(2014, 1, 10, 17, 0, 0));
     $eventRepo->create($event, $site, $user);
     #### Edit Event
     \TimeSource::mock(2014, 1, 1, 1, 3, 1);
     $event = $eventRepo->loadBySlug($site, $event->getSlug());
     $event->setSummary("Lizards");
     $event->setDescription("Go ?");
     $eventRepo->edit($event, $user);
     #### Edit Event
     \TimeSource::mock(2014, 1, 1, 1, 4, 1);
     $event = $eventRepo->loadBySlug($site, $event->getSlug());
     $event->setSummary("Dogs");
     $event->setDescription("Go Woof");
     $eventRepo->edit($event, $user);
     #### test: Load Current State
     \TimeSource::mock(2014, 1, 1, 1, 5, 1);
     $event = $eventRepo->loadBySlug($site, $event->getSlug());
     $this->assertEquals("Dogs", $event->getSummary());
     $this->assertEquals("Go Woof", $event->getDescription());
     #### test: load state before last edit
     \TimeSource::mock(2014, 1, 1, 1, 6, 1);
     $history = $eventHistoryRepo->loadByEventAndlastEditByUser($event, $user);
     $event = $eventRepo->loadEventJustBeforeEdit($event, $history);
     $this->assertEquals("Lizards", $event->getSummary());
     $this->assertEquals("Go ?", $event->getDescription());
 }
コード例 #19
0
 function test1()
 {
     $this->addCountriesToTestDB();
     $countryRepo = new CountryRepository();
     $areaRepo = new AreaRepository();
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array($countryRepo->loadByTwoCharCode('GB')), $this->getSiteQuotaUsedForTesting());
     ### No areas
     $this->assertFalse($areaRepo->doesCountryHaveAnyNotDeletedAreas($site, $countryRepo->loadByTwoCharCode('GB')));
     ### Area 1
     $area = new AreaModel();
     $area->setTitle("test");
     $area->setDescription("test test");
     $areaRepo->create($area, null, $site, $countryRepo->loadByTwoCharCode('GB'), $user);
     $areaRepo->buildCacheAreaHasParent($area);
     $this->checkAreaInTest1($areaRepo->loadById($area->getId()));
     $this->checkAreaInTest1($areaRepo->loadBySlug($site, $area->getSlug()));
     // no parents. Cache should be empty.
     $stat = $this->app['db']->prepare("SELECT * FROM cached_area_has_parent");
     $stat->execute();
     $this->assertEquals(0, $stat->rowCount());
     $this->assertTrue($areaRepo->doesCountryHaveAnyNotDeletedAreas($site, $countryRepo->loadByTwoCharCode('GB')));
     ### Area child
     $areaChild = new AreaModel();
     $areaChild->setTitle("test child");
     $areaChild->setDescription("test test child");
     $areaRepo->create($areaChild, $area, $site, $countryRepo->loadByTwoCharCode('GB'), $user);
     $areaRepo->buildCacheAreaHasParent($areaChild);
     // calling this multiple times should not crash
     $areaRepo->buildCacheAreaHasParent($areaChild);
     $areaRepo->buildCacheAreaHasParent($areaChild);
     $areaRepo->buildCacheAreaHasParent($areaChild);
     $areaRepo->buildCacheAreaHasParent($areaChild);
     $this->checkChildAreaInTest1($areaRepo->loadById($areaChild->getId()));
     $this->checkChildAreaInTest1($areaRepo->loadBySlug($site, $areaChild->getSlug()));
     // Check Cache
     $stat = $this->app['db']->prepare("SELECT * FROM cached_area_has_parent WHERE area_id=" . $areaChild->getId() . " AND has_parent_area_id=" . $area->getId());
     $stat->execute();
     $this->assertEquals(1, $stat->rowCount());
 }
コード例 #20
0
 function testMultiple()
 {
     TimeSource::mock(2013, 7, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupDupe = new GroupModel();
     $groupDupe->setTitle("test DUPE");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $groupRepo->create($groupDupe, $site, $user);
     TimeSource::mock(2013, 7, 1, 7, 1, 0);
     $groupRepo->markDuplicate($groupDupe, $group);
     $ufgr = new UserWatchesGroupRepository();
     $ufgr->startUserWatchingGroupIdIfNotWatchedBefore($user, $group->getId());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2013, 8, 1, 19, 0, 0));
     $event->setEndAt(getUTCDateTime(2013, 8, 1, 21, 0, 0));
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user, $group);
     ## TEST
     $this->assertNotNull($groupRepo->loadById($group->getId()));
     $groupRB = new GroupRepositoryBuilder();
     $groupRB->setEvent($event);
     $groups = $groupRB->fetchAll();
     $this->assertEquals(1, count($groups));
     ## PURGE!
     $groupRepo->purge($group);
     ## TEST
     $this->assertNull($groupRepo->loadById($group->getId()));
     $groupRB = new GroupRepositoryBuilder();
     $groupRB->setEvent($event);
     $groups = $groupRB->fetchAll();
     $this->assertEquals(0, count($groups));
 }
コード例 #21
0
 function test1()
 {
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $this->checkSiteInTest1($siteRepo->loadBySlug("test"));
 }
コード例 #22
0
 function testEventsVanish()
 {
     ## User, Site, Event
     \TimeSource::mock(2014, 1, 1, 1, 2, 3);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0, 'Europe/London'));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0, 'Europe/London'));
     $event->setUrl("http://www.info.com");
     $event->setTicketUrl("http://www.tickets.com");
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     ## Event can be found
     $erb = new EventRepositoryBuilder();
     $erb->setIncludeEventsFromClosedSites(true);
     $erb->fetchAll();
     $this->assertEquals(1, count($erb->fetchAll()));
     $erb = new EventRepositoryBuilder();
     $erb->setIncludeEventsFromClosedSites(false);
     $erb->fetchAll();
     $this->assertEquals(1, count($erb->fetchAll()));
     ## Close Site
     \TimeSource::mock(2014, 2, 1, 1, 2, 3);
     $site->setIsClosedBySysAdmin(true);
     $site->setClosedBySysAdminreason('Testing');
     $siteRepo->edit($site, $user);
     ## Event can not be found
     $erb = new EventRepositoryBuilder();
     $erb->setIncludeEventsFromClosedSites(true);
     $erb->fetchAll();
     $this->assertEquals(1, count($erb->fetchAll()));
     $erb = new EventRepositoryBuilder();
     $erb->setIncludeEventsFromClosedSites(false);
     $erb->fetchAll();
     $this->assertEquals(0, count($erb->fetchAll()));
 }
 function testStartRefusedThenGrantPermissionIsWriteCalendar()
 {
     $userAdmin = new UserAccountModel();
     $userAdmin->setEmail("*****@*****.**");
     $userAdmin->setUsername("admin");
     $userAdmin->setPassword("password");
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($userAdmin);
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $userAdmin, array(), $this->getSiteQuotaUsedForTesting());
     $api2appRepo = new API2ApplicationRepository();
     $api2app = $api2appRepo->create($userAdmin, "Title");
     $userInApi2AppRepo = new UserInAPI2ApplicationRepository();
     #### Initial Set
     $permissions = new API2ApplicationUserPermissionsModel();
     // no permissions at all ....
     $userInApi2AppRepo->setPermissionsForUserInApp($permissions, $user, $api2app);
     #### Test
     $userInApp = $userInApi2AppRepo->loadByUserAndApplication($user, $api2app);
     $this->assertEquals(false, $userInApp->getIsEditor());
     #### This should do nothing
     $permissions = new API2ApplicationUserPermissionsModel();
     $userInApi2AppRepo->setPermissionsForUserInApp($permissions, $user, $api2app);
     #### Test
     $userInApp = $userInApi2AppRepo->loadByUserAndApplication($user, $api2app);
     $this->assertEquals(false, $userInApp->getIsEditor());
     #### Then Remove
     $permissions = new API2ApplicationUserPermissionsModel();
     $permissions->setIsEditorGranted();
     $userInApi2AppRepo->setPermissionsForUserInApp($permissions, $user, $api2app);
     #### Test
     $userInApp = $userInApi2AppRepo->loadByUserAndApplication($user, $api2app);
     $this->assertEquals(true, $userInApp->getIsEditor());
     #### This should do nothing
     $permissions = new API2ApplicationUserPermissionsModel();
     $userInApi2AppRepo->setPermissionsForUserInApp($permissions, $user, $api2app);
     #### Test
     $userInApp = $userInApi2AppRepo->loadByUserAndApplication($user, $api2app);
     $this->assertEquals(true, $userInApp->getIsEditor());
 }
コード例 #24
0
 function test1()
 {
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userOther = new UserAccountModel();
     $userOther->setEmail("*****@*****.**");
     $userOther->setUsername("test2");
     $userOther->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $userRepo->create($userOther);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0, 'Europe/London'));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0, 'Europe/London'));
     $event->setUrl("http://www.info.com");
     $event->setTicketUrl("http://www.tickets.com");
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     $curatedList = new CuratedListModel();
     $curatedList->setTitle("test");
     $curatedList->setDescription("test this!");
     $clRepo = new CuratedListRepository();
     $clRepo->create($curatedList, $site, $user);
     $clRepo->addEditorToCuratedList($userOther, $curatedList, $user);
     $clRepo->addEventtoCuratedList($event, $curatedList, $user);
     $clRepo->addGroupToCuratedList($group, $curatedList, $user);
     ## Test
     $this->assertNotNull($clRepo->loadBySlug($site, $curatedList->getSlug()));
     ## Purge!
     $clRepo->purge($curatedList);
     ## Test
     $this->assertNull($clRepo->loadBySlug($site, $curatedList->getSlug()));
 }
 /**
  * @dataProvider dataForTest1
  */
 function test1($emailOption, $goingOption, $result)
 {
     TimeSource::mock(2013, 8, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt($this->mktime(2013, 8, 2, 19, 0, 0));
     $event->setEndAt($this->mktime(2013, 8, 2, 21, 0, 0));
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     $user->setEmailUpcomingEventsDaysNotice(1);
     $user->setEmailUpcomingEvents($emailOption);
     $userRepo->editEmailsOptions($user);
     if ($goingOption == 'a') {
         $userAtEvent = new UserAtEventModel();
         $userAtEvent->setUserAccountId($user->getId());
         $userAtEvent->setEventId($event->getId());
         $userAtEvent->setIsPlanAttending(true);
         $uaeRepo = new UserAtEventRepository();
         $uaeRepo->save($userAtEvent);
     } else {
         if ($goingOption == 'm') {
             $userAtEvent = new UserAtEventModel();
             $userAtEvent->setUserAccountId($user->getId());
             $userAtEvent->setEventId($event->getId());
             $userAtEvent->setIsPlanMaybeAttending(true);
             $uaeRepo = new UserAtEventRepository();
             $uaeRepo->save($userAtEvent);
         }
     }
     list($upcomingEvents, $allEvents, $userAtEvent, $flag) = $user->getDataForUpcomingEventsEmail();
     $this->assertEquals($result, $flag);
 }
コード例 #26
0
 function test1()
 {
     $userOwner = new UserAccountModel();
     $userOwner->setEmail("*****@*****.**");
     $userOwner->setUsername("test2");
     $userOwner->setPassword("password");
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $userRepo->create($userOwner);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $userOwner, array(), $this->getSiteQuotaUsedForTesting());
     $userWatchesSiteRepo = new UserWatchesSiteRepository();
     # Part 1: User does not watch site
     $t = $userWatchesSiteRepo->loadByUserAndSite($user, $site);
     $this->assertNull($t);
     $b = new UserWatchesSiteRepositoryBuilder();
     $t = $b->fetchAll();
     $this->assertEquals(1, count($t));
     # Part 2: Watches!
     $userWatchesSiteRepo->startUserWatchingSite($user, $site);
     $t = $userWatchesSiteRepo->loadByUserAndSite($user, $site);
     $this->assertEquals($user->getId(), $t->getUserAccountId());
     $this->assertEquals(true, $t->getIsWatching());
     $this->assertEquals(true, $t->getIsWasOnceWatching());
     $b = new UserWatchesSiteRepositoryBuilder();
     $t = $b->fetchAll();
     $this->assertEquals(2, count($t));
     # Part 3: Stops Watching!
     $userWatchesSiteRepo->stopUserWatchingSite($user, $site);
     $t = $userWatchesSiteRepo->loadByUserAndSite($user, $site);
     $this->assertEquals(false, $t->getIsWatching());
     $this->assertEquals(true, $t->getIsWasOnceWatching());
     $b = new UserWatchesSiteRepositoryBuilder();
     $t = $b->fetchAll();
     $this->assertEquals(1, count($t));
 }
 function testFreeTextSearch()
 {
     TimeSource::mock(2014, 5, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0, 'Europe/London'));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0, 'Europe/London'));
     $event->setUrl("http://www.info.com");
     $event->setTicketUrl("http://www.tickets.com");
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     ///////////// Test No Search
     $erb = new EventRepositoryBuilder();
     $this->assertEquals(1, count($erb->fetchAll()));
     $erb = new EventRepositoryBuilder();
     $this->assertEquals(1, $erb->fetchCount());
     ///////////// Test Search Pass
     $erb = new EventRepositoryBuilder();
     $erb->setFreeTextsearch("test");
     $this->assertEquals(1, count($erb->fetchAll()));
     $erb = new EventRepositoryBuilder();
     $erb->setFreeTextsearch("test");
     $this->assertEquals(1, $erb->fetchCount());
     ///////////// Test Search Fail
     $erb = new EventRepositoryBuilder();
     $erb->setFreeTextsearch("eodueoth dlhtunkn ethh5f 8l79,35dheutn");
     $this->assertEquals(0, count($erb->fetchAll()));
     $erb = new EventRepositoryBuilder();
     $erb->setFreeTextsearch("eodueoth dlhtunkn ethh5f 8l79,35dheutn");
     $this->assertEquals(0, $erb->fetchCount());
 }
 function testAcrossBST1()
 {
     \TimeSource::mock(2015, 5, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setTimezone('Europe/London');
     $start = new \DateTime("", new \DateTimeZone('Europe/London'));
     $start->setDate(2015, 5, 10);
     $start->setTime(19, 0, 0);
     $event->setStartAt($start);
     $end = new \DateTime("", new \DateTimeZone('Europe/London'));
     $end->setDate(2015, 5, 10);
     $end->setTime(21, 0, 0);
     $event->setEndAt($end);
     $event->setUrl("http://www.info.com");
     $event->setTicketUrl("http://www.tickets.com");
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     $event = $eventRepository->loadBySlug($site, $event->getSlug());
     $eventRecurSetRepository = new EventRecurSetRepository();
     $eventRecurSet = $eventRecurSetRepository->getForEvent($event);
     $eventRecurSet->setTimeZoneName($event->getTimezone());
     $newStart = new \DateTime();
     $newStart->setDate(2015, 11, 1);
     $newEvent = $eventRecurSet->getNewEventOnArbitraryDate($event, $newStart);
     // What we are really testing here is start and end times set correctly
     $this->assertEquals("2015-11-01T19:00:00+00:00", $newEvent->getStartAtInUTC()->format("c"));
     $this->assertEquals("2015-11-01T21:00:00+00:00", $newEvent->getEndAtInUTC()->format("c"));
     $this->assertEquals("2015-11-01T19:00:00+00:00", $newEvent->getStartAtInTimezone()->format("c"));
     $this->assertEquals("2015-11-01T21:00:00+00:00", $newEvent->getEndAtInTimezone()->format("c"));
 }
コード例 #29
0
 function test1()
 {
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $group = new GroupModel();
     $group->setTitle("test");
     $group->setDescription("test test");
     $group->setUrl("http://www.group.com");
     $groupRepo = new GroupRepository();
     $groupRepo->create($group, $site, $user);
     $importURLRepository = new ImportURLRepository();
     $newImportURL = new ImportURLModel();
     $newImportURL->setIsEnabled(true);
     $newImportURL->setSiteId($site->getId());
     $newImportURL->setGroupId($group->getId());
     $newImportURL->setTitle("Test");
     $newImportURL->setUrl("http://test.com");
     # no clash
     $clash = $importURLRepository->loadClashForImportUrl($newImportURL);
     $this->assertNull($clash);
     # save import, now clash!
     $importURLRepository->create($newImportURL, $site, $user);
     $newImportURL2 = new ImportURLModel();
     $newImportURL2->setIsEnabled(true);
     $newImportURL2->setSiteId($site->getId());
     $newImportURL2->setGroupId($group->getId());
     $newImportURL2->setTitle("Test.com site");
     $newImportURL2->setUrl("http://TEST.com");
     # no clash
     $clash = $importURLRepository->loadClashForImportUrl($newImportURL2);
     $this->assertTrue($clash != null);
 }
コード例 #30
0
 function test1()
 {
     TimeSource::mock(2014, 5, 1, 7, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $event = new EventModel();
     $event->setSummary("test");
     $event->setDescription("test test");
     $event->setStartAt(getUTCDateTime(2014, 5, 10, 19, 0, 0, 'Europe/London'));
     $event->setEndAt(getUTCDateTime(2014, 5, 10, 21, 0, 0, 'Europe/London'));
     $event->setUrl("http://www.info.com");
     $event->setTicketUrl("http://www.tickets.com");
     $eventRepository = new EventRepository();
     $eventRepository->create($event, $site, $user);
     $tag = new TagModel();
     $tag->setTitle("Test");
     $tagRepo = new TagRepository();
     $tagRepo->create($tag, $site, $user);
     $tagRepo->addTagToEvent($tag, $event, $user);
     ## Test
     $this->assertNotNull($tagRepo->loadById($tag->getId()));
     $tagRepoBuilder = new repositories\builders\TagRepositoryBuilder();
     $tagRepoBuilder->setTagsForEvent($event);
     $this->assertEquals(1, count($tagRepoBuilder->fetchAll()));
     ## Purge!
     $tagRepo->purge($tag);
     ## Test
     $this->assertNull($tagRepo->loadById($tag->getId()));
     $tagRepoBuilder = new repositories\builders\TagRepositoryBuilder();
     $tagRepoBuilder->setTagsForEvent($event);
     $this->assertEquals(0, count($tagRepoBuilder->fetchAll()));
 }