annotate vendor/pear/crypt_gpg/tests/KeyTest.php @ 4:888e774ee983

libcalendar plugin as distributed
author Charlie Root
date Sat, 13 Jan 2018 08:57:56 -0500
parents 1e000243b222
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
1 <?php
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
2
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
4
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
5 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
6 * Key class test cases for the Crypt_GPG package.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
7 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
8 * These tests require the PHPUnit 3.6 or greater package to be installed.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
9 * PHPUnit is installable using PEAR. See the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
10 * {@link http://www.phpunit.de/manual/3.6/en/installation.html manual}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
11 * for detailed installation instructions.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
12 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
13 * To run these tests, use:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
14 * <code>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
15 * $ phpunit KeyTestCase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
16 * </code>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
17 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
18 * LICENSE:
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
19 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
20 * This library is free software; you can redistribute it and/or modify
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
21 * it under the terms of the GNU Lesser General Public License as
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
22 * published by the Free Software Foundation; either version 2.1 of the
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
23 * License, or (at your option) any later version.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
24 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
25 * This library is distributed in the hope that it will be useful,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
28 * Lesser General Public License for more details.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
29 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
30 * You should have received a copy of the GNU Lesser General Public
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
31 * License along with this library; if not, see
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
32 * <http://www.gnu.org/licenses/>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
33 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
34 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
35 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
36 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
37 * @copyright 2008-2010 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
38 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
39 * @version CVS: $Id$
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
40 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
41 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
42
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
43 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
44 * Base test case.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
45 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
46 require_once 'TestCase.php';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
47
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
48 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
49 * Key class.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
50 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
51 require_once 'Crypt/GPG/Key.php';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
52
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
53 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
54 * User id class.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
55 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
56 require_once 'Crypt/GPG/UserId.php';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
57
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
58 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
59 * Sub-key class.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
60 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
61 require_once 'Crypt/GPG/SubKey.php';
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
62
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
63 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
64 * Key class tests for Crypt_GPG.
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
65 *
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
66 * @category Encryption
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
67 * @package Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
68 * @author Michael Gauthier <mike@silverorange.com>
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
69 * @copyright 2008-2010 silverorange
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
70 * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
71 * @link http://pear.php.net/package/Crypt_GPG
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
72 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
73 class KeyTestCase extends Crypt_GPG_TestCase
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
74 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
75 // accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
76 // {{{ testGetSubKeys()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
77
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
78 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
79 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
80 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
81 public function testGetSubKeys()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
82 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
83 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
84
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
85 $firstSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
86 'id' => 'C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
87 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_DSA,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
88 'fingerprint' => '8D2299D9C5C211128B32BBB0C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
89 'length' => 1024,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
90 'creation' => 1221785805,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
91 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
92 'canSign' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
93 'canEncrypt' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
94 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
95 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
96
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
97 $key->addSubKey($firstSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
98
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
99 $secondSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
100 'id' => '9F93F9116728EF12',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
101 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
102 'fingerprint' => 'C9C65B3BBF040E40D0EA27B79F93F9116728EF12',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
103 'length' => 2048,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
104 'creation' => 1221785821,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
105 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
106 'canSign' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
107 'canEncrypt' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
108 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
109 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
110
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
111 $key->addSubKey($secondSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
112
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
113 $subKeys = $key->getSubKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
114 $this->assertTrue(is_array($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
115 'Failed to assert returned sub-keys is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
116
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
117 $this->assertEquals(2, count($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
118 'Failed to assert number of returned sub-keys is the same as ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
119 'the number of sub-keys added.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
120
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
121 $this->assertContainsOnly('Crypt_GPG_SubKey', $subKeys, false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
122 'Failed to assert all returned sub-keys are Crypt_GPG_SubKey ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
123 'objects.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
124
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
125 $this->assertArrayHasKey(0, $subKeys);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
126 $this->assertEquals($subKeys[0], $firstSubKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
127 'Failed to assert the first sub-key is the same as the first ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
128 'added sub-key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
129
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
130 $this->assertArrayHasKey(1, $subKeys);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
131 $this->assertEquals($subKeys[1], $secondSubKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
132 'Failed to assert the second sub-key is the same as the second ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
133 'added sub-key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
134 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
135
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
136 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
137 // {{{ testGetUserIds()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
138
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
139 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
140 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
141 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
142 public function testGetUserIds()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
143 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
144 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
145
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
146 $firstUserId = new Crypt_GPG_UserId(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
147 'name' => 'Alice',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
148 'comment' => 'shipping',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
149 'email' => 'alice@example.com'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
150 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
151
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
152 $key->addUserId($firstUserId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
153
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
154 $secondUserId = new Crypt_GPG_UserId(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
155 'name' => 'Bob',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
156 'comment' => 'receiving',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
157 'email' => 'bob@example.com'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
158 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
159
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
160 $key->addUserId($secondUserId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
161
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
162 $userIds = $key->getUserIds();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
163 $this->assertTrue(is_array($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
164 'Failed to assert returned user ids is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
165
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
166 $this->assertEquals(2, count($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
167 'Failed to assert number of returned user ids is the same as ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
168 'the number of user ids added.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
169
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
170 $this->assertContainsOnly('Crypt_GPG_UserId', $userIds, false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
171 'Failed to assert all returned user ids are Crypt_GPG_UserId ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
172 'objects.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
173
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
174 $this->assertArrayHasKey(0, $userIds);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
175 $this->assertEquals($userIds[0], $firstUserId,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
176 'Failed to assert the first user id is the same as the first ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
177 'added user id.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
178
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
179 $this->assertArrayHasKey(1, $userIds);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
180 $this->assertEquals($userIds[1], $secondUserId,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
181 'Failed to assert the second user id is the same as the second ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
182 'added user id.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
183 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
184
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
185 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
186 // {{{ testGetPrimaryKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
187
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
188 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
189 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
190 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
191 public function testGetPrimaryKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
192 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
193 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
194
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
195 $firstSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
196 'id' => 'C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
197 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_DSA,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
198 'fingerprint' => '8D2299D9C5C211128B32BBB0C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
199 'length' => 1024,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
200 'creation' => 1221785805,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
201 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
202 'canSign' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
203 'canEncrypt' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
204 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
205 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
206
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
207 $key->addSubKey($firstSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
208
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
209 $secondSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
210 'id' => '9F93F9116728EF12',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
211 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
212 'fingerprint' => 'C9C65B3BBF040E40D0EA27B79F93F9116728EF12',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
213 'length' => 2048,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
214 'creation' => 1221785821,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
215 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
216 'canSign' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
217 'canEncrypt' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
218 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
219 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
220
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
221 $key->addSubKey($secondSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
222
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
223 $primaryKey = $key->getPrimaryKey();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
224
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
225 $this->assertEquals($firstSubKey, $primaryKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
226 'Failed to assert the primary key is the same as the first added ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
227 'sub-key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
228 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
229
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
230 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
231 // {{{ testCanSign_none()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
232
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
233 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
234 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
235 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
236 public function testCanSign_none()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
237 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
238 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
239
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
240 $subKey = new Crypt_GPG_SubKey(array('canSign' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
241 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
242
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
243 $subKey = new Crypt_GPG_SubKey(array('canSign' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
244 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
245
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
246 $subKey = new Crypt_GPG_SubKey(array('canSign' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
247 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
248
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
249 $this->assertFalse($key->canSign());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
250 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
251
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
252 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
253 // {{{ testCanSign_one()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
254
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
255 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
256 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
257 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
258 public function testCanSign_one()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
259 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
260 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
261
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
262 $subKey = new Crypt_GPG_SubKey(array('canSign' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
263 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
264
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
265 $subKey = new Crypt_GPG_SubKey(array('canSign' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
266 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
267
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
268 $subKey = new Crypt_GPG_SubKey(array('canSign' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
269 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
270
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
271 $this->assertTrue($key->canSign());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
272 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
273
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
274 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
275 // {{{ testCanSign_all()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
276
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
277 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
278 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
279 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
280 public function testCanSign_all()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
281 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
282 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
283
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
284 $subKey = new Crypt_GPG_SubKey(array('canSign' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
285 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
286
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
287 $subKey = new Crypt_GPG_SubKey(array('canSign' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
288 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
289
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
290 $subKey = new Crypt_GPG_SubKey(array('canSign' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
291 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
292
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
293 $this->assertTrue($key->canSign());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
294 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
295
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
296 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
297 // {{{ testCanEncrypt_none()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
298
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
299 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
300 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
301 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
302 public function testCanEncrypt_none()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
303 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
304 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
305
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
306 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
307 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
308
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
309 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
310 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
311
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
312 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
313 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
314
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
315 $this->assertFalse($key->canEncrypt());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
316 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
317
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
318 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
319 // {{{ testCanEncrypt_one()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
320
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
321 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
322 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
323 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
324 public function testCanEncrypt_one()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
325 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
326 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
327
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
328 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
329 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
330
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
331 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => false));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
332 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
333
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
334 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
335 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
336
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
337 $this->assertTrue($key->canEncrypt());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
338 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
339
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
340 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
341 // {{{ testCanEncrypt_all()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
342
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
343 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
344 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
345 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
346 public function testCanEncrypt_all()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
347 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
348 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
349
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
350 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
351 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
352
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
353 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
354 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
355
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
356 $subKey = new Crypt_GPG_SubKey(array('canEncrypt' => true));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
357 $key->addSubKey($subKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
358
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
359 $this->assertTrue($key->canEncrypt());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
360 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
361
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
362 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
363 // {{{ test__toString()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
364
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
365 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
366 * @group accessors
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
367 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
368 public function test__toString()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
369 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
370 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
371
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
372 $firstSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
373 'id' => 'C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
374 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_DSA,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
375 'fingerprint' => '8D2299D9C5C211128B32BBB0C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
376 'length' => 1024,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
377 'creation' => 1221785805,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
378 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
379 'canSign' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
380 'canEncrypt' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
381 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
382 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
383
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
384 $this->assertSame((string) $key, '');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
385
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
386 $key->addSubKey($firstSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
387
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
388 $this->assertSame((string) $key, $firstSubKey->getId());
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
389 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
390
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
391 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
392
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
393 // mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
394 // {{{ testAddSubKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
395
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
396 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
397 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
398 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
399 public function testAddSubKey()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
400 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
401 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
402
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
403 $subKeys = $key->getSubKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
404 $this->assertTrue(is_array($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
405 'Failed to assert returned sub-keys is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
406
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
407 $this->assertEquals(0, count($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
408 'Failed to assert there are no sub-keys.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
409
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
410 // add first sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
411 $firstSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
412 'id' => 'C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
413 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_DSA,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
414 'fingerprint' => '8D2299D9C5C211128B32BBB0C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
415 'length' => 1024,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
416 'creation' => 1221785805,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
417 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
418 'canSign' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
419 'canEncrypt' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
420 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
421 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
422
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
423 $key->addSubKey($firstSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
424
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
425 $subKeys = $key->getSubKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
426 $this->assertTrue(is_array($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
427 'Failed to assert returned sub-keys is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
428
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
429 $this->assertEquals(1, count($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
430 'Failed to assert number of returned sub-keys is the same as ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
431 'the number of sub-keys added.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
432
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
433 $this->assertContainsOnly('Crypt_GPG_SubKey', $subKeys, false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
434 'Failed to assert all returned sub-keys are Crypt_GPG_SubKey ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
435 'objects.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
436
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
437 $this->assertArrayHasKey(0, $subKeys);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
438 $this->assertEquals($subKeys[0], $firstSubKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
439 'Failed to assert the first sub-key is the same as the first ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
440 'added sub-key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
441
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
442 // add second sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
443 $secondSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
444 'id' => '9F93F9116728EF12',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
445 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_ELGAMAL_ENC,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
446 'fingerprint' => 'C9C65B3BBF040E40D0EA27B79F93F9116728EF12',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
447 'length' => 2048,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
448 'creation' => 1221785821,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
449 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
450 'canSign' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
451 'canEncrypt' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
452 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
453 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
454
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
455 $key->addSubKey($secondSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
456
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
457 $subKeys = $key->getSubKeys();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
458 $this->assertTrue(is_array($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
459 'Failed to assert returned sub-keys is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
460
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
461 $this->assertEquals(2, count($subKeys),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
462 'Failed to assert number of returned sub-keys is the same as ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
463 'the number of sub-keys added.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
464
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
465 $this->assertContainsOnly('Crypt_GPG_SubKey', $subKeys, false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
466 'Failed to assert all returned sub-keys are Crypt_GPG_SubKey ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
467 'objects.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
468
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
469 $this->assertArrayHasKey(0, $subKeys);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
470 $this->assertEquals($subKeys[0], $firstSubKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
471 'Failed to assert the first sub-key is the same as the first ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
472 'added sub-key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
473
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
474 $this->assertArrayHasKey(1, $subKeys);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
475 $this->assertEquals($subKeys[1], $secondSubKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
476 'Failed to assert the second sub-key is the same as the second ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
477 'added sub-key.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
478 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
479
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
480 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
481 // {{{ testAddUserId()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
482
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
483 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
484 * @group mutators
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
485 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
486 public function testAddUserId()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
487 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
488 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
489
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
490 $userIds = $key->getUserIds();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
491 $this->assertTrue(is_array($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
492 'Failed to assert returned user ids is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
493
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
494 $this->assertEquals(0, count($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
495 'Failed to assert there are no user ids.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
496
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
497 // add first user id
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
498 $firstUserId = new Crypt_GPG_UserId(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
499 'name' => 'Alice',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
500 'comment' => 'shipping',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
501 'email' => 'alice@example.com'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
502 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
503
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
504 $key->addUserId($firstUserId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
505
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
506 $userIds = $key->getUserIds();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
507 $this->assertTrue(is_array($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
508 'Failed to assert returned user ids is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
509
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
510 $this->assertEquals(1, count($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
511 'Failed to assert number of returned user ids is the same as ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
512 'the number of user ids added.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
513
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
514 $this->assertContainsOnly('Crypt_GPG_UserId', $userIds, false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
515 'Failed to assert all returned user ids are Crypt_GPG_UserId ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
516 'objects.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
517
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
518 $this->assertArrayHasKey(0, $userIds);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
519 $this->assertEquals($userIds[0], $firstUserId,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
520 'Failed to assert the first user id is the same as the first ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
521 'added user id.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
522
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
523 // add second user id
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
524 $secondUserId = new Crypt_GPG_UserId(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
525 'name' => 'Bob',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
526 'comment' => 'receiving',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
527 'email' => 'bob@example.com'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
528 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
529
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
530 $key->addUserId($secondUserId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
531
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
532 $userIds = $key->getUserIds();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
533 $this->assertTrue(is_array($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
534 'Failed to assert returned user ids is an array.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
535
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
536 $this->assertEquals(2, count($userIds),
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
537 'Failed to assert number of returned user ids is the same as ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
538 'the number of user ids added.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
539
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
540 $this->assertContainsOnly('Crypt_GPG_UserId', $userIds, false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
541 'Failed to assert all returned user ids are Crypt_GPG_UserId ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
542 'objects.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
543
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
544 $this->assertArrayHasKey(0, $userIds);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
545 $this->assertEquals($userIds[0], $firstUserId,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
546 'Failed to assert the first user id is the same as the first ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
547 'added user id.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
548
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
549 $this->assertArrayHasKey(1, $userIds);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
550 $this->assertEquals($userIds[1], $secondUserId,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
551 'Failed to assert the second user id is the same as the second ' .
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
552 'added user id.');
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
553 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
554
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
555 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
556
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
557 // fluent interface
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
558 // {{{ testFluentInterface
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
559
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
560 /**
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
561 * @group fluent
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
562 */
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
563 public function testFluentInterface()
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
564 {
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
565 $key = new Crypt_GPG_Key();
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
566
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
567 // add first sub-key
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
568 $firstSubKey = new Crypt_GPG_SubKey(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
569 'id' => 'C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
570 'algorithm' => Crypt_GPG_SubKey::ALGORITHM_DSA,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
571 'fingerprint' => '8D2299D9C5C211128B32BBB0C097D9EC94C06363',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
572 'length' => 1024,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
573 'creation' => 1221785805,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
574 'expiration' => 0,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
575 'canSign' => true,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
576 'canEncrypt' => false,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
577 'hasPrivate' => true
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
578 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
579
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
580 $returnedKey = $key->addSubKey($firstSubKey);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
581
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
582 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
583 $key,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
584 $returnedKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
585 'Failed asserting fluent interface works for addSubKey() method.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
586 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
587
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
588 $firstUserId = new Crypt_GPG_UserId(array(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
589 'name' => 'Alice',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
590 'comment' => 'shipping',
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
591 'email' => 'alice@example.com'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
592 ));
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
593
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
594 $returnedKey = $key->addUserId($firstUserId);
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
595
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
596 $this->assertEquals(
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
597 $key,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
598 $returnedKey,
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
599 'Failed asserting fluent interface works for addUserId() method.'
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
600 );
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
601 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
602
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
603 // }}}
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
604 }
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
605
1e000243b222 vanilla 1.3.3 distro, I hope
Charlie Root
parents:
diff changeset
606 ?>