source: trunk/tests/PayPalTest.php @ 1

Last change on this file since 1 was 1, checked in by scdev, 19 years ago

Initial import.

File size: 3.1 KB
Line 
1<?php
2/**
3 * PHPUnit test case for PayPal
4 *
5 * The method skeletons below need to be filled in with
6 * real data so that the tests will run correctly. Replace
7 * all EXPECTED_VAL and PARAM strings with real data.
8 *
9 * Created with PHPUnit_Skeleton on 2005-08-09
10 */
11require_once 'PHPUnit.php';
12class PayPalTest extends PHPUnit_TestCase {
13
14    var $PayPal;
15
16    function PayPalTest($name)
17    {
18        $this->PHPUnit_TestCase($name);
19    }
20
21    function setUp()
22    {
23        require dirname(__FILE__) . '/_config.inc.php';
24        require_once '../lib/PayPal.inc.php';
25        $this->PayPal =& new PayPal();
26
27        // Defaults for purchasing classified postings.
28        $this->PayPal->setButtonDefaults('web_accept', array(
29            'business' => 'paypal@example.com',
30            'item_name' => 'Test Button',
31            'no_shipping' => '1',
32            'no_note' => '1',
33            'currency_code' => 'USD',
34        ));
35    }
36
37    function tearDown()
38    {
39        unset($this->PayPal);
40    }
41
42    function test_setbuttondefaults()
43    {
44        $result = $this->PayPal->setButtonDefaults('web_accept', array(
45            'item_name' => 'Test Button',
46            'no_shipping' => '1',
47            'no_note' => '1',
48            'currency_code' => 'USD',
49        ));
50        $this->assertTrue($result);
51    }
52
53    function test_newbutton()
54    {
55        $result = $this->PayPal->newButton('web_accept', 'testitem', array(
56            'item_name' => 'Test Item',
57            'amount' => 1.23,
58            'custom' => 'customdata'
59        ));
60        $this->assertTrue($result);
61    }
62
63    function test_getlink()
64    {
65        $this->PayPal->newButton('web_accept', 'testitem', array(
66            'item_name' => 'Test Item',
67            'amount' => 1.23,
68            'custom' => 'customdata'
69        ));
70        $result = $this->PayPal->getlink('testitem');
71        $this->assertTrue(preg_match('/customdata/', $result));
72    }
73
74    function test_printbutton()
75    {
76        $this->PayPal->newButton('web_accept', 'testitem', array(
77            'item_name' => 'Test Item',
78            'amount' => 1.23,
79            'custom' => 'customdata'
80        ));
81        ob_start();
82        $this->PayPal->printbutton('testitem');
83        $result = ob_get_clean();
84        $this->assertTrue(preg_match('/customdata/', $result));
85    }
86
87    function test_setparam()
88    {
89        $this->PayPal->setparam(array('business' => 'business@example.com'));
90    }
91
92    function test_getparam()
93    {
94        $this->PayPal->setparam(array('business' => 'business@example.com'));
95        $result = $this->PayPal->getparam('business');
96        $this->assertEquals('business@example.com', $result);
97    }
98
99//     function test_incomingipnrequest()
100//     {
101//         $result = $this->PayPal->incomingipnrequest();
102//     }
103//
104//     function test_processipn()
105//     {
106//         $result = $this->PayPal->processipn();
107//     }
108//
109//     function test_verifiedipn()
110//     {
111//         $result = $this->PayPal->verifiedipn();
112//     }
113
114}
115// Running the test.
116$suite = new PHPUnit_TestSuite('PayPalTest');
117$result = PHPUnit::run($suite);
118echo $result->toString();
119?>
Note: See TracBrowser for help on using the repository browser.