Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,7 @@ function () {
'track_id',
'occupancy',
'track',
'location',
];
},
function ($filter) use($summit_id, $location, $published){
Expand Down Expand Up @@ -1539,7 +1540,7 @@ function ($page, $per_page, $filter, $order, $applyExtraFilters) use ($location)
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID or slug', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'location_id', in: 'path', required: true, description: 'Location ID or "tbd"', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'filter', in: 'query', required: false, description: 'Filter by: title, start_date, end_date, speaker, tags, event_type_id, track_id, type_show_always_on_schedule', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by: title, start_date, end_date, id, created, track_id, occupancy, track', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by: title, start_date, end_date, id, created, track_id, occupancy, track, location', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'page', in: 'query', required: false, description: 'Page number', schema: new OA\Schema(type: 'integer', default: 1)),
new OA\Parameter(name: 'per_page', in: 'query', required: false, description: 'Items per page', schema: new OA\Schema(type: 'integer', default: 10)),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand related entities', schema: new OA\Schema(type: 'string')),
Expand Down Expand Up @@ -1570,7 +1571,7 @@ public function getLocationEvents($summit_id, $location_id)
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID or slug', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'location_id', in: 'path', required: true, description: 'Location ID or "tbd"', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'filter', in: 'query', required: false, description: 'Filter by: title, start_date, end_date, speaker, tags, event_type_id, track_id, type_show_always_on_schedule', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by: title, start_date, end_date, id, created, track_id, occupancy, track', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by: title, start_date, end_date, id, created, track_id, occupancy, track, location', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'page', in: 'query', required: false, description: 'Page number', schema: new OA\Schema(type: 'integer', default: 1)),
new OA\Parameter(name: 'per_page', in: 'query', required: false, description: 'Items per page', schema: new OA\Schema(type: 'integer', default: 10)),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand related entities', schema: new OA\Schema(type: 'string')),
Expand Down Expand Up @@ -1599,7 +1600,7 @@ public function getLocationEvents($summit_id, $location_id)
new OA\Parameter(name: 'id', in: 'path', required: true, description: 'Summit ID or slug', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'location_id', in: 'path', required: true, description: 'Location ID or "tbd"', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'filter', in: 'query', required: false, description: 'Filter by: title, start_date, end_date, speaker, tags, event_type_id, track_id, type_show_always_on_schedule', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by: title, start_date, end_date, id, created, track_id, occupancy, track', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'order', in: 'query', required: false, description: 'Order by: title, start_date, end_date, id, created, track_id, occupancy, track, location', schema: new OA\Schema(type: 'string')),
new OA\Parameter(name: 'page', in: 'query', required: false, description: 'Page number', schema: new OA\Schema(type: 'integer', default: 1)),
new OA\Parameter(name: 'per_page', in: 'query', required: false, description: 'Items per page', schema: new OA\Schema(type: 'integer', default: 10)),
new OA\Parameter(name: 'expand', in: 'query', required: false, description: 'Expand related entities', schema: new OA\Schema(type: 'string')),
Expand Down
41 changes: 40 additions & 1 deletion tests/oauth2/OAuth2SummitLocationsApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function testCurrentSummitPublishedLocationEventsWithFilter()
public static function locationEventsOrderProvider(): array
{
$cases = [];
foreach (['+occupancy', '-occupancy', '+track'] as $order) {
foreach (['+occupancy', '-occupancy', '+track', '+location', '-location'] as $order) {
$cases["real location $order"] = [false, $order];
$cases["tbd location $order"] = [true, $order];
}
Expand Down Expand Up @@ -520,6 +520,45 @@ public function testGetLocationPublishedEventsOrderByTrack()
}
}

private function getPublishedEventsHasLocation(string $order): array
{
$response = $this->action(
"GET",
"OAuth2SummitEventsApiController@getScheduledEvents",
[
'id' => self::$summit->getId(),
'page' => 1,
'per_page' => 100,
'order' => $order,
],
[],
[],
[],
$this->getAuthHeaders()
);

$this->assertResponseStatus(200);
$page = json_decode($response->getContent());
$this->assertNotEmpty($page->data);

return array_map(fn($event) => intval($event->location_id) > 0 ? 1 : 0, $page->data);
}

public function testGetPublishedEventsOrderByLocation()
{
// events without location sort as '' (COALESCE), so they come before the main venue on ascending order
$asc = $this->getPublishedEventsHasLocation('+location');
$sorted_asc = $asc;
sort($sorted_asc);
$this->assertSame($sorted_asc, $asc);
$this->assertCount(2, array_unique($asc), 'fixtures should mix events with and without location');

$desc = $this->getPublishedEventsHasLocation('-location');
$sorted_desc = $desc;
rsort($sorted_desc);
$this->assertSame($sorted_desc, $desc);
}

public function testAddLocationWithoutClassName(){

$params = [
Expand Down
Loading