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())); }
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())); }
public function setFeature(SiteModel $site, \BaseSiteFeature $siteFeature, $value, UserAccountModel $userAccountModel = null) { try { $this->app['db']->beginTransaction(); $changeMade = false; $stat = $this->app['db']->prepare("SELECT is_on FROM site_feature_information WHERE site_id=:site_id AND extension_id =:extension_id AND feature_id =:feature_id"); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId())); if ($stat->rowCount() == 1) { $data = $stat->fetch(); if ($data['is_on'] != $value) { $stat = $this->app['db']->prepare("UPDATE site_feature_information SET is_on=:is_on " . " WHERE site_id=:site_id AND extension_id =:extension_id AND feature_id =:feature_id "); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0)); $changeMade = true; } } else { $stat = $this->app['db']->prepare("INSERT INTO site_feature_information (site_id, extension_id, feature_id, is_on) " . " VALUES(:site_id, :extension_id, :feature_id, :is_on) "); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0)); $changeMade = true; } if ($changeMade) { $stat = $this->app['db']->prepare("INSERT INTO site_feature_history (site_id, extension_id, feature_id, is_on, user_account_id, created_at) " . " VALUES (:site_id, :extension_id, :feature_id, :is_on, :user_account_id, :created_at)"); $stat->execute(array('site_id' => $site->getId(), 'extension_id' => $siteFeature->getExtensionId(), 'feature_id' => $siteFeature->getFeatureId(), 'is_on' => $value ? 1 : 0, 'user_account_id' => $userAccountModel ? $userAccountModel->getId() : null, 'created_at' => \TimeSource::getFormattedForDataBase())); } $this->app['db']->commit(); } catch (Exception $e) { $this->app['db']->rollBack(); } }
protected function build() { $this->select = array('group_information.*'); if ($this->site) { $this->where[] = " group_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->event) { $this->joins[] = " JOIN event_in_group AS event_in_group ON event_in_group.group_id = group_information.id " . "AND event_in_group.removed_at IS NULL AND event_in_group.event_id = :event_id "; $this->params['event_id'] = $this->event->getId(); } else { if ($this->notEvent) { $this->joins[] = " LEFT JOIN event_in_group AS event_in_group ON event_in_group.group_id = group_information.id " . "AND event_in_group.removed_at IS NULL AND event_in_group.event_id = :event_id "; $this->params['event_id'] = $this->notEvent->getId(); $this->where[] = ' event_in_group.event_id IS NULL '; } } if ($this->freeTextSearch) { $this->where[] = '(CASE WHEN group_information.title IS NULL THEN \'\' ELSE group_information.title END ) || \' \' || ' . '(CASE WHEN group_information.description IS NULL THEN \'\' ELSE group_information.description END )' . ' ILIKE :free_text_search '; $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%"; } if (!$this->include_deleted) { $this->where[] = " group_information.is_deleted = '0' "; } if ($this->includeMediasSlugs) { $this->select[] = " (SELECT array_to_string(array_agg(media_information.slug), ',') FROM media_information " . " JOIN media_in_group ON media_information.id = media_in_group.media_id " . " WHERE media_information.deleted_at IS NULL AND media_information.is_file_lost='0' " . " AND media_in_group.removal_approved_at IS NULL AND media_in_group.group_id = group_information.id " . " GROUP BY group_information.id ) AS media_group_slugs "; } if ($this->editedByUser) { $this->where[] = " group_information.id IN (SELECT group_id FROM group_history WHERE user_account_id = :editedByUser) "; $this->params['editedByUser'] = $this->editedByUser->getId(); } }
protected function build() { if ($this->site) { $this->where[] = " human_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->humansForEvent) { $this->joins[] = " JOIN event_has_human ON event_has_human.human_id = human_information.id AND event_has_human.event_id = :event_id AND event_has_human.removed_at IS NULL"; $this->params['event_id'] = $this->humansForEvent->getId(); } else { if ($this->humansNotForEvent) { $this->joins[] = " LEFT JOIN event_has_human ON event_has_human.human_id = human_information.id AND event_has_human.event_id = :event_id AND event_has_human.removed_at IS NULL"; $this->params['event_id'] = $this->humansNotForEvent->getId(); $this->where[] = ' event_has_human.event_id IS NULL '; } } if ($this->area) { // TODO direct areas only, should do child areas to. But not now. $this->joins[] = " JOIN human_in_area ON human_in_area.human_id = human_information.id AND human_in_area.area_id = :area_id AND human_in_area.removed_at IS NULL"; $this->params['area_id'] = $this->area->getId(); } if (!$this->include_deleted) { $this->where[] = " human_information.is_deleted = '0' "; } if ($this->freeTextSearch) { $this->where[] = '(CASE WHEN human_information.title IS NULL THEN \'\' ELSE human_information.title END ) || \' \' || ' . '(CASE WHEN human_information.description IS NULL THEN \'\' ELSE human_information.description END )' . ' ILIKE :free_text_search '; $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%"; } }
function testUserIsUserGroup() { $user = new UserAccountModel(); $user->setEmail("*****@*****.**"); $user->setUsername("test"); $user->setPassword("password"); $userTest = new UserAccountModel(); $userTest->setEmail("*****@*****.**"); $userTest->setUsername("testtest"); $userTest->setPassword("password"); $userRepo = new UserAccountRepository(); $userRepo->create($user); $userRepo->create($userTest); $site = new SiteModel(); $site->setTitle("Test"); $site->setSlug("test"); $siteRepo = new SiteRepository(); $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting()); $usrb = new \repositories\builders\UserGroupRepositoryBuilder(); $usrb->setSite($site); $userGroups = $usrb->fetchAll(); $this->assertTrue(count($userGroups) > 0); $userGroup = $userGroups[0]; $uiugr = new \repositories\UserGroupRepository(); $uiugr->addUserToGroup($userTest, $userGroup); // Test user in user group has it $srb = new \repositories\builders\SiteRepositoryBuilder(); $srb->setUserInterestedIn($userTest); $sites = $srb->fetchAll(); $this->assertEquals(1, count($sites)); }
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())); }
protected function build() { $this->select[] = 'area_information.*'; if ($this->site) { $this->where[] = " area_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->country) { $this->where[] = " area_information.country_id = :country_id "; $this->params['country_id'] = $this->country->getId(); } if (!$this->include_deleted) { $this->where[] = " area_information.is_deleted = '0' "; } if ($this->noParentArea) { $this->where[] = ' area_information.parent_area_id IS null '; } else { if ($this->parentArea) { $this->where[] = " area_information.parent_area_id = :parent_id "; $this->params['parent_id'] = $this->parentArea->getId(); } } if ($this->cacheNeedsBuildingOnly) { $this->where[] = " area_information.cache_area_has_parent_generated = '0'"; } if ($this->freeTextSearch) { $this->where[] = ' area_information.title ILIKE :free_text_search '; $this->params['free_text_search'] = "%" . strtolower($this->freeTextSearch) . "%"; } if ($this->include_parent_levels > 0) { $this->joins[] = " LEFT JOIN area_information AS area_information_parent_1 ON area_information.parent_area_id = area_information_parent_1.id "; $this->select[] = " area_information_parent_1.title AS parent_1_title"; } }
/** * */ 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()); }
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()); }
public function isCountryInSite(CountryModel $country, SiteModel $site) { global $DB; $stat = $DB->prepare("SELECT * FROM country_in_site_information WHERE site_id =:site_id AND country_id =:country_id AND is_in= '1'"); $stat->execute(array('country_id' => $country->getId(), 'site_id' => $site->getId())); return $stat->rowCount() == 1; }
public function isUserInSite(UserAccountModel $userAccountModel, SiteModel $siteModel) { global $DB; $stat = $DB->prepare("SELECT * FROM user_has_no_editor_permissions_in_site WHERE site_id=:site_id AND user_account_id=:user_account_id AND removed_at IS NULL"); $stat->execute(array("site_id" => $siteModel->getId(), "user_account_id" => $userAccountModel->getId())); return $stat->rowCount() > 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")); }
protected function build() { if ($this->site) { $this->where[] = " incoming_link.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } }
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())); }
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()); }
protected function build() { $this->select = array('new_event_draft_information.*'); if ($this->site) { $this->where[] = " new_event_draft_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } }
protected function build() { $this->select[] = 'event_custom_field_definition_information.*'; if ($this->site) { $this->where[] = " event_custom_field_definition_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } }
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()); }
protected function build() { if ($this->onlyCurrent) { $this->where[] = "user_watches_site_information.is_watching = '1'"; } if ($this->site) { $this->where[] = " user_watches_site_information.site_id = :site_id"; $this->params['site_id'] = $this->site->getId(); } }
protected function build() { if ($this->site) { $this->where[] = " send_email_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->userCreatedBy) { $this->where[] = " send_email_information.created_by = :created_by "; $this->params['created_by'] = $this->userCreatedBy->getId(); } }
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()); }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT import_url_information.* FROM import_url_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $iurl = new ImportURLModel(); $iurl->setFromDataBaseRow($stat->fetch()); return $iurl; } }
public function loadBySlugForSite($slug, SiteModel $siteModel) { global $DB; $stat = $DB->prepare("SELECT new_event_draft_information.* FROM new_event_draft_information " . " WHERE new_event_draft_information.slug =:slug AND new_event_draft_information.site_id = :site_id "); $stat->execute(array('slug' => $slug, 'site_id' => $siteModel->getId())); if ($stat->rowCount() > 0) { $event = new NewEventDraftModel(); $event->setFromDataBaseRow($stat->fetch()); return $event; } }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT curated_list_information.* FROM curated_list_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $clist = new CuratedListModel(); $clist->setFromDataBaseRow($stat->fetch()); return $clist; } }
/** * This will return one country only. It is intended for sites with one country only. **/ public function loadBySite(SiteModel $site) { global $DB; $stat = $DB->prepare("SELECT country.* FROM country " . " JOIN country_in_site_information ON country_in_site_information.country_id = country.id AND country_in_site_information.is_in = '1' " . " WHERE country_in_site_information.site_id=:id "); $stat->execute(array('id' => $site->getId())); if ($stat->rowCount() > 0) { $country = new CountryModel(); $country->setFromDataBaseRow($stat->fetch()); return $country; } }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT human_information.* FROM human_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $human = new HumanModel(); $human->setFromDataBaseRow($stat->fetch()); return $human; } }
protected function build() { if ($this->site) { $this->where[] = " import_url_information.site_id = :site_id "; $this->params['site_id'] = $this->site->getId(); } if ($this->group) { $this->where[] = " import_url_information.group_id = :group_id "; $this->params['group_id'] = $this->group->getId(); } }
public function loadBySlug(SiteModel $site, $slug) { global $DB; $stat = $DB->prepare("SELECT send_email_information.* FROM send_email_information WHERE slug =:slug AND site_id =:sid"); $stat->execute(array('sid' => $site->getId(), 'slug' => $slug)); if ($stat->rowCount() > 0) { $sem = new SendEmailModel(); $sem->setFromDataBaseRow($stat->fetch()); return $sem; } }