forked from clifgriffin/shopp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomerAPITests.php
executable file
·365 lines (307 loc) · 9.03 KB
/
CustomerAPITests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?php
/**
* CustomerAPITests$1
*
* @author Jonathan Davis
* @version 1.0
* @copyright Ingenesis Limited, 1 December, 2009
* @package shopp
* @subpackage tests
**/
class CustomerAPITests extends ShoppTestCase {
public static function setUpBeforeClass () {
shopp_set_setting('account_system', 'wordpress');
$Shopp = Shopp::object();
$Shopp->Flow->Controller = new ShoppStorefront();
// Create the WordPress account
$wpuser = wp_insert_user(array(
'user_login' => 'bones',
'user_pass' => 'imadoctornotanengineer',
'user_email' => '[email protected]',
'display_name' => 'Dr. Leonard McCoy',
'nickname' => 'Bones',
'first_name' => 'Leonard',
'last_name' => 'McCoy'
));
$customerid = shopp_add_customer(array(
'wpuser' => $wpuser,
'firstname' => 'Leonard',
'lastname' => 'McCoy',
'email' => '[email protected]',
'phone' => '999-999-1701',
'company' => 'Starfleet Command',
'marketing' => 'no',
'type' => 'Tax-Exempt',
'saddress' => '24-593 Federation Dr',
'sxaddress' => 'Shipping',
'scity' => 'San Francisco',
'sstate' => 'CA',
'scountry' => 'US',
'spostcode' => '94123',
'baddress' => '24-593 Federation Dr',
'bxaddress' => 'Billing',
'bcity' => 'San Francisco',
'bstate' => 'CA',
'bcountry' => 'US',
'bpostcode' => '94123',
'residential' => true
));
shopp_add_product(array(
'name' => 'USS Enterprise',
'publish' => array('flag' => true),
'single' => array(
'type' => 'Shipped',
'price' => 1701,
'sale' => array(
'flag' => true,
'price' => 17.01
),
'taxed'=> true,
'shipping' => array('flag' => true, 'fee' => 1.50, 'weight' => 52.7, 'length' => 285.9, 'width' => 125.6, 'height' => 71.5),
'inventory' => array(
'flag' => true,
'stock' => 1,
'sku' => 'NCC-1701'
)
),
'specs' => array(
'Class' => 'Constitution',
'Category' => 'Heavy Cruiser',
'Decks' => 23,
'Officers' => 40,
'Crew' => 390,
'Max Vistors' => 50,
'Max Accommodations' => 800,
'Phaser Force Rating' => '2.5 MW',
'Torpedo Force Rating' => '9.7 isotons'
)
));
}
static function tearDownAfterClass () {
shopp_set_setting('account_system', 'none');
$Customer = shopp_customer('[email protected]','email');
wp_delete_user( $Customer->wpuser );
}
function test_customer_accounturl () {
$actual = shopp('customer.get-accounturl');
$this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?shopp_page=account', $actual);
}
function test_customer_recoverurl () {
ob_start();
shopp('customer','recover-url');
$actual = ob_get_contents();
ob_end_clean();
$this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?shopp_page=account&recover',$actual);
}
function test_customer_process () {
$this->assertEquals(null,shopp('customer','process'));
}
function test_customer_loggedin () {
$this->assertTrue(shopp('customer','loggedin'));
}
function test_customer_notloggedin () {
$this->assertFalse(shopp('customer','notloggedin'));
}
function test_customer_loginlabel () {
ob_start();
shopp('customer','login-label');
$actual = ob_get_contents();
ob_end_clean();
$this->assertEquals('Login Name',$actual);
}
function test_customer_accountlogin () {
ob_start();
shopp('customer','account-login');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'account-login','id' => 'account-login')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_passwordlogin () {
ob_start();
shopp('customer','password-login');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'password','name' => 'password-login','id' => 'password-login')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_recoverbutton () {
ob_start();
shopp('customer','recover-button');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'submit','name' => 'recover-login','id' => 'recover-button')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_loginbutton () {
ob_start();
shopp('customer','login-button');
$actual = ob_get_contents();
ob_end_clean();
$this->assertValidMarkup($actual);
}
function test_customer_accounts () {
ob_start();
shopp('customer','accounts');
$actual = ob_get_contents();
ob_end_clean();
$this->assertEquals('wordpress',$actual);
}
function test_customer_orderlookup () {
ob_start();
shopp('customer','order-lookup');
$actual = ob_get_contents();
ob_end_clean();
$this->assertValidMarkup($actual);
}
function test_customer_firstname () {
ob_start();
shopp('customer','firstname');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'firstname','id' => 'firstname')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_lastname () {
ob_start();
shopp('customer','lastname');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'lastname','id' => 'lastname')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_company () {
ob_start();
shopp('customer','company');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'company','id' => 'company')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_email () {
ob_start();
shopp('customer','email');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'email','id' => 'email')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_loginname () {
ob_start();
shopp('customer','loginname');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'loginname','id' => 'login','autocomplete'=>'off')
);
$this->assertTag($expected,$actual,$actual,true);
$this->assertValidMarkup($actual);
}
function test_customer_password () {
ob_start();
shopp('customer','password');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'password','name' => 'password','id' => 'password')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_confirmpassword () {
ob_start();
shopp('customer','confirm-password');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'password','name' => 'confirm-password','id' => 'confirm-password')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_phone () {
ob_start();
shopp('customer','phone');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'phone','id' => 'phone')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
function test_customer_info_tags () {
$this->assertFalse(shopp('customer','hasinfo'));
ob_start();
shopp('customer','info','type=text&name=Test Field');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'text','name' => 'info[Test Field]','id' => 'customer-info-test-field')
);
$this->assertTag($expected,$actual,$actual,true);
$this->assertValidMarkup($actual);
}
function test_customer_savebutton () {
ob_start();
shopp('customer','save-button');
$actual = ob_get_contents();
ob_end_clean();
$expected = array(
'tag' => 'input',
'attributes' => array('type' => 'submit','name' => 'save','id' => 'save-button')
);
$this->assertTag($expected,$actual,'',true);
$this->assertValidMarkup($actual);
}
// function test_customer_download_tags () {
//
// }
function test_customer_purchase_tags () {
$Customer = shopp_customer('[email protected]', 'email');
$Product = shopp_product('uss-enterprise', 'slug');
shopp_add_cart_product ( $Product->id, 1 );
$Purchase = shopp_add_order($Customer->id);
ob_start();
if (shopp('customer','has-purchases')) {
while (shopp('customer','purchases'))
shopp('customer','order');
}
$actual = ob_get_contents();
ob_end_clean();
$this->assertEquals('http://' . WP_TESTS_DOMAIN . '/?shopp_page=account&orders=1',$actual);
}
} // end CustomerAPITests class