mirror of
https://github.com/php-gnupg/php-gnupg.git
synced 2024-11-21 14:07:10 +00:00
Add complete coverage for init
This commit is contained in:
parent
587a5f9400
commit
1779a02f74
4 changed files with 81 additions and 1 deletions
21
tests/gnupg_oo_init_file_name.phpt
Normal file
21
tests/gnupg_oo_init_file_name.phpt
Normal file
|
@ -0,0 +1,21 @@
|
|||
--TEST--
|
||||
init object with custom file_name
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!class_exists("gnupg")) {
|
||||
die("skip");
|
||||
}
|
||||
if (!file_exists('/usr/bin/gpg')) {
|
||||
die("skip /usr/bin/gpg does not exist");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once "gnupgt.inc";
|
||||
|
||||
$gpg = new gnupg(array('file_name' => '/usr/bin/gpg'));
|
||||
$engine = $gpg->getengineinfo();
|
||||
var_dump($engine['file_name']);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(12) "/usr/bin/gpg"
|
|
@ -18,12 +18,16 @@ foreach (glob("$homedir/*") as $filename) {
|
|||
$imported = true;
|
||||
}
|
||||
var_dump($imported);
|
||||
$engine = $gpg->getengineinfo();
|
||||
var_dump($engine['home_dir'] === $homedir);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
--CLEAN--
|
||||
<?php
|
||||
foreach (glob(__DIR__ . '/init_oo_home/*') as $filename) {
|
||||
$homedir = __DIR__ . '/init_oo_home';
|
||||
foreach (glob($homedir . '/*') as $filename) {
|
||||
unlink($filename);
|
||||
}
|
||||
rmdir($homedir);
|
||||
|
|
21
tests/gnupg_res_init_file_name.phpt
Normal file
21
tests/gnupg_res_init_file_name.phpt
Normal file
|
@ -0,0 +1,21 @@
|
|||
--TEST--
|
||||
init resource with custom file_name
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if(!class_exists("gnupg")) {
|
||||
die("skip");
|
||||
}
|
||||
if (!file_exists('/usr/bin/gpg')) {
|
||||
die("skip /usr/bin/gpg does not exist");
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once "gnupgt.inc";
|
||||
|
||||
$gpg = gnupg_init(array('file_name' => '/usr/bin/gpg'));
|
||||
$engine = gnupg_getengineinfo($gpg);
|
||||
var_dump($engine['file_name']);
|
||||
?>
|
||||
--EXPECT--
|
||||
string(12) "/usr/bin/gpg"
|
34
tests/gnupg_res_init_home_dir.phpt
Normal file
34
tests/gnupg_res_init_home_dir.phpt
Normal file
|
@ -0,0 +1,34 @@
|
|||
--TEST--
|
||||
init resource with custom home_dir
|
||||
--SKIPIF--
|
||||
<?php if(!class_exists("gnupg")) die("skip"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once "gnupgt.inc";
|
||||
$homedir = __DIR__ . '/init_res_home';
|
||||
if (!is_dir($homedir)) {
|
||||
mkdir($homedir);
|
||||
}
|
||||
|
||||
$gpg = gnupg_init(array('home_dir' => $homedir));
|
||||
gnupg_seterrormode($gpg, gnupg::ERROR_WARNING);
|
||||
gnupg_import($gpg, $testkey);
|
||||
$imported = false;
|
||||
foreach (glob("$homedir/*") as $filename) {
|
||||
$imported = true;
|
||||
}
|
||||
var_dump($imported);
|
||||
$engine = gnupg_getengineinfo($gpg);
|
||||
var_dump($engine['home_dir'] === $homedir);
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
||||
bool(true)
|
||||
--CLEAN--
|
||||
<?php
|
||||
$homedir = __DIR__ . '/init_res_home';
|
||||
foreach (glob($homedir . '/*') as $filename) {
|
||||
unlink($filename);
|
||||
}
|
||||
rmdir($homedir);
|
||||
?>
|
Loading…
Reference in a new issue