openstackid-resources/tests/OAuth2CompaniesApiTest.php
smarcet 600b417929 Company CRUDS
get all

GET api/v1/companies

add

POST api/v1/companies

payload

'name' => 'required|string',
'url' => 'nullable|url',
'display_on_site' => 'nullable|boolean',
'featured' => 'nullable|boolean',
'city' => 'nullable|string',
'state' => 'nullable|string',
'country' => 'nullable|string',
'description' => 'nullable|string',
'industry' => 'nullable|string',
'products' => 'nullable|string',
'contributions' => 'nullable|string',
'contact_email' => 'nullable|email',
'member_level' => 'nullable|string',
'admin_email' => 'nullable|email',
'color' => 'nullable|hex_color',
'overview' => 'nullable|string',
'commitment' => 'nullable|string',
'commitment_author' => 'nullable|string',

update

PUT api/v1/companies/{id}

'name' => 'sometimes|string',
'url' => 'nullable|url',
'display_on_site' => 'nullable|boolean',
'featured' => 'nullable|boolean',
'city' => 'nullable|string',
'state' => 'nullable|string',
'country' => 'nullable|string',
'description' => 'nullable|string',
'industry' => 'nullable|string',
'products' => 'nullable|string',
'contributions' => 'nullable|string',
'contact_email' => 'nullable|email',
'member_level' => 'nullable|string',
'admin_email' => 'nullable|email',
'color' => 'nullable|hex_color',
'overview' => 'nullable|string',
'commitment' => 'nullable|string',
'commitment_author' => 'nullable|string',

delete

DELETE api/v1/companies/{id}

get

GET api/v1/companies/{id}

add logo

POST api/v1/companies/{id}/logo

payload

file

delete logo

DELETE api/v1/companies/{id}/logo

add big logo

api/v1/companies/{id}/logo/big

payload

file

delete big logo

DELETE api/v1/companies/{id}/logo/big

Change-Id: Idac203571b31af6141f06d35bf1d3131a4636182
Signed-off-by: smarcet <smarcet@gmail.com>
2020-10-01 11:05:55 -03:00

78 lines
2.1 KiB
PHP

<?php
/**
* Copyright 2017 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.
**/
class OAuth2CompaniesApiTest extends ProtectedApiTest
{
public function testGetCompanies()
{
$params = [
//AND FILTER
'filter' => ['name=@Dell\,'],
'order' => '-id'
];
$headers = array("HTTP_Authorization" => " Bearer " . $this->access_token);
$response = $this->action(
"GET",
"OAuth2CompaniesApiController@getAllCompanies",
$params,
array(),
array(),
array(),
$headers
);
$content = $response->getContent();
$companies = json_decode($content);
$this->assertTrue(!is_null($companies));
$this->assertResponseStatus(200);
}
public function testAddCompany(){
$data = [
'name' => str_random(16).'_company',
'description' => str_random(16).'_description',
];
$headers = [
"HTTP_Authorization" => " Bearer " . $this->access_token,
"CONTENT_TYPE" => "application/json"
];
$response = $this->action(
"POST",
"OAuth2CompaniesApiController@add",
[],
[],
[],
[],
$headers,
json_encode($data)
);
$content = $response->getContent();
$this->assertResponseStatus(201);
$company = json_decode($content);
$this->assertTrue(!is_null($company));
return $company;
}
public function testAddCompanyBigLogo(){
}
}