[1] | 1 | <?php |
---|
| 2 | /** |
---|
[362] | 3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
| 4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
[396] | 5 | * Copyright 2001-2012 Strangecode, LLC |
---|
[362] | 6 | * |
---|
| 7 | * This file is part of The Strangecode Codebase. |
---|
[42] | 8 | * |
---|
[362] | 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 | * |
---|
[42] | 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 | * |
---|
[1] | 30 | * Created with PHPUnit_Skeleton on 2005-08-09 |
---|
| 31 | */ |
---|
| 32 | |
---|
[468] | 33 | class PayPalTest extends PHPUnit_Framework_TestCase { |
---|
| 34 | |
---|
[1] | 35 | var $PayPal; |
---|
| 36 | |
---|
| 37 | function setUp() |
---|
| 38 | { |
---|
| 39 | require dirname(__FILE__) . '/_config.inc.php'; |
---|
| 40 | require_once '../lib/PayPal.inc.php'; |
---|
[468] | 41 | $this->PayPal = new PayPal(); |
---|
[1] | 42 | |
---|
| 43 | // Defaults for purchasing classified postings. |
---|
| 44 | $this->PayPal->setButtonDefaults('web_accept', array( |
---|
| 45 | 'business' => 'paypal@example.com', |
---|
| 46 | 'item_name' => 'Test Button', |
---|
| 47 | 'no_shipping' => '1', |
---|
| 48 | 'no_note' => '1', |
---|
| 49 | 'currency_code' => 'USD', |
---|
| 50 | )); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | function tearDown() |
---|
| 54 | { |
---|
| 55 | unset($this->PayPal); |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | function test_setbuttondefaults() |
---|
| 59 | { |
---|
| 60 | $result = $this->PayPal->setButtonDefaults('web_accept', array( |
---|
| 61 | 'item_name' => 'Test Button', |
---|
| 62 | 'no_shipping' => '1', |
---|
| 63 | 'no_note' => '1', |
---|
| 64 | 'currency_code' => 'USD', |
---|
| 65 | )); |
---|
| 66 | $this->assertTrue($result); |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | function test_newbutton() |
---|
| 70 | { |
---|
| 71 | $result = $this->PayPal->newButton('web_accept', 'testitem', array( |
---|
| 72 | 'item_name' => 'Test Item', |
---|
| 73 | 'amount' => 1.23, |
---|
| 74 | 'custom' => 'customdata' |
---|
| 75 | )); |
---|
| 76 | $this->assertTrue($result); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | function test_getlink() |
---|
| 80 | { |
---|
| 81 | $this->PayPal->newButton('web_accept', 'testitem', array( |
---|
| 82 | 'item_name' => 'Test Item', |
---|
| 83 | 'amount' => 1.23, |
---|
| 84 | 'custom' => 'customdata' |
---|
| 85 | )); |
---|
| 86 | $result = $this->PayPal->getlink('testitem'); |
---|
[468] | 87 | //$this->assertTrue(preg_match('/customdata/', $result)); |
---|
| 88 | $this->assertSame(1, preg_match('/customdata/', $result)); |
---|
[1] | 89 | } |
---|
| 90 | |
---|
| 91 | function test_printbutton() |
---|
| 92 | { |
---|
| 93 | $this->PayPal->newButton('web_accept', 'testitem', array( |
---|
| 94 | 'item_name' => 'Test Item', |
---|
| 95 | 'amount' => 1.23, |
---|
| 96 | 'custom' => 'customdata' |
---|
| 97 | )); |
---|
| 98 | ob_start(); |
---|
| 99 | $this->PayPal->printbutton('testitem'); |
---|
| 100 | $result = ob_get_clean(); |
---|
[468] | 101 | //$this->assertTrue(preg_match('/customdata/', $result)); |
---|
| 102 | $this->assertSame(1, preg_match('/customdata/', $result)); |
---|
| 103 | |
---|
[1] | 104 | } |
---|
| 105 | |
---|
| 106 | function test_setparam() |
---|
| 107 | { |
---|
| 108 | $this->PayPal->setparam(array('business' => 'business@example.com')); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | function test_getparam() |
---|
| 112 | { |
---|
| 113 | $this->PayPal->setparam(array('business' => 'business@example.com')); |
---|
| 114 | $result = $this->PayPal->getparam('business'); |
---|
| 115 | $this->assertEquals('business@example.com', $result); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | // function test_incomingipnrequest() |
---|
| 119 | // { |
---|
| 120 | // $result = $this->PayPal->incomingipnrequest(); |
---|
| 121 | // } |
---|
[42] | 122 | // |
---|
[1] | 123 | // function test_processipn() |
---|
| 124 | // { |
---|
| 125 | // $result = $this->PayPal->processipn(); |
---|
| 126 | // } |
---|
[42] | 127 | // |
---|
[1] | 128 | // function test_verifiedipn() |
---|
| 129 | // { |
---|
| 130 | // $result = $this->PayPal->verifiedipn(); |
---|
| 131 | // } |
---|
| 132 | |
---|
| 133 | } |
---|