From ddc0a955e26fbb35ddb29ace923e671b526da3af Mon Sep 17 00:00:00 2001 From: Sebastian Marcet Date: Tue, 28 Nov 2017 14:29:47 -0300 Subject: [PATCH] Fixed postEvent and publishEvent Endpoints Change-Id: I9d9d5ddc9720cf46f94de9a5bcd20abd376bd660 --- .../Summit/OAuth2SummitApiController.php | 2 +- .../PresentationTypeSerializer.php | 46 ++++ app/ModelSerializers/SerializerRegistry.php | 1 + .../SummitEventTypeSerializer.php | 17 +- app/ModelSerializers/SummitSerializer.php | 50 +++++ .../Summit/Events/ISummitEventType.php | 4 + .../Presentations/IPresentationType.php | 22 ++ .../Events/Presentations/PresentationType.php | 202 ++++++++++++++++++ .../Summit/Events/SummitEventType.php | 87 +++++--- .../Summit/Factories/SummitEventFactory.php | 15 +- app/Models/Utils/SilverstripeBaseModel.php | 8 + app/Services/Model/SummitService.php | 154 ++++++------- tests/OAuth2SummitApiTest.php | 40 ++-- 13 files changed, 521 insertions(+), 127 deletions(-) create mode 100644 app/ModelSerializers/PresentationTypeSerializer.php create mode 100644 app/Models/Foundation/Summit/Events/Presentations/IPresentationType.php create mode 100644 app/Models/Foundation/Summit/Events/Presentations/PresentationType.php diff --git a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php index 127961d9..a112feaf 100644 --- a/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php +++ b/app/Http/Controllers/Apis/Protected/Summit/OAuth2SummitApiController.php @@ -108,7 +108,7 @@ final class OAuth2SummitApiController extends OAuth2ProtectedController $summits = []; foreach($this->repository->getAllOrderedByBeginDate() as $summit){ - $summits[] = SerializerRegistry::getInstance()->getSerializer($summit)->serialize(); + $summits[] = SerializerRegistry::getInstance()->getSerializer($summit)->serialize(Input::get('expand','')); } $response = new PagingResponse diff --git a/app/ModelSerializers/PresentationTypeSerializer.php b/app/ModelSerializers/PresentationTypeSerializer.php new file mode 100644 index 00000000..20ce1cbc --- /dev/null +++ b/app/ModelSerializers/PresentationTypeSerializer.php @@ -0,0 +1,46 @@ + 'max_speakers:json_int', + 'MinSpeakers' => 'min_speakers:json_int', + 'MaxModerators' => 'max_moderators:json_int', + 'MinModerators' => 'min_moderators:json_int', + 'UseSpeakers' => 'use_speakers:json_boolean', + 'AreSpeakersMandatory' => 'are_speakers_mandatory:json_boolean', + 'UseModerator' => 'use_moderator:json_boolean', + 'ModeratorMandatory' => 'moderator_mandatory:json_boolean', + 'ModeratorLabel' => 'moderator_label:json_string', + ); + + /** + * @param null $expand + * @param array $fields + * @param array $relations + * @param array $params + * @return array + */ + public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() ) + { + $values = parent::serialize($expand, $fields, $relations, $params); + return $values; + } +} \ No newline at end of file diff --git a/app/ModelSerializers/SerializerRegistry.php b/app/ModelSerializers/SerializerRegistry.php index c2afda02..c1946add 100644 --- a/app/ModelSerializers/SerializerRegistry.php +++ b/app/ModelSerializers/SerializerRegistry.php @@ -81,6 +81,7 @@ final class SerializerRegistry $this->registry['SummitWIFIConnection'] = SummitWIFIConnectionSerializer::class; $this->registry['SummitType'] = SummitTypeSerializer::class; $this->registry['SummitEventType'] = SummitEventTypeSerializer::class; + $this->registry['PresentationType'] = PresentationTypeSerializer::class; $this->registry['SummitTicketType'] = SummitTicketTypeSerializer::class; $this->registry['PresentationCategory'] = PresentationCategorySerializer::class; $this->registry['PresentationCategoryGroup'] = PresentationCategoryGroupSerializer::class; diff --git a/app/ModelSerializers/SummitEventTypeSerializer.php b/app/ModelSerializers/SummitEventTypeSerializer.php index 9072fe93..46975c12 100644 --- a/app/ModelSerializers/SummitEventTypeSerializer.php +++ b/app/ModelSerializers/SummitEventTypeSerializer.php @@ -16,14 +16,17 @@ * Class SummitEventTypeSerializer * @package ModelSerializers */ -final class SummitEventTypeSerializer extends SilverStripeSerializer +class SummitEventTypeSerializer extends SilverStripeSerializer { - protected static $array_mappings = array - ( - 'Type' => 'name:json_string', - 'Color' => 'color:json_string', - 'BlackoutTimes' => 'black_out_times:json_boolean', - ); + protected static $array_mappings = [ + 'Type' => 'name:json_string', + 'ClassName' => 'class_name:json_string', + 'Color' => 'color:json_string', + 'BlackoutTimes' => 'black_out_times:json_boolean', + 'UseSponsors' => 'use_sponsors:json_boolean', + 'AreSponsorsMandatory' => 'are_sponsors_mandatory:json_boolean', + 'AllowsAttachment' => 'allows_attachment:json_boolean', + ]; /** * @param null $expand diff --git a/app/ModelSerializers/SummitSerializer.php b/app/ModelSerializers/SummitSerializer.php index 18cfbded..6aa1d5ee 100644 --- a/app/ModelSerializers/SummitSerializer.php +++ b/app/ModelSerializers/SummitSerializer.php @@ -119,6 +119,56 @@ final class SummitSerializer extends SilverStripeSerializer $expand = explode(',', $expand); foreach ($expand as $relation) { switch (trim($relation)) { + case 'event_types':{ + $event_types = []; + foreach ($summit->getEventTypes() as $event_type) { + $event_types[] = SerializerRegistry::getInstance()->getSerializer($event_type)->serialize(); + } + $values['event_types'] = $event_types; + } + break; + case 'tracks':{ + $presentation_categories = array(); + foreach ($summit->getPresentationCategories() as $cat) { + $presentation_categories[] = SerializerRegistry::getInstance()->getSerializer($cat)->serialize(); + } + $values['tracks'] = $presentation_categories; + } + break; + case 'track_groups':{ + // track_groups + $track_groups = array(); + foreach ($summit->getCategoryGroups() as $group) { + $track_groups[] = SerializerRegistry::getInstance()->getSerializer($group)->serialize(); + } + $values['track_groups'] = $track_groups; + } + break; + case 'sponsors':{ + $sponsors = array(); + foreach ($summit->getSponsors() as $company) { + $sponsors[] = SerializerRegistry::getInstance()->getSerializer($company)->serialize(); + } + $values['sponsors'] = $sponsors; + } + break; + case 'speakers':{ + $speakers = array(); + foreach ($summit->getSpeakers() as $speaker) { + $speakers[] = + SerializerRegistry::getInstance()->getSerializer($speaker)->serialize + ( + null, [], [], + [ + 'summit_id' => $summit->getId(), + 'published' => true + ] + ); + + } + $values['speakers'] = $speakers; + } + break; case 'schedule': { $event_types = array(); foreach ($summit->getEventTypes() as $event_type) { diff --git a/app/Models/Foundation/Summit/Events/ISummitEventType.php b/app/Models/Foundation/Summit/Events/ISummitEventType.php index a6d29bd6..160915f1 100644 --- a/app/Models/Foundation/Summit/Events/ISummitEventType.php +++ b/app/Models/Foundation/Summit/Events/ISummitEventType.php @@ -27,4 +27,8 @@ interface ISummitEventType const EveningEvents = 'Evening Events'; const GroupsEvents = 'Groups Events'; + + const Lunch = 'Lunch'; + + const Breaks = 'Breaks'; } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/Presentations/IPresentationType.php b/app/Models/Foundation/Summit/Events/Presentations/IPresentationType.php new file mode 100644 index 00000000..86d593f2 --- /dev/null +++ b/app/Models/Foundation/Summit/Events/Presentations/IPresentationType.php @@ -0,0 +1,22 @@ +execute(['summit_id' => $summit->getId(), 'type' => $type]); + $res = $stmt->fetchAll(\PDO::FETCH_COLUMN); + return count($res) > 0 ; + } + catch (\Exception $ex){ + + } + return false; + } + + /** + * @return array() + */ + static public function presentationTypes(){ + return [IPresentationType::Presentation, IPresentationType::Keynotes, IPresentationType::LightingTalks, IPresentationType::Panel]; + } + + /** + * @return int + */ + public function getMaxSpeakers() + { + return $this->max_speakers; + } + + /** + * @return int + */ + public function getMinSpeakers() + { + return $this->min_speakers; + } + + /** + * @return int + */ + public function getMaxModerators() + { + return $this->max_moderators; + } + + /** + * @return int + */ + public function getMinModerators() + { + return $this->min_moderators; + } + + /** + * @return bool + */ + public function isUseSpeakers() + { + return $this->use_speakers; + } + + /** + * @return bool + */ + public function isAreSpeakersMandatory() + { + return $this->are_speakers_mandatory; + } + + /** + * @return bool + */ + public function isUseModerator() + { + return $this->use_moderator; + } + + /** + * @return bool + */ + public function isModeratorMandatory() + { + return $this->is_moderator_mandatory; + } + + /** + * @return bool + */ + public function isShouldBeAvailableOnCfp() + { + return $this->should_be_available_on_cfp; + } + + /** + * @return string + */ + public function getModeratorLabel() + { + return $this->moderator_label; + } + + public function getClassName(){ + return 'PresentationType'; + } +} \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Events/SummitEventType.php b/app/Models/Foundation/Summit/Events/SummitEventType.php index 8b90bf01..7105552a 100644 --- a/app/Models/Foundation/Summit/Events/SummitEventType.php +++ b/app/Models/Foundation/Summit/Events/SummitEventType.php @@ -11,15 +11,15 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ - use models\utils\SilverstripeBaseModel; use Doctrine\ORM\Mapping AS ORM; /** * @ORM\Entity * @ORM\Table(name="SummitEventType") - * Class SummitEventType - * @package models\summit + * @ORM\InheritanceType("JOINED") + * @ORM\DiscriminatorColumn(name="ClassName", type="string") + * @ORM\DiscriminatorMap({"SummitEventType" = "SummitEventType", "PresentationType" = "PresentationType", "SummitGroupEvent" = "SummitGroupEvent", "SummitEventWithFile" = "SummitEventWithFile"}) */ class SummitEventType extends SilverstripeBaseModel { @@ -29,39 +29,37 @@ class SummitEventType extends SilverstripeBaseModel * @ORM\Column(name="Type", type="string") * @var string */ - private $type; + protected $type; /** * @ORM\Column(name="Color", type="string") * @var string */ - private $color; - - /** - * @ORM\Column(name="ClassName", type="string") - * @var string - */ - private $class_name; - - /** - * @return bool - */ - public function isPresentationType(){ - return $this->class_name === 'PresentationType'; - } - - /** - * @return bool - */ - public function allowsModerator(){ - return $this->isPresentationType() && in_array($this->type, ['Panel','Keynotes']); - } + protected $color; /** * @ORM\Column(name="BlackoutTimes", type="boolean") * @var bool */ - private $blackout_times; + protected $blackout_times; + + /** + * @ORM\Column(name="UseSponsors", type="boolean") + * @var bool + */ + protected $use_sponsors; + + /** + * @ORM\Column(name="AreSponsorsMandatory", type="boolean") + * @var bool + */ + protected $are_sponsors_mandatory; + + /** + * @ORM\Column(name="AllowsAttachment", type="boolean") + * @var bool + */ + protected $allows_attachment; /** * @return string @@ -127,4 +125,41 @@ class SummitEventType extends SilverstripeBaseModel return in_array($type, $private_types); } + /** + * @param Summit $summit + * @param string $type + * @return bool + */ + static public function IsSummitEventType(Summit $summit, $type){ + return !PresentationType::IsPresentationEventType($summit, $type); + } + + /** + * @return bool + */ + public function isUseSponsors() + { + return $this->use_sponsors; + } + + /** + * @return bool + */ + public function isAreSponsorsMandatory() + { + return $this->are_sponsors_mandatory; + } + + /** + * @return bool + */ + public function isAllowsAttachment() + { + return $this->allows_attachment; + } + + public function getClassName(){ + return 'SummitEventType'; + } + } \ No newline at end of file diff --git a/app/Models/Foundation/Summit/Factories/SummitEventFactory.php b/app/Models/Foundation/Summit/Factories/SummitEventFactory.php index 197bcaf6..798aad37 100644 --- a/app/Models/Foundation/Summit/Factories/SummitEventFactory.php +++ b/app/Models/Foundation/Summit/Factories/SummitEventFactory.php @@ -21,12 +21,23 @@ namespace models\summit; final class SummitEventFactory { /** + * @param Summit $summit * @param SummitEventType $type * @return SummitEvent */ - static public function build(SummitEventType $type) + static public function build(Summit $summit, SummitEventType $type) { - $event = in_array($type->getType(),[ 'Presentation', 'Keynotes' , 'Panel']) ? new Presentation: new SummitEvent; + $event = new SummitEvent(); + + if(PresentationType::IsPresentationEventType($summit, $type->getType())) + $event = new Presentation(); + + if(SummitEventType::isPrivate($type->getType())) + $event = new SummitGroupEvent(); + + if($type->isAllowsAttachment()) + $event = new SummitEventWithFile(); + return $event; } } \ No newline at end of file diff --git a/app/Models/Utils/SilverstripeBaseModel.php b/app/Models/Utils/SilverstripeBaseModel.php index 52776b38..e3a526a5 100644 --- a/app/Models/Utils/SilverstripeBaseModel.php +++ b/app/Models/Utils/SilverstripeBaseModel.php @@ -125,6 +125,14 @@ class SilverstripeBaseModel extends BaseEntity return Registry::getManager(self::EntityManager)->getConnection()->prepare($sql); } + /** + * @param string $sql + * @return mixed + */ + protected static function prepareRawSQLStatic($sql){ + return Registry::getManager(self::EntityManager)->getConnection()->prepare($sql); + } + /** * @return EntityManager */ diff --git a/app/Services/Model/SummitService.php b/app/Services/Model/SummitService.php index 23e57aad..b625709f 100644 --- a/app/Services/Model/SummitService.php +++ b/app/Services/Model/SummitService.php @@ -41,6 +41,8 @@ use models\summit\ISummitAttendeeRepository; use models\summit\ISummitAttendeeTicketRepository; use models\summit\ISummitEntityEventRepository; use models\summit\ISummitEventRepository; +use models\summit\Presentation; +use models\summit\PresentationType; use models\summit\Summit; use models\summit\SummitAttendee; use models\summit\SummitAttendeeTicket; @@ -63,7 +65,7 @@ final class SummitService implements ISummitService /** * minimun number of minutes that an event must last */ - const MIN_EVENT_MINUTES = 15; + const MIN_EVENT_MINUTES = 10; /** * @var ITransactionService */ @@ -485,6 +487,59 @@ final class SummitService implements ISummitService return $this->saveOrUpdateEvent($summit, $data, $event_id); } + /** + * @param array $data + * @param Summit $summit + * @param SummitEvent $event + * @return SummitEvent + * @throws ValidationException + */ + private function updateEventDates(array $data, Summit $summit, SummitEvent $event){ + + if (isset($data['start_date']) && isset($data['end_date'])) { + $event->setSummit($summit); + $summit_time_zone = $summit->getTimeZone(); + $start_datetime = intval($data['start_date']); + $start_datetime = new \DateTime("@$start_datetime", $summit_time_zone); + + $end_datetime = intval($data['end_date']); + $end_datetime = new \DateTime("@$end_datetime", $summit_time_zone); + + $interval_seconds = $end_datetime->getTimestamp() - $start_datetime->getTimestamp(); + $minutes = $interval_seconds / 60; + if ($minutes < self::MIN_EVENT_MINUTES) + throw new ValidationException + ( + sprintf + ( + "event should last at lest %s minutes - current duration %s", + self::MIN_EVENT_MINUTES, + $minutes + ) + ); + + // set local time from UTC + $event->setStartDate($start_datetime); + $event->setEndDate($end_datetime); + + if (!$summit->isEventInsideSummitDuration($event)) + throw new ValidationException + ( + sprintf + ( + "event start/end (%s - %s) does not match with summit start/end (%s - %s)", + $start_datetime->format('Y-m-d H:i:s'), + $end_datetime->format('Y-m-d H:i:s'), + $summit->getLocalBeginDate()->format('Y-m-d H:i:s'), + $summit->getLocalEndDate()->format('Y-m-d H:i:s') + ) + ); + } + + return $event; + + } + /** * @param Summit $summit * @param array $data @@ -493,35 +548,11 @@ final class SummitService implements ISummitService */ private function saveOrUpdateEvent(Summit $summit, array $data, $event_id = null) { - $event_repository = $this->event_repository; - return $this->tx_service->transaction(function () use ($summit, $data, $event_id, $event_repository) { - - $start_datetime = null; - $end_datetime = null; - - if (isset($data['start_date']) && isset($data['end_date'])) { - $start_datetime = intval($data['start_date']); - $start_datetime = new \DateTime("@$start_datetime"); - - $end_datetime = intval($data['end_date']); - $end_datetime = new \DateTime("@$end_datetime"); - - $interval_seconds = $end_datetime->getTimestamp() - $start_datetime->getTimestamp(); - $minutes = $interval_seconds / 60; - if ($minutes < self::MIN_EVENT_MINUTES) - throw new ValidationException - ( - sprintf - ( - "event should last at lest %s minutes - current duration %s", - self::MIN_EVENT_MINUTES, - $minutes - ) - ); - } + return $this->tx_service->transaction(function () use ($summit, $data, $event_id) { $event_type = null; + if (isset($data['type_id'])) { $event_type = $summit->getEventType(intval($data['type_id'])); if (is_null($event_type)) { @@ -547,9 +578,9 @@ final class SummitService implements ISummitService } if (is_null($event_id)) { - $event = SummitEventFactory::build($event_type); + $event = SummitEventFactory::build($summit, $event_type); } else { - $event = $event_repository->getById($event_id); + $event = $this->event_repository->getById($event_id); if (is_null($event)) throw new ValidationException(sprintf("event id %s does not exists!", $event_id)); $event_type = $event->getType(); @@ -581,7 +612,8 @@ final class SummitService implements ISummitService } // is event is new and we dont provide speakers ... - if(is_null($event_id) && !is_null($event_type) && $event_type->isPresentationType() && !isset($data['speakers'])) + if(is_null($event_id) && !is_null($event_type) && $event_type instanceof PresentationType + && $event_type->isAreSpeakersMandatory() && !isset($data['speakers'])) throw new ValidationException('speakers data is required for presentations!'); $event->setSummit($summit); @@ -589,25 +621,7 @@ final class SummitService implements ISummitService if (!is_null($location)) $event->setLocation($location); - // check start/end datetime with summit - if (!is_null($start_datetime) && !is_null($end_datetime)) { - // set local time from UTC - $event->setStartDate($start_datetime); - $event->setEndDate($end_datetime); - - if (!$summit->isEventInsideSummitDuration($event)) - throw new ValidationException - ( - sprintf - ( - "event start/end (%s - %s) does not match with summit start/end (%s - %s)", - $start_datetime->format('Y-m-d H:i:s'), - $end_datetime->format('Y-m-d H:i:s'), - $summit->getLocalBeginDate()->format('Y-m-d H:i:s'), - $summit->getLocalEndDate()->format('Y-m-d H:i:s') - ) - ); - } + $this->updateEventDates($data, $summit, $event); if (isset($data['tags']) && count($data['tags']) > 0) { $event->clearTags(); @@ -627,7 +641,8 @@ final class SummitService implements ISummitService } } - if(isset($data['moderator_speaker_id']) && !is_null($event_type) && $event_type->allowsModerator()){ + if(isset($data['moderator_speaker_id']) && !is_null($event_type) + && $event_type instanceof PresentationType && $event instanceof Presentation){ $speaker_id = intval($data['moderator_speaker_id']); if($speaker_id === 0) $event->unsetModerator(); else @@ -638,7 +653,7 @@ final class SummitService implements ISummitService } } - $event_repository->add($event); + $this->event_repository->add($event); return $event; }); @@ -652,11 +667,10 @@ final class SummitService implements ISummitService */ public function publishEvent(Summit $summit, $event_id, array $data) { - $event_repository = $this->event_repository; - return $this->tx_service->transaction(function () use ($summit, $data, $event_id, $event_repository) { + return $this->tx_service->transaction(function () use ($summit, $data, $event_id) { - $event = $event_repository->getById($event_id); + $event = $this->event_repository->getById($event_id); if (is_null($event)) throw new EntityNotFoundException(sprintf("event id %s does not exists!", $event_id)); @@ -670,16 +684,11 @@ final class SummitService implements ISummitService if ($event->getSummit()->getIdentifier() !== $summit->getIdentifier()) throw new ValidationException(sprintf("event %s does not belongs to summit id %s", $event_id, $summit->getIdentifier())); + $this->updateEventDates($data, $summit, $event); + $start_datetime = $event->getStartDate(); $end_datetime = $event->getEndDate(); - if (isset($data['start_date']) && isset($data['end_date'])) { - $start_datetime = intval($data['start_date']); - $start_datetime = new \DateTime("@$start_datetime"); - $end_datetime = intval($data['end_date']); - $end_datetime = new \DateTime("@$end_datetime"); - } - if (is_null($start_datetime)) throw new ValidationException(sprintf("start_date its not assigned to event id %s!", $event_id)); @@ -690,14 +699,13 @@ final class SummitService implements ISummitService $location = $summit->getLocation(intval($data['location_id'])); if (is_null($location)) throw new EntityNotFoundException(sprintf("location id %s does not exists!", $data['location_id'])); - $event->setLocation($location); } $current_event_location = $event->getLocation(); // validate blackout times - $conflict_events = $event_repository->getPublishedOnSameTimeFrame($event); + $conflict_events = $this->event_repository->getPublishedOnSameTimeFrame($event); if (!is_null($conflict_events)) { foreach ($conflict_events as $c_event) { // if the published event is BlackoutTime or if there is a BlackoutTime event in this timeframe @@ -748,7 +756,7 @@ final class SummitService implements ISummitService $event->unPublish(); $event->publish(); - $event_repository->add($event); + $this->event_repository->add($event); return $event; }); } @@ -760,11 +768,10 @@ final class SummitService implements ISummitService */ public function unPublishEvent(Summit $summit, $event_id) { - $event_repository = $this->event_repository; - return $this->tx_service->transaction(function () use ($summit, $event_id, $event_repository) { + return $this->tx_service->transaction(function () use ($summit, $event_id) { - $event = $event_repository->getById($event_id); + $event = $this->event_repository->getById($event_id); if (is_null($event)) throw new EntityNotFoundException(sprintf("event id %s does not exists!", $event_id)); @@ -773,8 +780,8 @@ final class SummitService implements ISummitService throw new ValidationException(sprintf("event %s does not belongs to summit id %s", $event_id, $summit->getIdentifier())); $event->unPublish(); - $event_repository->add($event); - $event_repository->cleanupAttendeesScheduleForEvent($event_id); + $this->event_repository->add($event); + $this->event_repository->cleanupAttendeesScheduleForEvent($event_id); return $event; }); } @@ -786,11 +793,10 @@ final class SummitService implements ISummitService */ public function deleteEvent(Summit $summit, $event_id) { - $event_repository = $this->event_repository; - return $this->tx_service->transaction(function () use ($summit, $event_id, $event_repository) { + return $this->tx_service->transaction(function () use ($summit, $event_id) { - $event = $event_repository->getById($event_id); + $event = $this->event_repository->getById($event_id); if (is_null($event)) throw new EntityNotFoundException(sprintf("event id %s does not exists!", $event_id)); @@ -798,9 +804,9 @@ final class SummitService implements ISummitService if ($event->getSummit()->getIdentifier() !== $summit->getIdentifier()) throw new ValidationException(sprintf("event %s does not belongs to summit id %s", $event_id, $summit->getIdentifier())); - $event_repository->delete($event); + $this->event_repository->delete($event); // clean up summit attendees schedule - $event_repository->cleanupAttendeesScheduleForEvent($event_id); + $this->event_repository->cleanupAttendeesScheduleForEvent($event_id); return true; }); } diff --git a/tests/OAuth2SummitApiTest.php b/tests/OAuth2SummitApiTest.php index 3c1e7df9..1f474d6a 100644 --- a/tests/OAuth2SummitApiTest.php +++ b/tests/OAuth2SummitApiTest.php @@ -40,7 +40,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest public function testGetAllSummits() { - $params = ['expand' => 'type']; + $params = ['expand' => 'type,event_types,tracks']; $headers = array("HTTP_Authorization" => " Bearer " . $this->access_token); $response = $this->action( @@ -109,7 +109,8 @@ final class OAuth2SummitApiTest extends ProtectedApiTest $params = array ( - 'id' => $summit_id + 'id' => $summit_id, + 'expand' =>'event_types', ); $headers = array("HTTP_Authorization" => " Bearer " . $this->access_token); @@ -199,7 +200,6 @@ final class OAuth2SummitApiTest extends ProtectedApiTest $this->assertResponseStatus(200); } - public function testGetCurrentSummit($summit_id = 23) { @@ -964,11 +964,11 @@ final class OAuth2SummitApiTest extends ProtectedApiTest $this->assertTrue(!is_null($events)); } - public function testPostEvent($start_date = 1477645200, $end_date = 1477647600) + public function testPostEvent($summit_id = 23, $location_id = 0, $type_id = 0, $track_id = 0, $start_date = 1477645200, $end_date = 1477647600) { $params = array ( - 'id' => 7, + 'id' => $summit_id, ); $headers = array @@ -979,16 +979,20 @@ final class OAuth2SummitApiTest extends ProtectedApiTest $data = array ( - 'title' => 'Neutron: tbd', - 'description' => 'TBD', - 'location_id' => 179, + 'title' => 'Neutron: tbd', + 'description' => 'TBD', 'allow_feedback' => true, - 'start_date' => $start_date, - 'end_date' => $end_date, - 'type_id' => 95, - 'tags' => ['Neutron'] + 'start_date' => $start_date, + 'end_date' => $end_date, + 'type_id' => $type_id, + 'tags' => ['Neutron'], + 'track_id' => $track_id ); + if($location_id > 0){ + $data['location_id'] = $location_id; + } + $response = $this->action ( "POST", @@ -1004,7 +1008,7 @@ final class OAuth2SummitApiTest extends ProtectedApiTest $this->assertResponseStatus(201); $content = $response->getContent(); $event = json_decode($content); - $this->assertTrue($event->getId() > 0); + $this->assertTrue($event->id > 0); return $event; } @@ -1131,15 +1135,17 @@ final class OAuth2SummitApiTest extends ProtectedApiTest } - public function testPublishEvent($start_date = 1461520800, $end_date = 1461526200) + public function testPublishEvent($start_date = 1509789600, $end_date = 1509791400) { - $event = $this->testPostEvent($start_date, $end_date); + $event = $this->testPostEvent($summit_id = 23,$location_id = 0, $type_id = 124, $track_id = 206, $start_date, $end_date); unset($event->tags); $params = array ( - 'id' => 6, - 'event_id' => $event->getId(), + 'id' => $summit_id, + 'event_id' => $event->id, + 'start_date' => $start_date, + 'end_date' => $end_date ); $headers = array