Skip to content

Commit 4188895

Browse files
committed
Fixes Parsing errors when name is an empty object
Fixes #138
1 parent d4dafdf commit 4188895

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/Attribute/Complex.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ public function replace($value, Model &$object, Path $path = null, $removeIfNotS
215215
return;
216216
}
217217

218+
// if value is empty, nothing to do
219+
if (empty($value)) {
220+
return;
221+
}
222+
218223
// if there is no path, keys of value are attribute paths
219224
foreach ($value as $key => $v) {
220225
if (is_numeric($key)) {

tests/BasicTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,37 @@ public function testTotalResultsOnly(){
524524
$response = $this->get('/scim/v2/Users?count=0');
525525
$this->assertTrue(true);
526526
}
527+
528+
public function testPostTopLevelEmptyName()
529+
{
530+
$response = $this->post('/scim/v2/Users', [
531+
// "id" => 1,
532+
"schemas" => [
533+
"urn:ietf:params:scim:schemas:core:2.0:User",
534+
],
535+
"name" => [],
536+
"userName" => "Dr. Marie Jo",
537+
"password" => "Password123",
538+
"emails" => [
539+
[
540+
"value" => "[email protected]",
541+
"type" => "primary",
542+
"primary" => true
543+
]
544+
]
545+
546+
]);
547+
548+
$this->assertEquals(
549+
201,
550+
$response->baseResponse->getStatusCode(),
551+
'Wrong status: ' . $response->baseResponse->content()
552+
);
553+
554+
$json = $response->json();
555+
556+
$this->assertArrayHasKey('urn:ietf:params:scim:schemas:core:2.0:User', $json);
557+
$this->assertEquals('[email protected]', $json['urn:ietf:params:scim:schemas:core:2.0:User']['emails'][0]['value']);
558+
$this->assertEquals('Dr. Marie Jo', $json['urn:ietf:params:scim:schemas:core:2.0:User']['userName']);
559+
}
527560
}

0 commit comments

Comments
 (0)