Skip to content

Commit

Permalink
fix: changes to SensitiveParameter test
Browse files Browse the repository at this point in the history
  • Loading branch information
heap-s committed Sep 3, 2024
1 parent c8ef853 commit 3b4be4c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/Db/Driver/PDO/PDODriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,20 @@ public function testGetUsername(): void

public function testSensitiveParameter(): void
{
if (PHP_VERSION_ID < 80200) {
$this->markTestSkipped('SensitiveParameterValue is not available in PHP < 8.2');
}
$dsn = 'sqlite::memory:';
try {
$fn = static function(#[\SensitiveParameter] string $password): void {
};
$fn(null);
} catch (\Throwable $e) {
$trace = $e->getTrace()[0];
$valid = isset($trace['args']) && $trace['args'][0] instanceof \SensitiveParameterValue;
var_dump($valid);
new PDODriver($dsn, password: null);
} catch (\TypeError $e) {
$this->assertTrue($e->getTrace()[0]['args'][2] instanceof \SensitiveParameterValue);
}
$pdoDriver = new PDODriver($dsn);
try {
$pdoDriver->password(null);
} catch (\TypeError $e) {
$this->assertTrue($e->getTrace()[0]['args'][0] instanceof \SensitiveParameterValue);
}
}
}

0 comments on commit 3b4be4c

Please sign in to comment.