Skip to content

Commit

Permalink
Merge branch 'BUG-602'
Browse files Browse the repository at this point in the history
  • Loading branch information
stevebauman committed Nov 9, 2023
2 parents bd7d2e0 + eeb7ccf commit aaaa1ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"ext-ldap": "*",
"ext-json": "*",
"ramsey/uuid": "*",
"directorytree/ldaprecord": "^v3.0",
"directorytree/ldaprecord": "^v3.3",
"illuminate/support": "^8.0|^9.0|^10.0"
},
"require-dev": {
Expand Down
14 changes: 10 additions & 4 deletions src/Testing/EmulatesQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ protected function getFirstRecordFromResult(Collection|array $result)
/**
* {@inheritdoc}
*/
public function insert($dn, array $attributes): bool
public function insertAndGetDn($dn, array $attributes): string|false
{
$dn = $this->substituteBaseDn($dn);

if (! Arr::get($attributes, 'objectclass')) {
throw new Exception('LDAP objects must have object classes to be created.');
}
Expand All @@ -390,7 +392,7 @@ public function insert($dn, array $attributes): bool
}
}

return true;
return $dn;
}

/**
Expand Down Expand Up @@ -501,16 +503,20 @@ protected function attributeValueIsGuid(array|string $value): bool
/**
* {@inheritdoc}
*/
public function rename($dn, $rdn, $newParentDn, $deleteOldRdn = true): bool
public function renameAndGetDn($dn, $rdn, $newParentDn, $deleteOldRdn = true): string|false
{
$newParentDn = $this->substituteBaseDn($newParentDn);

$database = $this->findEloquentModelByDn($dn);

if ($database) {
$database->name = $rdn;
$database->dn = implode(',', [$rdn, $newParentDn]);
$database->parent_dn = $newParentDn;

return $database->save();
$database->save();

return $database->dn;
}

return false;
Expand Down

0 comments on commit aaaa1ad

Please sign in to comment.