/[drupal]/contributions/modules/gnupg/gnupg.test
ViewVC logotype

Contents of /contributions/modules/gnupg/gnupg.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Wed Feb 18 19:09:44 2009 UTC (9 months ago) by arto
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +5 -4 lines
File MIME type: text/x-php
Updated unit tests to take into account recent API changes.
1 <?php
2 // $Id$
3
4 //////////////////////////////////////////////////////////////////////////////
5 // Unit tests (compatible with Simpletest 2.x)
6
7 class GnupgTestCase extends DrupalWebTestCase {
8 const DATA = 'GnuPG for Drupal';
9
10 public function getInfo() {
11 return array(
12 'name' => t('Operations'),
13 'description' => t('Exercises the GnuPG API encryption/decryption operations.'),
14 'group' => t('GnuPG'),
15 );
16 }
17
18 public function test_configuration() {
19 $gnupg_exec = variable_get('gnupg_exec', gnupg_guess_binpath());
20 $this->assertTrue(file_exists($gnupg_exec), t('The GnuPG binary exists.'), t('Configuration'));
21 $this->assertTrue(is_executable($gnupg_exec), t('The GnuPG binary is executable.'), t('Configuration'));
22 $this->assertTrue(is_dir(GNUPG_HOMEDIR), t('The GnuPG home directory exists.'), t('Configuration'));
23 $this->assertTrue(is_readable(GNUPG_HOMEDIR), t('The GnuPG home directory is readable.'), t('Configuration'));
24 $this->assertTrue(GNUPG_KEYID != '', t('A GnuPG default key ID has been configured.'), t('Configuration')); // needed for later
25 }
26
27 public function test_version() {
28 $this->assertNotNull(gnupg_version(), t('GnuPG is installed.'), t('Version'));
29 $this->assertTrue(preg_match('!^\d+\.\d+\.\d+$!', gnupg_version()) > 0, t('The GnuPG version number is valid.'), t('Version'));
30 }
31
32 public function test_encrypt() {
33 $this->assertTrue(is_string(gnupg_encrypt(self::DATA)), t('Encryption succeeds.'), t('Encryption'));
34 $this->assertTrue(preg_match('!^-----BEGIN PGP MESSAGE-----!', gnupg_encrypt(self::DATA)), t('Encryption returns ciphertext.'), t('Encryption'));
35 }
36
37 public function test_decrypt() { /* TODO */ }
38 }

  ViewVC Help
Powered by ViewVC 1.1.2