Skip to content

Commit 2fd77fa

Browse files
committed
feat(HasSudoPassword): Add withoutSudoPassword method to clear sudo password
- Add withoutSudoPassword() to clear the sudo password by delegating to withSudoPassword(null) - Update tests to ensure withoutSudoPassword() yields a null sudo password before setting a new one - Preserve fluent interface by returning self from the new method - Provide clearer, explicit API for removing the sudo password when needed Signed-off-by: guanguans <[email protected]>
1 parent 0bd3a5d commit 2fd77fa

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

baselines/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 7 errors
1+
# total 8 errors
22

33
includes:
44
- assign.propertyType.neon
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
# total 1 error
1+
# total 2 errors
22

33
parameters:
44
ignoreErrors:
55
-
66
message: '#^Parameters should have "array" types as the only types passed to this method$#'
77
count: 1
88
path: ../src/Soar.php
9+
10+
-
11+
message: '#^Parameters should have "null" types as the only types passed to this method$#'
12+
count: 1
13+
path: ../src/Soar.php

src/Concerns/HasSudoPassword.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public function getSudoPassword(): ?string
2727
return $this->sudoPassword;
2828
}
2929

30+
public function withoutSudoPassword(): self
31+
{
32+
return $this->withSudoPassword(null);
33+
}
34+
3035
public function withSudoPassword(
3136
#[\SensitiveParameter]
3237
?string $sudoPassword

tests/Concerns/HasSudoPasswordTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
it('can set sudo password', function (): void {
2525
expect(Soar::make())
26+
->withoutSudoPassword()
27+
->getSudoPassword()->toBeNull()
2628
->withSudoPassword($sudoPassword = 'foo')
2729
->getSudoPassword()->toBe($sudoPassword);
2830
})->group(__DIR__, __FILE__);

0 commit comments

Comments
 (0)