
Change-Id: I22f9b1fcad456c01ec3d151b03873a83a7a2afb4 Signed-off-by: smarcet <smarcet@gmail.com>
180 lines
5.1 KiB
PHP
180 lines
5.1 KiB
PHP
<?php namespace Tests;
|
|
/**
|
|
* Copyright 2021 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\Main\IGroup;
|
|
/**
|
|
* Class OAuth2SummitTrackChairsApiTest
|
|
* @package Tests
|
|
*/
|
|
class OAuth2SummitTrackChairsApiTest extends \ProtectedApiTest
|
|
{
|
|
use \InsertSummitTestData;
|
|
|
|
use \InsertMemberTestData;
|
|
|
|
protected function setUp()
|
|
{
|
|
$this->setCurrentGroup(IGroup::TrackChairs);
|
|
parent::setUp();
|
|
self::insertTestData();
|
|
self::$summit_permission_group->addMember(self::$member);
|
|
self::$em->persist(self::$summit);
|
|
self::$em->persist(self::$summit_permission_group);
|
|
self::$em->flush();
|
|
$track_chair = self::$summit->addTrackChair(self::$member, [ self::$defaultTrack ] );
|
|
self::$em->persist(self::$summit);
|
|
self::$em->flush();
|
|
}
|
|
|
|
protected function tearDown()
|
|
{
|
|
self::clearTestData();
|
|
parent::tearDown();
|
|
}
|
|
|
|
public function testGetAllTrackChairsPerSummit(){
|
|
$params = [
|
|
'summit_id' => self::$summit->getId(),
|
|
'filter' => 'track_id=='.self::$defaultTrack->getId(),
|
|
'page' => 1,
|
|
'per_page' => 10,
|
|
'order' => '+id',
|
|
'expand' => 'member,categories'
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"GET",
|
|
"OAuth2SummitTrackChairsApiController@getAllBySummit",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(200);
|
|
$track_chairs = json_decode($content);
|
|
$this->assertTrue(!is_null($track_chairs));
|
|
$this->assertTrue($track_chairs->total == 1);
|
|
return $track_chairs;
|
|
}
|
|
|
|
public function testAddTrackChair(){
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
'expand' => 'member,categories'
|
|
];
|
|
|
|
$data = [
|
|
'member_id' => self::$member2->getId(),
|
|
'categories' => [self::$defaultTrack->getId()]
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitTrackChairsApiController@add",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$track_chair = json_decode($content);
|
|
$this->assertTrue(!is_null($track_chair));
|
|
}
|
|
|
|
public function testUpdateTrackChair(){
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
'expand' => 'member,categories,categories.selection_lists'
|
|
];
|
|
|
|
$data = [
|
|
'member_id' => self::$member2->getId(),
|
|
'categories' => [self::$defaultTrack->getId()]
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"POST",
|
|
"OAuth2SummitTrackChairsApiController@add",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$track_chair = json_decode($content);
|
|
$this->assertTrue(!is_null($track_chair));
|
|
|
|
$params = [
|
|
'id' => self::$summit->getId(),
|
|
'track_chair_id' => $track_chair->id,
|
|
'expand' => 'member,categories,categories.selection_lists'
|
|
];
|
|
|
|
$data = [
|
|
'member_id' => self::$member2->getId(),
|
|
'categories' => [
|
|
self::$secondaryTrack->getId()
|
|
]
|
|
];
|
|
|
|
$headers = [
|
|
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
|
"CONTENT_TYPE" => "application/json"
|
|
];
|
|
|
|
$response = $this->action(
|
|
"PUT",
|
|
"OAuth2SummitTrackChairsApiController@update",
|
|
$params,
|
|
[],
|
|
[],
|
|
[],
|
|
$headers,
|
|
json_encode($data)
|
|
);
|
|
|
|
$content = $response->getContent();
|
|
$this->assertResponseStatus(201);
|
|
$track_chair = json_decode($content);
|
|
$this->assertTrue(!is_null($track_chair));
|
|
}
|
|
|
|
} |