
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>
635 lines
18 KiB
PHP
635 lines
18 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\PromoCodes\PromoCodesConstants;
|
|
/**
|
|
* Class OAuth2PromoCodesApiTest
|
|
*/
|
|
final class OAuth2PromoCodesApiTest extends ProtectedApiTest
|
|
{
|
|
/**
|
|
* @param int $summit_id
|
|
*/
|
|
public function testGetPromoCodesDiscount($summit_id=27){
|
|
$params = [
|
|
|
|
'id' => $summit_id,
|
|
'page' => 1,
|
|
'per_page' => 10,
|
|
//'filter' => 'code=@DISCOUNT_',
|
|
'order' => '-code'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getAllBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$promo_codes = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_codes));
|
|
}
|
|
|
|
public function testGetPromoCodesByClassNameSpeakerSummitRegistrationPromoCode(){
|
|
$params = [
|
|
|
|
'id' => 23,
|
|
'page' => 1,
|
|
'per_page' => 10,
|
|
'filter' => 'class_name=='.\models\summit\SpeakerSummitRegistrationPromoCode::ClassName,
|
|
'order' => '+code'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getAllBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$promo_codes = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_codes));
|
|
}
|
|
|
|
public function testGetPromoCodesByClassNameSpeakerSummitRegistrationPromoCodeCSV(){
|
|
$params = [
|
|
|
|
'id' => 25,
|
|
//'filter' => 'class_name=='.\models\summit\SpeakerSummitRegistrationPromoCode::ClassName,
|
|
'order' => '+code',
|
|
'columns' => 'code,type,owner_name,owner_email,sponsor_name,redeemed,email_sent',
|
|
'expand' => 'owner_name,owner_email,sponsor_name',
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getAllBySummitCSV",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$this->assertTrue(!is_null($content));
|
|
}
|
|
|
|
public function testGetPromoCodesByClassNameOR($summit_id=27){
|
|
$params = [
|
|
|
|
'id' => $summit_id,
|
|
'page' => 1,
|
|
'per_page' => 10,
|
|
'filter' => [
|
|
'class_name=='.\models\summit\SummitRegistrationDiscountCode::ClassName.','. 'class_name=='.\models\summit\MemberSummitRegistrationDiscountCode::ClassName,
|
|
],
|
|
'order' => '+code'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getAllBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$promo_codes = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_codes));
|
|
}
|
|
|
|
public function testGetPromoCodesByClassNameORInvalidClassName(){
|
|
$params = [
|
|
'id' => 23,
|
|
'page' => 1,
|
|
'per_page' => 10,
|
|
'filter' => [
|
|
'class_name=='.\models\summit\SpeakerSummitRegistrationPromoCode::ClassName.','. 'class_name==invalid'
|
|
],
|
|
'order' => '+code'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getAllBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(412);
|
|
}
|
|
|
|
public function testGetPromoCodesFilterByEmailOwner(){
|
|
$params = [
|
|
'id' => 23,
|
|
'page' => 1,
|
|
'per_page' => 10,
|
|
'filter' => [
|
|
'speaker_email=@muroi',
|
|
],
|
|
'order' => '+code',
|
|
'expand' => 'speaker,creator'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getAllBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$promo_codes = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_codes));
|
|
}
|
|
|
|
public function testGetPromoCodesMetadata(){
|
|
$params = [
|
|
'id' => 27,
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getMetadata",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$metadata = json_decode($content);
|
|
$this->assertTrue(!is_null($metadata));
|
|
}
|
|
|
|
public function testAddGenericDiscountCode( $summit_id = 27){
|
|
$code = str_random(16).'_DISCOUNT_CODE';
|
|
$params = ['rate' => 50.00];
|
|
return $this->testAddPromoCode
|
|
(
|
|
$summit_id,
|
|
$code,
|
|
\models\summit\SummitRegistrationDiscountCode::ClassName,
|
|
$params
|
|
);
|
|
}
|
|
|
|
public function testAddMemberDiscountCode( $summit_id = 27){
|
|
$code = str_random(16).'_MEMBER_DISCOUNT_CODE';
|
|
$params = [
|
|
'amount' => 100.00,
|
|
'email' => 'smarcet@gmail.com',
|
|
'first_name' => 'sebastian',
|
|
'last_name' => 'marcet',
|
|
'type' => PromoCodesConstants::MemberSummitRegistrationPromoCodeTypes[0]
|
|
];
|
|
return $this->testAddPromoCode
|
|
(
|
|
$summit_id,
|
|
$code,
|
|
\models\summit\MemberSummitRegistrationDiscountCode::ClassName,
|
|
$params
|
|
);
|
|
}
|
|
|
|
public function testAddPromoCode(
|
|
$summit_id = 27,
|
|
$code = "PROMOCODE",
|
|
$class_name =\models\summit\SummitRegistrationPromoCode::ClassName,
|
|
array $extra_params = []
|
|
){
|
|
$params = [
|
|
'id' => $summit_id,
|
|
];
|
|
|
|
$data = [
|
|
'code' => $code,
|
|
'class_name' => $class_name,
|
|
'quantity_available' => 100,
|
|
];
|
|
|
|
$data = array_merge($data, $extra_params);
|
|
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitPromoCodesApiController@addPromoCodeBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$promo_code = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_code));
|
|
return $promo_code;
|
|
}
|
|
|
|
public function testAddDiscountSpeakerCode($summit_id = 27, $code = ""){
|
|
$params = [
|
|
'id' => $summit_id,
|
|
];
|
|
|
|
if(empty($code))
|
|
$code = str_random(16).'_PROMOCODE';
|
|
$data = [
|
|
'code' => $code,
|
|
'class_name' => \models\summit\SpeakerSummitRegistrationDiscountCode::ClassName,
|
|
'quantity_available' => 100,
|
|
'speaker_id' => 1,
|
|
'type' => PromoCodesConstants::SpeakerSummitRegistrationPromoCodeTypeAccepted
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitPromoCodesApiController@addPromoCodeBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$promo_code = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_code));
|
|
return $promo_code;
|
|
}
|
|
|
|
public function testAddDiscountSpeakerCodeTicketRule($summit_id = 27){
|
|
$promo_code = $this->testAddDiscountSpeakerCode($summit_id);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code->id,
|
|
'ticket_type_id' => 105
|
|
];
|
|
|
|
$data = [
|
|
'rate' => 50.50
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitPromoCodesApiController@addTicketTypeToPromoCode",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$promo_code = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_code));
|
|
return $promo_code;
|
|
}
|
|
|
|
public function testUpdatePromoCode($summit_id = 27){
|
|
|
|
$code = str_random(16).'_PROMOCODE_TEST';
|
|
$promo_code = $this->testAddPromoCode($summit_id, $code);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code->id
|
|
];
|
|
|
|
$data = [
|
|
'code' => $code.'_UPDATE',
|
|
'class_name' => \models\summit\MemberSummitRegistrationPromoCode::ClassName,
|
|
'first_name' => 'Sebastian update',
|
|
'last_name' => 'Marcet update',
|
|
'email' => 'test@test.com',
|
|
'type' => PromoCodesConstants::MemberSummitRegistrationPromoCodeTypes[2]
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitPromoCodesApiController@updatePromoCodeBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$promo_code = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_code));
|
|
return $promo_code;
|
|
}
|
|
|
|
public function testDeletePromoCode($summit_id = 23){
|
|
|
|
$code = str_random(16).'_PROMOCODE_TEST';
|
|
$promo_code = $this->testAddPromoCode($summit_id, $code);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code->id
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"DELETE",
|
|
"OAuth2SummitPromoCodesApiController@deletePromoCodeBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(204);
|
|
}
|
|
|
|
public function testGetPromoCodeById($summit_id = 23){
|
|
|
|
$code = str_random(16).'_PROMOCODE_TEST';
|
|
$promo_code = $this->testAddPromoCode($summit_id, $code);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code->id
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitPromoCodesApiController@getPromoCodeBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$promo_code = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_code));
|
|
return $promo_code;
|
|
}
|
|
|
|
public function testEmailPromoCode($summit_id = 23){
|
|
|
|
$code = str_random(16).'_PROMOCODE_TEST';
|
|
$promo_code = $this->testAddPromoCode($summit_id, $code);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code->id
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitPromoCodesApiController@sendPromoCodeMail",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
}
|
|
|
|
public function testEmailPromoCodeSendTwice($summit_id = 23){
|
|
|
|
$code = str_random(16).'_PROMOCODE_TEST';
|
|
$promo_code = $this->testAddPromoCode($summit_id, $code);
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code->id
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitPromoCodesApiController@sendPromoCodeMail",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitPromoCodesApiController@sendPromoCodeMail",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(412);
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @param int $promo_code_id
|
|
* @param int $ticket_type_id
|
|
* @return mixed
|
|
*/
|
|
public function testAddDiscountCodeTicketRule($summit_id = 8 , $promo_code_id = 7 , $ticket_type_id = 7){
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code_id,
|
|
'ticket_type_id' => $ticket_type_id,
|
|
'expand' => 'ticket_types_rules,ticket_types_rules.discount_code'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$data = [
|
|
'rate' => 10,
|
|
'amount' => 0,
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitPromoCodesApiController@addTicketTypeToPromoCode",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$promo_code = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_code));
|
|
return $promo_code;
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @param int $promo_code_id
|
|
* @param int $ticket_type_id
|
|
* @return mixed
|
|
*/
|
|
public function testDeleteDiscountCodeTicketRule($summit_id = 8 , $promo_code_id = 7 , $ticket_type_id = 7){
|
|
$params = [
|
|
'id' => $summit_id,
|
|
'promo_code_id' => $promo_code_id,
|
|
'ticket_type_id' => $ticket_type_id
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$data = [
|
|
|
|
];
|
|
|
|
$response = $this->action(
|
|
"DELETE",
|
|
"OAuth2SummitPromoCodesApiController@removeTicketTypeFromPromoCode",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
// json_encode($data)
|
|
);
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$promo_code = json_decode($content);
|
|
$this->assertTrue(!is_null($promo_code));
|
|
return $promo_code;
|
|
}
|
|
} |