source: tags/2.1.5/tests/PayPalTest.php @ 377

Last change on this file since 377 was 377, checked in by quinn, 14 years ago

Releasing trunk as stable version 2.1.5

File size: 4.0 KB
Line 
1<?php
2/**
3 * The Strangecode Codebase - a general application development framework for PHP
4 * For details visit the project site: <http://trac.strangecode.com/codebase/>
5 * Copyright 2001-2010 Strangecode, LLC
6 *
7 * This file is part of The Strangecode Codebase.
8 *
9 * The Strangecode Codebase is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your option)
12 * any later version.
13 *
14 * The Strangecode Codebase is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23/**
24 * PHPUnit test case for codebase/lib/PayPal.inc.php
25 *
26 * The method skeletons below need to be filled in with
27 * real data so that the tests will run correctly. Replace
28 * all EXPECTED_VAL and PARAM strings with real data.
29 *
30 * Created with PHPUnit_Skeleton on 2005-08-09
31 */
32require_once 'PHPUnit.php';
33class PayPalTest extends PHPUnit_TestCase {
34
35    var $PayPal;
36
37    function PayPalTest($name)
38    {
39        $this->PHPUnit_TestCase($name);
40    }
41
42    function setUp()
43    {
44        require dirname(__FILE__) . '/_config.inc.php';
45        require_once '../lib/PayPal.inc.php';
46        $this->PayPal =& new PayPal();
47
48        // Defaults for purchasing classified postings.
49        $this->PayPal->setButtonDefaults('web_accept', array(
50            'business' => 'paypal@example.com',
51            'item_name' => 'Test Button',
52            'no_shipping' => '1',
53            'no_note' => '1',
54            'currency_code' => 'USD',
55        ));
56    }
57
58    function tearDown()
59    {
60        unset($this->PayPal);
61    }
62
63    function test_setbuttondefaults()
64    {
65        $result = $this->PayPal->setButtonDefaults('web_accept', array(
66            'item_name' => 'Test Button',
67            'no_shipping' => '1',
68            'no_note' => '1',
69            'currency_code' => 'USD',
70        ));
71        $this->assertTrue($result);
72    }
73
74    function test_newbutton()
75    {
76        $result = $this->PayPal->newButton('web_accept', 'testitem', array(
77            'item_name' => 'Test Item',
78            'amount' => 1.23,
79            'custom' => 'customdata'
80        ));
81        $this->assertTrue($result);
82    }
83
84    function test_getlink()
85    {
86        $this->PayPal->newButton('web_accept', 'testitem', array(
87            'item_name' => 'Test Item',
88            'amount' => 1.23,
89            'custom' => 'customdata'
90        ));
91        $result = $this->PayPal->getlink('testitem');
92        $this->assertTrue(preg_match('/customdata/', $result));
93    }
94
95    function test_printbutton()
96    {
97        $this->PayPal->newButton('web_accept', 'testitem', array(
98            'item_name' => 'Test Item',
99            'amount' => 1.23,
100            'custom' => 'customdata'
101        ));
102        ob_start();
103        $this->PayPal->printbutton('testitem');
104        $result = ob_get_clean();
105        $this->assertTrue(preg_match('/customdata/', $result));
106    }
107
108    function test_setparam()
109    {
110        $this->PayPal->setparam(array('business' => 'business@example.com'));
111    }
112
113    function test_getparam()
114    {
115        $this->PayPal->setparam(array('business' => 'business@example.com'));
116        $result = $this->PayPal->getparam('business');
117        $this->assertEquals('business@example.com', $result);
118    }
119
120//     function test_incomingipnrequest()
121//     {
122//         $result = $this->PayPal->incomingipnrequest();
123//     }
124//
125//     function test_processipn()
126//     {
127//         $result = $this->PayPal->processipn();
128//     }
129//
130//     function test_verifiedipn()
131//     {
132//         $result = $this->PayPal->verifiedipn();
133//     }
134
135}
136// Running the test.
137$suite = new PHPUnit_TestSuite('PayPalTest');
138$result = PHPUnit::run($suite);
139echo $result->toString();
140?>
Note: See TracBrowser for help on using the repository browser.