Add complete coverage for init

This commit is contained in:
Jakub Zelenka 2018-06-04 19:29:56 +01:00
parent 587a5f9400
commit 1779a02f74
4 changed files with 81 additions and 1 deletions

View 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"

View file

@ -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);

View 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"

View 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);
?>