Skip to content

Commit 9f1d980

Browse files
committed
Fixed issue with unused code; Corrected logic for unknown include
1 parent 929bc87 commit 9f1d980

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

api/controllers/BaseController.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,13 @@ class BaseController extends Controller
5252
* Get the company/companies
5353
*
5454
* @param int $id
55-
* @param string $relationships
5655
*
5756
* @return array
5857
*/
59-
public function callAction($id = 0, $relationships = '')
58+
public function callAction($id = 0)
6059
{
6160
$includes = $this->request->getQuery('includes', [Filter::FILTER_STRING, Filter::FILTER_TRIM], '');
6261
$parameters = $this->checkIdParameter($id);
63-
$parameter = $this->filter->sanitize($relationships, [Filter::FILTER_STRING, Filter::FILTER_TRIM]);
6462
$results = $this->getRecords($this->config, $this->cache, $this->model, $parameters, $this->orderBy);
6563
$related = [];
6664

@@ -70,11 +68,9 @@ public function callAction($id = 0, $relationships = '')
7068
if (true !== empty($includes)) {
7169
$requestedIncludes = explode(',', $includes);
7270
foreach ($requestedIncludes as $include) {
73-
if (true !== in_array($include, $this->includes)) {
74-
return $this->send404();
71+
if (true === in_array($include, $this->includes)) {
72+
$related[] = strtolower($include);
7573
}
76-
77-
$related[] = strtolower($include);
7874
}
7975
}
8076
}

tests/api/Companies/GetCest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function getCompany(ApiTester $I)
3636
/**
3737
* @param ApiTester $I
3838
*/
39-
public function getCompanyUnknownRelationship(ApiTester $I)
39+
public function getCompanyUnknownInclude(ApiTester $I)
4040
{
4141
$I->addApiUserRecord();
4242
$token = $I->apiLogin();
@@ -45,7 +45,13 @@ public function getCompanyUnknownRelationship(ApiTester $I)
4545
$I->haveHttpHeader('Authorization', 'Bearer ' . $token);
4646
$I->sendGET(sprintf(Data::$companiesRecordRelationshipUrl, $company->get('id'), 'unknown'));
4747
$I->deleteHeader('Authorization');
48-
$I->seeResponseIs404();
48+
$I->seeResponseIsSuccessful();
49+
$I->seeSuccessJsonResponse(
50+
'data',
51+
[
52+
Data::companyResponse($company),
53+
]
54+
);
4955
}
5056

5157
/**

0 commit comments

Comments
 (0)