From 2aafefafb2c611d5368abc3ffe68986f9472e961 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Tue, 9 Dec 2025 15:25:37 +1100 Subject: [PATCH] Add new test for PRAGMA cipher_status (new in 4.12.0) --- tests/test_sqlcipher.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_sqlcipher.php b/tests/test_sqlcipher.php index 663e015..f96af03 100644 --- a/tests/test_sqlcipher.php +++ b/tests/test_sqlcipher.php @@ -105,6 +105,18 @@ function cipherIntegrityOk(PDO $dbh): bool { return ($row === false); // no rows == OK } +/** + * cipher_status returns: + * - 1 (ok) + * https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_status + */ +function cipherStatus(PDO $dbh): bool { + $stmt = $dbh->query("PRAGMA cipher_status;"); + if (!$stmt) return false; // query failed -> not OK + $row = $stmt->fetch(PDO::FETCH_NUM); + return ($row[0] == "1"); +} + // ---------------------------- Main actions ---------------------------- function createAndPopulate(string $path, string $passphrase, string $marker): void { @@ -128,6 +140,10 @@ function createAndPopulate(string $path, string $passphrase, string $marker): vo $ok = cipherIntegrityOk($dbh); check("cipher_integrity_check", $ok, $ok ? "no rows (OK)" : "reported errors"); + // Status check should be OK (new in 4.12.0 - returns 1 if ok) + $ok = cipherStatus($dbh); + check("cipher_status", $ok, $ok ? "row result = 1 (OK)" : "reported errors"); + // Capture page_size (for entropy sampling) $pageSize = (int)(pragmaOne($dbh, "page_size") ?? 4096); $dbh = null; // close