Refactore all test to be independent

This commit is contained in:
Jakub Zelenka 2018-05-17 20:15:14 +01:00
parent 3bb4d28798
commit 4aabe3c966
26 changed files with 306 additions and 108 deletions

View file

@ -0,0 +1,21 @@
--TEST--
delete a key from the keyring
--SKIPIF--
<?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE--
<?php
require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING);
$ret = $gpg->deletekey($fingerprint,true);
var_dump($ret);
?>
--EXPECT--
bool(true)
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -4,12 +4,13 @@ encrypt and decrypt a text
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$gpg->addencryptkey($fingerprint); $gpg->addencryptkey($fingerprint);
$enc = $gpg->encrypt($plaintext); $enc = $gpg->encrypt($plaintext);
$gpg = NULL;
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->adddecryptkey($fingerprint, $passphrase); $gpg->adddecryptkey($fingerprint, $passphrase);
@ -19,3 +20,8 @@ var_dump($ret);
?> ?>
--EXPECTF-- --EXPECTF--
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -4,16 +4,16 @@ encryptsign and decryptverify a text
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$gpg->addencryptkey($fingerprint); $gpg->addencryptkey($fingerprint);
$gpg->addsignkey($fingerprint, $passphrase); $gpg->addsignkey($fingerprint, $passphrase);
$enc = $gpg->encryptsign($plaintext); $enc = $gpg->encryptsign($plaintext);
$gpg = NULL;
$plaintext = false; $plaintext = false;
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->adddecryptkey($fingerprint, $passphrase); $gpg->adddecryptkey($fingerprint, $passphrase);
$ret = $gpg->decryptverify ($enc, $plaintext); $ret = $gpg->decryptverify ($enc, $plaintext);
@ -38,3 +38,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -4,7 +4,9 @@ export a key
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$ret = $gpg->export($fingerprint); $ret = $gpg->export($fingerprint);
@ -12,7 +14,6 @@ var_dump($ret);
?> ?>
--EXPECTF-- --EXPECTF--
string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK----- string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3 mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
@ -36,3 +37,8 @@ drhhPQJw1AY6GEpSbK0JtACeJuewK8C1wO1l5OYkGzFpb4VgquI=
=twR+ =twR+
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
" "
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,12 +1,12 @@
--TEST--n --TEST--
import a new key into the keyring import a new key into the keyring
--SKIPIF-- --SKIPIF--
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
@unlink (dirname(__FILE__)."/pubring.gpg"); gnupgt::delete_key();
@unlink (dirname(__FILE__)."/secring.gpg");
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$ret = $gpg->import($testkey); $ret = $gpg->import($testkey);
@ -33,3 +33,8 @@ array(9) {
["fingerprint"]=> ["fingerprint"]=>
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
} }
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -4,7 +4,9 @@ get keyinfo
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$ret = $gpg->keyinfo($fingerprint); $ret = $gpg->keyinfo($fingerprint);
@ -99,3 +101,8 @@ array(1) {
} }
} }
} }
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,10 +1,12 @@
--TEST--n --TEST--
list signatures list signatures
--SKIPIF-- --SKIPIF--
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$ret = $gpg->listsignatures($fingerprint); $ret = $gpg->listsignatures($fingerprint);
@ -35,3 +37,8 @@ array(1) {
} }
} }
} }
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -4,7 +4,9 @@ sign a text with sigmode SIG_MODE_CLEAR
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$gpg->setsignmode(gnupg::SIG_MODE_CLEAR); $gpg->setsignmode(gnupg::SIG_MODE_CLEAR);
@ -38,3 +40,8 @@ array(1) {
} }
string(8) "foo bar string(8) "foo bar
" "
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -4,7 +4,9 @@ sign a text with mode SIG_MODE_DETACH
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$gpg->setsignmode(gnupg::SIG_MODE_DETACH); $gpg->setsignmode(gnupg::SIG_MODE_DETACH);
@ -37,3 +39,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,10 +1,12 @@
--TEST--n --TEST--
sign a text with mode SIG_MODE_DETACH and without armored output sign a text with mode SIG_MODE_DETACH and without armored output
--SKIPIF-- --SKIPIF--
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$gpg->setarmor(0); $gpg->setarmor(0);
@ -38,3 +40,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,10 +1,12 @@
--TEST--n --TEST--
sign a text with mode SIG_MODE_NORMAL sign a text with mode SIG_MODE_NORMAL
--SKIPIF-- --SKIPIF--
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$gpg->setsignmode(gnupg::SIG_MODE_NORMAL); $gpg->setsignmode(gnupg::SIG_MODE_NORMAL);
@ -38,3 +40,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,10 +1,12 @@
--TEST--n --TEST--
sign a text with mode SIG_MODE_NORMAL and without armored output sign a text with mode SIG_MODE_NORMAL and without armored output
--SKIPIF-- --SKIPIF--
<?php if(!class_exists("gnupg")) die("skip"); ?> <?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = new gnupg(); $gpg = new gnupg();
$gpg->seterrormode(gnupg::ERROR_WARNING); $gpg->seterrormode(gnupg::ERROR_WARNING);
$gpg->setarmor(0); $gpg->setarmor(0);
@ -12,8 +14,6 @@ $gpg -> setsignmode(gnupg::SIG_MODE_NORMAL);
$gpg->addsignkey($fingerprint, $passphrase); $gpg->addsignkey($fingerprint, $passphrase);
$ret = $gpg->sign($plaintext); $ret = $gpg->sign($plaintext);
$gpg = NULL;
$gpg = new gnupg(); $gpg = new gnupg();
//$ret = $gpg->verify($plaintext, $ret); //$ret = $gpg->verify($plaintext, $ret);
$plaintext = false; $plaintext = false;
@ -39,3 +39,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,14 +0,0 @@
--TEST--n
delete a key from the keyring
--SKIPIF--
<?php if(!class_exists("gnupg")) die("skip"); ?>
--FILE--
<?php
require_once(dirname(__FILE__)."/vars.inc");
$gpg = new gnupg();
$gpg -> seterrormode(gnupg::ERROR_WARNING);
$ret = $gpg -> deletekey($fingerprint,true);
var_dump($ret);
?>
--EXPECT--
bool(true)

View file

@ -1,10 +1,12 @@
--TEST--n --TEST--
import a new key into the keyring import a new key into the keyring
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
@unlink (dirname(__FILE__)."/pubring.gpg"); gnupgt::delete_key();
@unlink (dirname(__FILE__)."/secring.gpg");
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
$ret = gnupg_import($gpg, $testkey); $ret = gnupg_import($gpg, $testkey);
@ -31,3 +33,8 @@ array(9) {
["fingerprint"]=> ["fingerprint"]=>
string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E" string(40) "64DF06E42FCF2094590CDEEE2E96F141B3DD2B2E"
} }
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST--n --TEST--n
delete a key from the keyring delete a key from the keyring
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
$ret = gnupg_deletekey($gpg, $fingerprint,true); $ret = gnupg_deletekey($gpg, $fingerprint,true);
@ -10,3 +14,8 @@ var_dump($ret);
?> ?>
--EXPECT-- --EXPECT--
bool(true) bool(true)
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST-- --TEST--
encrypt and decrypt a text encrypt and decrypt a text
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_addencryptkey($gpg, $fingerprint); gnupg_addencryptkey($gpg, $fingerprint);
@ -18,3 +22,8 @@ var_dump($ret);
?> ?>
--EXPECTF-- --EXPECTF--
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST-- --TEST--
encryptsign and decryptverify a text encryptsign and decryptverify a text
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_addencryptkey($gpg, $fingerprint); gnupg_addencryptkey($gpg, $fingerprint);
@ -36,3 +40,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST-- --TEST--
export a key export a key
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
$ret = gnupg_export($gpg, $fingerprint); $ret = gnupg_export($gpg, $fingerprint);
@ -10,7 +14,6 @@ var_dump($ret);
?> ?>
--EXPECTF-- --EXPECTF--
string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK----- string(%d) "-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3 mQGiBENQAKwRBADpy828KU+0SuoetJTrJ5dR86PiO3CsH8K6QRP7wY82Eh/9NTJ3
afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z afRj0FNPaVSP0NciPeM4G4uFoQ3lsIf+FBEPXH1D97/XigWObU8K6ha2/s8wU98z
@ -34,3 +37,8 @@ drhhPQJw1AY6GEpSbK0JtACeJuewK8C1wO1l5OYkGzFpb4VgquI=
=twR+ =twR+
-----END PGP PUBLIC KEY BLOCK----- -----END PGP PUBLIC KEY BLOCK-----
" "
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST--n --TEST--n
get keyinfo get keyinfo
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
$ret = gnupg_keyinfo($gpg, $fingerprint); $ret = gnupg_keyinfo($gpg, $fingerprint);
@ -97,3 +101,8 @@ array(1) {
} }
} }
} }
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST--n --TEST--n
list signatures list signatures
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
$ret = gnupg_listsignatures($gpg, $fingerprint); $ret = gnupg_listsignatures($gpg, $fingerprint);
@ -33,3 +37,8 @@ array(1) {
} }
} }
} }
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,16 +1,18 @@
--TEST--n --TEST--n
sign a text with sigmode SIG_MODE_CLEAR sign a text with sigmode SIG_MODE_CLEAR
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_CLEAR); gnupg_setsignmode($gpg, GNUPG_SIG_MODE_CLEAR);
gnupg_addsignkey($gpg, $fingerprint, $passphrase); gnupg_addsignkey($gpg, $fingerprint, $passphrase);
$ret = gnupg_sign($gpg, $plaintext); $ret = gnupg_sign($gpg, $plaintext);
$gpg = NULL;
$gpg = gnupg_init(); $gpg = gnupg_init();
$tmp = false; $tmp = false;
$ret = gnupg_verify($gpg, $ret, false, $tmp); $ret = gnupg_verify($gpg, $ret, false, $tmp);
@ -36,3 +38,8 @@ array(1) {
} }
string(8) "foo bar string(8) "foo bar
" "
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,16 +1,18 @@
--TEST--n --TEST--n
sign a text with mode SIG_MODE_DETACH sign a text with mode SIG_MODE_DETACH
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH); gnupg_setsignmode($gpg, GNUPG_SIG_MODE_DETACH);
gnupg_addsignkey($gpg, $fingerprint, $passphrase); gnupg_addsignkey($gpg, $fingerprint, $passphrase);
$ret = gnupg_sign($gpg, $plaintext); $ret = gnupg_sign($gpg, $plaintext);
$gpg = NULL;
$gpg = gnupg_init(); $gpg = gnupg_init();
$tmp = false; $tmp = false;
$ret = gnupg_verify($gpg,$plaintext, $ret); $ret = gnupg_verify($gpg,$plaintext, $ret);
@ -35,3 +37,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST--n --TEST--n
sign a text with mode SIG_MODE_DETACH and without armored output sign a text with mode SIG_MODE_DETACH and without armored output
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_setarmor($gpg, 0); gnupg_setarmor($gpg, 0);
@ -36,3 +40,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST--n --TEST--n
sign a text with mode SIG_MODE_NORMAL sign a text with mode SIG_MODE_NORMAL
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL); gnupg_setsignmode($gpg, GNUPG_SIG_MODE_NORMAL);
@ -36,3 +40,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

View file

@ -1,8 +1,12 @@
--TEST--n --TEST--n
sign a text with mode SIG_MODE_NORMAL and without armored output sign a text with mode SIG_MODE_NORMAL and without armored output
--SKIPIF--
<?php if (!extension_loaded("gnupg")) die("skip"); ?>
--FILE-- --FILE--
<?php <?php
require_once(dirname(__FILE__)."/vars.inc"); require_once "gnupgt.inc";
gnupgt::import_key();
$gpg = gnupg_init(); $gpg = gnupg_init();
gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING); gnupg_seterrormode($gpg, GNUPG_ERROR_WARNING);
gnupg_setarmor($gpg, 0); gnupg_setarmor($gpg, 0);
@ -36,3 +40,8 @@ array(1) {
} }
} }
string(7) "foo bar" string(7) "foo bar"
--CLEAN--
<?php
require_once "gnupgt.inc";
gnupgt::delete_key();
?>

21
tests/gnupgt.inc Normal file
View file

@ -0,0 +1,21 @@
<?php
require_once __DIR__ . "/vars.inc";
class gnupgt {
static function import_key()
{
global $testkey;
self::delete_key();
$gpg = new gnupg();
$gpg->import($testkey);
}
static function delete_key()
{
@unlink(__DIR__ . "/pubring.gpg");
@unlink(__DIR__ . "/secring.gpg");
}
}