Skip to content

Commit 504953f

Browse files
test(Session): lint/rector cleanup of CryptoSessionDataTest
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent f8756b1 commit 504953f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/lib/Session/CryptoSessionDataTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ protected function setUp(): void {
4343
$this->crypto = $this->createMock(ICrypto::class);
4444

4545
$this->crypto->method('encrypt')->willReturnCallback(
46-
fn($input) => '#' . $input . '#'
46+
fn ($input) => '#' . $input . '#'
4747
);
4848
$this->crypto->method('decrypt')->willReturnCallback(
49-
fn($input) => ($input === '' || strlen($input) < 2) ? '' : substr($input, 1, -1)
49+
fn ($input) => ($input === '' || strlen($input) < 2) ? '' : substr($input, 1, -1)
5050
);
5151

5252
$this->session = new Memory();
@@ -59,7 +59,7 @@ protected function setUp(): void {
5959
public function testSessionDataStoredEncrypted(): void {
6060
$keyName = 'secret';
6161
$unencryptedValue = 'superSecretValue123';
62-
62+
6363
$this->instance->set($keyName, $unencryptedValue);
6464
$this->instance->close();
6565

@@ -89,11 +89,11 @@ public function testRoundTripValue($key, $value): void {
8989

9090
public static function roundTripValuesProvider(): array {
9191
return [
92-
'simple string' => ['foo', 'bar'],
93-
'unicode value' => ['uni', "héllo 🌍"],
94-
'large value' => ['big', str_repeat('x', 4096)],
95-
'large array' => ['thousand', json_encode(self::makeLargeArray())],
96-
'empty string' => ['', ''],
92+
'simple string' => ['foo', 'bar'],
93+
'unicode value' => ['uni', "héllo 🌍"],
94+
'large value' => ['big', str_repeat('x', 4096)],
95+
'large array' => ['thousand', json_encode(self::makeLargeArray())],
96+
'empty string' => ['', ''],
9797
];
9898
}
9999

@@ -166,11 +166,11 @@ public function testWrongPassphraseGivesNoAccess(): void {
166166
private function createPassphraseAwareCryptoMock(): ICrypto {
167167
$crypto = $this->createMock(ICrypto::class);
168168

169-
$crypto->method('encrypt')->willReturnCallback(function($plain, $passphrase = null) {
169+
$crypto->method('encrypt')->willReturnCallback(function ($plain, $passphrase = null) {
170170
// Set up: store a value with the passphrase embedded (fake encryption)
171171
return $passphrase . '#' . $plain . '#' . $passphrase;
172172
});
173-
$crypto->method('decrypt')->willReturnCallback(function($input, $passphrase = null) {
173+
$crypto->method('decrypt')->willReturnCallback(function ($input, $passphrase = null) {
174174
// Only successfully decrypt if the embedded passphrase matches
175175
if (strpos($input, $passphrase . '#') === 0 && strrpos($input, '#' . $passphrase) === strlen($input) - strlen('#' . $passphrase)) {
176176
// Strip off passphrase markers and return the "decrypted" string

0 commit comments

Comments
 (0)