openstackid-resources/tests/OAuth2SummitLocationsApiTest.php
smarcet 39e3c8e333 * Summit Registration Model/Endpoints
Doc

https://docs.google.com/document/d/1gOAceevwutF3QHYWD0_6aESQMZEiIz3YVBVXlyUuRy8

* Summit Registration External Feed

https://docs.google.com/document/d/1_2QZUK--A350jxh2USKBtVtisKrrcUcVjdKnbcZ7-4M/edit#

* Multi Stripe Config

* Added stripe payment configuration per summit
* Added webhook automatic creation
* Added CRUD endpoints for payment profiles per summit

GET api/v1/summits/{id}/payment-gateway-profiles

filters

active ['==']
application_type ['=@', '==']

scopes

summits/read/all
summits/payment-gateway-profiles/read

POST  api/v1/summits/{id}/payment-gateway-profiles

payload

'active'               => 'sometimes|boolean',
'application_type'     => 'sometimes|string|in:Registration,BookableRooms'
'provider'             => 'required|string|in:Stripe',
'test_mode_enabled'    => 'required|boolean',
'live_secret_key'      => 'sometimes|string',
'live_publishable_key' => 'required_with:live_secret_key|string',
'test_secret_key'      => 'sometimes|string',
'test_publishable_key' => 'required_with:test_secret_key|string'

scopes

summits/write
summits/payment-gateway-profiles/write

GET  api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}

scopes

summits/read/all
summits/payment-gateway-profiles/read

PUT api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}

payload

'active'               => 'sometimes|boolean',
'application_type'     => 'sometimes|string|in:Registration,BookableRooms'
'provider'             => 'required|string|in:Stripe',
'test_mode_enabled'    => 'required|boolean',
'live_secret_key'      => 'sometimes|string',
'live_publishable_key' => 'required_with:live_secret_key|string',
'test_secret_key'      => 'sometimes|string',
'test_publishable_key' => 'required_with:test_secret_key|string'

scopes

summits/payment-gateway-profiles/write
summits/write

DELETE api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id}

scopes

summits/payment-gateway-profiles/write
summits/write

Stripe Webhooks

default webhook

(SECRET set per application under .env, should be created previously on stripe default account)

POST api/public/v1/summits/all/payments/{application_name}/confirm

where application_name could be Registration or BookableRooms

otherwise if a stripe account is set per summit, when the profile gets activated
a webhook will be automatically be created using following url

POST api/public/v1/summits/{id}/payments/{application_name}/confirm

* Email API Integration

* moved all blade templates to mail api ( DB Seeding)
* defined email events flows per summmit
* created endpoint to set up templates per email events on each flow

PUT /api/v1/summits/{id}/email-flows-events/{event_id}

payload

email_template_identifier: string

* added endpoint to get all email events per summit

GET /api/v1/summits/{id}/email-flows-events

* added endpoint to get email event per summit/id

GET /api/v1/summits/{id}/email-flows-events/{event_id}

Summit Documents endpoints

add summit document

POST /api/v1/summits/{id}/summit-documents

payload

file (mandatory|file stream)
label ( mandatory|string)
name ( mandatory|string)
description (optional|string)

get all summit documents

GET /api/v1/summits/{id}/summit-documents

get by id

GET /api/v1/summits/{id}/summit-documents/{document_id}

update

PUT GET /api/v1/summits/{id}/summit-documents/{document_id}

file (optional|file stream)
label (optional|string)
name (optional|string)
description (optional|string)

delete

DELETE GET /api/v1/summits/{id}/summit-documents/{document_id}

add event type to doc

PUT /api/v1/summits/{id}/summit-documents/{document_id}/event-types/{event_type_id}

delete event type from doc

DELETE /api/v1/summits/{id}/summit-documents/{document_id}/event-types/{event_type_id}

add document to event type

PUT /api/v1/summits/{id}/event-types/{event_type_id}/summit-documents/{document_id}

delete document from event type

DELETE /api/v1/summits/{id}/event-types/{event_type_id}/summit-documents/{document_id}

Updated Summit events to support streaming url, meeting_url and etherpad link

* Summit Registration - Invite only

Summit Administrator Permission Groups

GET /api/v1/summit-administrator-groups

filter

* title
* member_first_name
* member_last_name
* member_full_name
* member_email
* summit_id
* member_id

ordering

id
title

scopes

%s/summit-administrator-groups/read

/api/v1/summit-administrator-groups/{group_id}

scopes

%s/summit-administrator-groups/read

POST /api/v1/summit-administrator-groups

title
summits
members

scopes

%s/summit-administrator-groups/write

PUT /api/v1/summit-administrator-groups/{group_id}

title
summits
members

scopes

%s/summit-administrator-groups/write

DELETE /api/v1/summit-administrator-groups/{group_id}

scopes

%s/summit-administrator-groups/write

PUT /api/v1/summit-administrator-groups/{group_id}/members/{member_id}

DELETE /api/v1/summit-administrator-groups/{group_id}/members/{member_id}

PUT /api/v1/summit-administrator-groups/{group_id}/summits/{summit_id}

DELETE /api/v1/summit-administrator-groups/{group_id}/summits/{summit_id}

Room Metrics

PUT /api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/enter

Scopes

%s/me/summits/events/enter

PUT /api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/leave

%s/me/summits/events/leave

update summit_event serializer

new fields

total_attendance_count
current_attendance_count
attendance
current_attendance

Added new Speakers Endpoints

GET /api/v1/summits/{id}/speakers/on-schedule

retrieves all speakers on summit schedule

filters

'first_name' => ['=@', '=='],
'last_name'  => ['=@', '=='],
'email'      => ['=@', '=='],
'id'         => ['=='],
'full_name'  => ['=@', '=='],
'start_date' => ['>', '<', '<=', '>=', '=='],
'end_date'   => ['>', '<', '<=', '>=', '=='],

Summit Events Image

POST /api/v1/summits/{id}/events/{event_id}/image
DELETE /api/v1/summits/{id}/events/{event_id}/image

Speakers Image Big Pic

POST /api/v1/speakers/{speaker_id}/big-photo
DELETE /api/v1/speakers/{speaker_id}/big-photo

CFP - multiple summits

Presentation Materials - Media Uploads

New Endpoints

GET api/v1/summit-media-file-types

filter
'name' => ['=@', '==']

order

id, name

POST api/v1/summit-media-file-types

payload

'name'  => 'required|string|max:255',
'description'  => 'sometimes|string|max:255',
'allowed_extensions' => 'required|string_array',

GET api/v1/summit-media-file-types/{id}

PUT api/v1/summit-media-file-types/{id}

payload

'name'  => 'sometimes|string|max:255',
'description'  => 'sometimes|string|max:255',
'allowed_extensions' => 'required|string_array',

DELETE api/v1/summit-media-file-types/{id}

GET api/v1/summits/{id}/media-upload-types

POST

payload

'name' => 'required|string|max:255',
'description' => 'sometimes|string|max:255',
'is_mandatory' => 'required|boolean',
'max_size' => 'required|int|megabyte_aligned',
'private_storage_type' => 'required|string|in:None,DropBox,Swift,Local',
'public_storage_type' => 'required|string|in:None,DropBox,Swift,Local'
'type_id' => 'required|int',
'presentation_types' => 'sometimes|int_array',

GET api/v1/summits/{id}/media-upload-types/{media_upload_type_id}

PUT api/v1/summits/{id}/media-upload-types/{media_upload_type_id}

payload

'name' => 'sometimes|string|max:255',
'description' => 'sometimes|string|max:255',
'is_mandatory' => 'sometimes|boolean',
'max_size' => 'sometimes|int|megabyte_aligned',
'private_storage_type' => 'sometimes|string|in:None,DropBox,Swift,Local',
'public_storage_type' => 'sometimes|string|in:None,DropBox,Swift,Local'
'type_id' => 'sometimes|int',
'presentation_types' => 'sometimes|int_array',

DELETE api/v1/summits/{id}/media-upload-types/{media_upload_type_id}

PUT api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id}

DELETE api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id}

GET api/v1/summits/{id}/presentations/{presentation_id}/media-uploads

POST api/v1/summits/{id}/presentations/{presentation_id}/media-uploads

payload multiform

file

media_upload_type_id

GET api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id}

PUT api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id}

payload multiform

file

DELETE api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id}

POST /api/v1/summits/{id}/media-upload-types/all/clone/{to_summit_id}

Summit Invitation Only endpoints V2

CRUD invitations

Change-Id: Ia23c247a59c3810f2a738265efdd890fe6f59dfb
Signed-off-by: smarcet <smarcet@gmail.com>
2020-09-21 09:52:07 -03:00

1901 lines
50 KiB
PHP

<?php
/**
* Copyright 2018 OpenStack Foundation
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
use App\Models\Foundation\Summit\Factories\SummitLocationFactory;
use LaravelDoctrine\ORM\Facades\EntityManager;
use models\summit\SummitBookableVenueRoom;
/**
* Class OAuth2SummitLocationsApiTest
*/
final class OAuth2SummitLocationsApiTest extends ProtectedApiTest
{
public function testGetFolder(){
$service = \Illuminate\Support\Facades\App::make(\App\Services\Model\IFolderService::class);
$folder = $service->findOrMake('summits/1/locations/292/maps');
}
use InsertSummitTestData;
private static $bookable_room;
protected function setUp()
{
parent::setUp();
self::insertTestData();
$data = [
'name' => 'test bookable room',
'capacity' => 10,
'description' => 'test bookable room',
'time_slot_cost' => 200,
'currency' => 'USD',
];
$data['class_name'] = SummitBookableVenueRoom::ClassName;
self::$bookable_room = SummitLocationFactory::build($data);
self::$summit->addLocation(self::$bookable_room);
self::$mainVenue->addRoom(self::$bookable_room);
self::$em->persist(self::$summit);
self::$em->flush();
}
protected function tearDown()
{
self::clearTestData();
parent::tearDown();
}
public function testGetCurrentSummitLocations($summit_id = 23)
{
$params = [
'id' => $summit_id,
'page' => 1,
'per_page' => 5,
'order' => '-order'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocations",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetSummitLocationsOrderByName($summit_id = 22)
{
$params = [
'id' => $summit_id,
'page' => 1,
'per_page' => 5,
'order' => 'name-'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocations",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitLocationsMetadata($summit_id = 23)
{
$params = [
'id' => $summit_id,
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getMetadata",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$metadata = json_decode($content);
$this->assertTrue(!is_null($metadata));
}
public function testGetCurrentSummitLocationsByClassNameVenueORAirport($summit_id = 24)
{
$params = [
'id' => $summit_id,
'page' => 1,
'per_page' => 5,
'filter' => [
'class_name=='.\models\summit\SummitVenue::ClassName.',class_name=='.\models\summit\SummitAirport::ClassName,
]
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocations",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitLocationsByClassHotels($summit_id = 25)
{
$params = [
'id' => $summit_id,
'page' => 1,
'per_page' => 100,
'filter' => [
'class_name=='.\models\summit\SummitHotel::ClassName,
]
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocations",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitVenues()
{
$params = array
(
'id' => 'current',
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getVenues",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitHotels()
{
$params = array
(
'id' => 'current',
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getHotels",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitAirports()
{
$params = array
(
'id' => 'current',
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getAirports",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitExternalLocations()
{
$params = array
(
'id' => 'current',
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getExternalLocations",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testGetCurrentSummitLocation()
{
$params = array
(
'id' => 'current',
'location_id' => 25
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocation",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$locations = json_decode($content);
$this->assertTrue(!is_null($locations));
}
public function testCurrentSummitLocationEventsWithFilter($summit_id = 7)
{
$params = array
(
'id' => $summit_id,
'page' => 1,
'per_page' => 50,
'location_id' => 52,
'filter' => array
(
'tags=@Nova',
'speaker=@Todd'
)
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocationEvents",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$events = json_decode($content);
$this->assertTrue(!is_null($events));
}
public function testCurrentSummitPublishedLocationEventsWithFilter()
{
$params = array
(
'id' => 23,
'location_id' => 311,
'filter' => [
'start_date>=1451479955'
]
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocationPublishedEvents",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$events = json_decode($content);
$this->assertTrue(!is_null($events));
}
public function testCurrentSummitPublishedLocationTBAEvents()
{
$params = array
(
'id' => 23,
'location_id' => "tba",
);
$headers = array
(
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
);
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocationPublishedEvents",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$events = json_decode($content);
$this->assertTrue(!is_null($events));
}
public function testAddLocationWithoutClassName($summit_id = 24){
$params = [
'id' => $summit_id,
];
$name = str_random(16).'_location';
$data = [
'name' => $name,
'description' => 'test location',
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addLocation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(412);
}
public function testAddLocationVenue($summit_id = 24){
$params = [
'id' => $summit_id,
];
$name = str_random(16).'_location';
$data = [
'name' => $name,
'address_1' => 'Nazar 612',
'city' => 'Lanus',
'state' => 'Buenos Aires',
'country' => 'AR',
'class_name' => \models\summit\SummitVenue::ClassName,
'description' => 'test location',
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addLocation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$location = json_decode($content);
$this->assertTrue(!is_null($location));
return $location;
}
/**
* @param int $summit_id
* @return mixed
*/
public function testAddLocationVenueLatLng($summit_id = 24){
$params = [
'id' => $summit_id,
];
$name = str_random(16).'_location';
$data = [
'name' => $name,
'lat' => '-34.6994795',
'lng' => '-58.3920795',
'class_name' => \models\summit\SummitVenue::ClassName,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addLocation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$location = json_decode($content);
$this->assertTrue(!is_null($location));
return $location;
}
/**
* @param int $summit_id
* @return mixed
*/
public function testAddLocationVenueLatLngInvalid($summit_id = 24){
$params = [
'id' => $summit_id,
];
$name = str_random(16).'_location';
$data = [
'name' => $name,
'lat' => '-134.6994795',
'lng' => '-658.3920795',
'class_name' => \models\summit\SummitVenue::ClassName,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addLocation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(412);
}
/**
* @param int $summit_id
* @return mixed
*/
public function testAddLocationHotelAddress($summit_id = 24){
$params = [
'id' => $summit_id,
];
$name = str_random(16).'_hotel';
$data = [
'name' => $name,
'address_1' => 'H. de Malvinas 1724',
'city' => 'Lanus Este',
'state' => 'Buenos Aires',
'country' => 'AR',
'zip_code' => '1824',
'class_name' => \models\summit\SummitHotel::ClassName,
'hotel_type' => \models\summit\SummitHotel::HotelTypePrimary,
'capacity' => 200
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addLocation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$location = json_decode($content);
$this->assertTrue(!is_null($location));
return $location;
}
public function testUpdateLocationHotelOrder($summit_id = 24){
$hotel = $this->testAddLocationHotelAddress($summit_id);
$new_order = 9;
$params = [
'id' => $summit_id,
'location_id' => $hotel->id
];
$data = [
'order' => $new_order,
'class_name' => \models\summit\SummitHotel::ClassName,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"PUT",
"OAuth2SummitLocationsApiController@updateLocation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$location = json_decode($content);
$this->assertTrue(!is_null($location));
$this->assertTrue($location->order == $new_order);
return $location;
}
/**
* @param int $summit_id
* @return mixed
*/
public function testUpdateExistentLocation($summit_id = 23){
$params = [
'id' => $summit_id,
'location_id' => 292
];
$data = [
'class_name' => \models\summit\SummitVenue::ClassName,
'name' => 'Sydney Convention and Exhibition Centre Update!'
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"PUT",
"OAuth2SummitLocationsApiController@updateLocation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$location = json_decode($content);
$this->assertTrue(!is_null($location));
return $location;
}
/**
* @param int $summit_id
*/
public function testDeleteNewlyCreatedHotel($summit_id = 24){
$hotel = $this->testAddLocationHotelAddress($summit_id);
$params = [
'id' => $summit_id,
'location_id' => $hotel->id
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"DELETE",
"OAuth2SummitLocationsApiController@deleteLocation",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
/**
* @param int $summit_id
* @param int $venue_id
* @param int $number
* @return mixed
*/
public function testAddVenueFloor($summit_id = 23, $venue_id = 292, $number = null){
$params = [
'id' => $summit_id,
'venue_id' => $venue_id
];
if(is_null($number))
$number = rand(0,1000);
$name = str_random(16).'_floor';
$data = [
'name' => $name,
'description' => 'test floor',
'number' => $number
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addVenueFloor",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$floor = json_decode($content);
$this->assertTrue(!is_null($floor));
return $floor;
}
/**
* @param int $summit_id
* @param int $venue_id
* @return mixed
*/
public function testUpdateVenueFloor($summit_id = 23, $venue_id = 292){
$floor = $this->testAddVenueFloor($summit_id, $venue_id, rand(0,1000));
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
'floor_id' => $floor->id
];
$data = [
'name' => 'test floor update',
'description' => 'test floor update',
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"PUT",
"OAuth2SummitLocationsApiController@updateVenueFloor",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$floor = json_decode($content);
$this->assertTrue(!is_null($floor));
return $floor;
}
/**
* @param int $summit_id
* @param int $venue_id
*/
public function testDeleteVenueFloor($summit_id = 23, $venue_id = 292){
$floor = $this->testAddVenueFloor($summit_id, $venue_id, rand(0,1000));
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
'floor_id' => $floor->id
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"DELETE",
"OAuth2SummitLocationsApiController@deleteVenueFloor",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
/**
* @param int $summit_id
* @param int $venue_id
* @return mixed
*/
public function testAddVenueRoom($summit_id = 23, $venue_id = 292){
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
];
$name = str_random(16).'_room';
$data = [
'name' => $name,
'description' => 'test room',
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addVenueRoom",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$room = json_decode($content);
$this->assertTrue(!is_null($room));
return $room;
}
/**
* @param int $summit_id
* @param int $venue_id
* @return mixed
*/
public function testAddVenueRoomWithFloor($summit_id = 23, $venue_id = 292){
$floor = $this->testAddVenueFloor($summit_id, $venue_id, rand(0,1000));
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
'floor_id' => $floor->id
];
$name = str_random(16).'_room';
$data = [
'name' => $name,
'description' => 'test room',
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addVenueFloorRoom",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$room = json_decode($content);
$this->assertTrue(!is_null($room));
return $room;
}
/**
* @param int $summit_id
* @param int $venue_id
* @return mixed
*/
public function testUpdateVenueRoomWithFloor($summit_id = 23, $venue_id = 292){
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
'floor_id' => 22,
'room_id' => 307
];
$data = [
'description' => 'Pyrmont Theatre Update',
'order' => 2,
'capacity' => 1000,
'floor_id' => 23
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"PUT",
"OAuth2SummitLocationsApiController@updateVenueFloorRoom",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$room = json_decode($content);
$this->assertTrue(!is_null($room));
return $room;
}
/**
* @param int $summit_id
* @param int $venue_id
* @return mixed
*/
public function testDeleteExistentRoom($summit_id = 23, $venue_id = 292, $room_id = 307){
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
'room_id' => 333
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"DELETE",
"OAuth2SummitLocationsApiController@deleteVenueRoom",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
public function testGetFloorById($summit_id = 23, $venue_id = 292, $floor_id = 23){
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
'floor_id' => $floor_id,
'expand' => 'rooms'
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"GET",
"OAuth2SummitLocationsApiController@getVenueFloor",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$floor = json_decode($content);
$this->assertTrue(!is_null($floor));
return $floor;
}
public function testGetVenueFloorRoomById($summit_id = 23, $venue_id = 292, $floor_id = 23, $room_id = 309){
$params = [
'id' => $summit_id,
'venue_id' => $venue_id,
'floor_id' => $floor_id,
'room_id' => $room_id,
'expand' => 'floor,venue'
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"GET",
"OAuth2SummitLocationsApiController@getVenueFloorRoom",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$room = json_decode($content);
$this->assertTrue(!is_null($room));
return $room;
}
public function testAddLocationBanner($summit_id = 23, $location_id = 315){
$params = [
'id' => $summit_id,
'location_id' => $location_id
];
$data = [
'title' => str_random(16).'_banner_title',
'content' => '<span>title</span>',
'type' => \App\Models\Foundation\Summit\Locations\Banners\SummitLocationBanner::TypePrimary,
'enabled' => true,
'class_name' => \App\Models\Foundation\Summit\Locations\Banners\SummitLocationBanner::ClassName,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addLocationBanner",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$banner = json_decode($content);
$this->assertTrue(!is_null($banner));
return $banner;
}
public function testAddLocationScheduleBanner($summit_id = 23, $location_id = 315){
$params = [
'id' => $summit_id,
'location_id' => $location_id
];
$data = [
'title' => str_random(16).'_banner_title',
'content' => '<span>title</span>',
'type' => \App\Models\Foundation\Summit\Locations\Banners\SummitLocationBanner::TypePrimary,
'enabled' => true,
'class_name' => \App\Models\Foundation\Summit\Locations\Banners\ScheduledSummitLocationBanner::ClassName,
'start_date' => 1509876000,
'end_date' => (1509876000+1000),
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@addLocationBanner",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$banner = json_decode($content);
$this->assertTrue(!is_null($banner));
return $banner;
}
public function testGetLocationBanners($summit_id = 23, $location_id = 315)
{
$params = [
'id' => $summit_id,
'location_id' => $location_id,
'page' => 1,
'per_page' => 5,
'order' => '-id'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocationBanners",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$banners = json_decode($content);
$this->assertTrue(!is_null($banners));
return $banners;
}
public function testGetLocationBannersFilterByClassName($summit_id = 23, $location_id = 315)
{
$params = [
'id' => $summit_id,
'location_id' => $location_id,
'page' => 1,
'per_page' => 5,
'order' => '-id',
'filter' => 'class_name=='.\App\Models\Foundation\Summit\Locations\Banners\ScheduledSummitLocationBanner::ClassName
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocationBanners",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$banners = json_decode($content);
$this->assertTrue(!is_null($banners));
}
public function testGetLocationBannersFilterByInvalidClassName($summit_id = 23, $location_id = 315)
{
$params = [
'id' => $summit_id,
'location_id' => $location_id,
'page' => 1,
'per_page' => 5,
'order' => '-id',
'filter' => 'class_name==test,class_name==test2'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getLocationBanners",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$banners = json_decode($content);
$this->assertTrue(!is_null($banners));
}
public function testDeleteLocationBanner($summit_id = 23, $location_id = 315){
$banners = $this->testGetLocationBanners($summit_id, $location_id);
$params = [
'id' => $summit_id,
'location_id' => $location_id,
'banner_id' => $banners->data[0]->id
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"DELETE",
"OAuth2SummitLocationsApiController@deleteLocationBanner",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
public function testDeleteLocationMap($summit_id = 22, $location_id = 214, $map_id=30){
$params = [
'id' => $summit_id,
'location_id' => $location_id,
'map_id' => $map_id
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"DELETE",
"OAuth2SummitLocationsApiController@deleteLocationMap",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(204);
}
// bookable rooms tests
public function testSummitGetBookableRoomsFilterDiffValuesSameColumn($summit_id = 6)
{
$params = [
'id' => $summit_id,
'page' => 1,
'per_page' => 10,
'order' => '-id',
'expand' => 'venue,attribute_type',
'filter' => [
"availability_day==1579086000",
"attribute==",
"capacity>=1"
],
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getBookableVenueRooms",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$rooms = json_decode($content);
$this->assertTrue(!is_null($rooms));
}
public function testSummitGetBookableRoomAvailability($summit_id = 6, $room_id = 20, $day = 1579172400)
{
$params = [
'id' => $summit_id,
'room_id' => $room_id,
'day' => $day,
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getBookableVenueRoomAvailability",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$slots = json_decode($content);
$this->assertTrue(!is_null($slots));
}
/**
* @param int $summit_id
* @param int $room_id
* @param int $start_date
* @return mixed
*/
public function testBookableRoomReservation(){
$params = [
'id' => self::$summit->getId(),
'room_id' => self::$bookable_room->getId(),
];
$data = [
'currency' => 'USD',
'amount' => 200,
'start_datetime' => 1572919200,
'end_datetime' => 1572922800,
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2SummitLocationsApiController@createBookableVenueRoomReservation",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$reservation = json_decode($content);
$this->assertTrue(!is_null($reservation));
return $reservation;
}
public function testGetMyReservations($summit_id = 27)
{
$params = [
'id' => $summit_id,
'expand' => 'room'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getMyBookableVenueRoomReservations",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$reservations = json_decode($content);
$this->assertTrue(!is_null($reservations));
}
public function testCancelMyReservations($summit_id = 27, $reservation_id = 4)
{
$params = [
'id' => $summit_id,
'reservation_id' => $reservation_id
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"DELETE",
"OAuth2SummitLocationsApiController@cancelMyBookableVenueRoomReservation",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$reservations = json_decode($content);
$this->assertTrue(!is_null($reservations));
}
/**
* @param int $summit_id
*/
public function testAddBookableRoom($summit_id = 27){
$summit_repository = EntityManager::getRepository(\models\summit\Summit::class);
$summit = $summit_repository->getById($summit_id);
$this->assertTrue(!is_null($summit));
if(!$summit instanceof \models\summit\Summit) return;
$venues = $summit->getVenues();
$this->assertTrue($venues->count() > 0 );
$venue = $venues->first();
$params = [
'id' => $summit_id,
'venue_id' => $venue->getId()
];
$name = str_random(16).'_bookable_room';
$data = [
'name' => $name,
'capacity' => 10,
'description' => 'test bookable room',
'time_slot_cost' => 200,
'currency' => 'USD',
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"POST",
"OAuth2SummitLocationsApiController@addVenueBookableRoom",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$bookable_room = json_decode($content);
$this->assertTrue(!is_null($bookable_room));
$this->assertTrue($bookable_room->name == $name);
return $bookable_room;
}
/**
* @param int $summit_id
* @param int $floor_id
* @return mixed|null
*/
public function testAddBookableRoomOnFloor($summit_id = 27){
$summit_repository = EntityManager::getRepository(\models\summit\Summit::class);
$summit = $summit_repository->getById($summit_id);
$this->assertTrue(!is_null($summit));
if(!$summit instanceof \models\summit\Summit) return null;
$venues = $summit->getVenues();
$this->assertTrue($venues->count() > 0 );
$venue = $venues->first();
if(!$venue instanceof \models\summit\SummitVenue) return null;
$floors = $venue->getFloors();
$this->assertTrue($floors->count() > 0);
$params = [
'id' => $summit_id,
'venue_id' => $venue->getId(),
'floor_id' => $floors->first()->getId()
];
$name = str_random(16).'_bookable_room';
$data = [
'name' => $name,
'capacity' => 10,
'description' => 'test bookable room',
'time_slot_cost' => 200,
'currency' => 'USD',
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"POST",
"OAuth2SummitLocationsApiController@addVenueFloorBookableRoom",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$bookable_room = json_decode($content);
$this->assertTrue(!is_null($bookable_room));
$this->assertTrue($bookable_room->name == $name);
return $bookable_room;
}
public function testUpdateBookableRooms($summit_id = 27){
$bookable_room = $this->testAddBookableRoom($summit_id);
$this->assertTrue(!is_null($bookable_room));
$params = [
'id' => $summit_id,
'venue_id' => $bookable_room->venue_id,
'room_id' => $bookable_room->id,
];
$name = str_random(16).'_bookable_room_update';
$data = [
'name' => $name,
'capacity' => 14,
'time_slot_cost' => 250,
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"PUT",
"OAuth2SummitLocationsApiController@updateVenueBookableRoom",
$params,
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$bookable_room = json_decode($content);
$this->assertTrue(!is_null($bookable_room));
$this->assertTrue($bookable_room->name == $name);
return $bookable_room;
}
/**
* @param int $summit_id
*/
public function testAddBookableRoomAttributeValue($summit_id = 27){
$summit_repository = EntityManager::getRepository(\models\summit\Summit::class);
$summit = $summit_repository->getById($summit_id);
$this->assertTrue(!is_null($summit));
if(!$summit instanceof \models\summit\Summit) return;
$rooms = $summit->getBookableRooms();
$room = $rooms->first();
$attributes = $summit->getMeetingBookingRoomAllowedAttributes();
$attribute = $attributes->last();
$values = $attribute->getValues();
$value = $values->first();
$params = [
'id' => $summit_id,
'venue_id' => $room->getVenueId(),
'room_id' => $room->getId(),
'attribute_id' => $value->getId()
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"PUT",
"OAuth2SummitLocationsApiController@addVenueBookableRoomAttribute",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$bookable_room = json_decode($content);
$this->assertTrue(!is_null($bookable_room));
}
public function testGetAllReservationsBySummit($summit_id =27){
$params = [
'id' => $summit_id,
'filter' => 'status==Reserved,room_id==1',
'order' => '+owner_name'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getAllReservationsBySummit",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$reservations = json_decode($content);
$this->assertTrue(!is_null($reservations));
}
public function testGetAllReservationsBySummitAndOwnerName($summit_id =27){
$params = [
'id' => $summit_id,
'filter' => 'status==Canceled,owner_name=@Sebastian'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getAllReservationsBySummit",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$reservations = json_decode($content);
$this->assertTrue(!is_null($reservations));
}
public function testGetAllReservationsBySummitAndOwnerNameCSV($summit_id =27){
$params = [
'id' => $summit_id,
'filter' => 'status==Canceled,owner_name=@Sebastian'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getAllReservationsBySummitCSV",
$params,
[],
[],
[],
$headers
);
$csv = $response->getContent();
$this->assertResponseStatus(200);
$this->assertTrue(!empty($csv));
}
public function testGetReservationById($id = 2){
$params = [
'id' => $id,
'filter' => 'status==Canceled,owner_name=@Sebastian'
];
$headers =
[
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action
(
"GET",
"OAuth2SummitLocationsApiController@getReservationById",
$params,
[],
[],
[],
$headers
);
$content = $response->getContent();
$this->assertResponseStatus(200);
$reservation = json_decode($content);
$this->assertTrue(!is_null($reservation));
}
}