* Copyright 2001-2012 Strangecode, LLC * * This file is part of The Strangecode Codebase. * * The Strangecode Codebase is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your option) * any later version. * * The Strangecode Codebase is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * The Strangecode Codebase. If not, see . */ /** * PHPUnit test case for codebase/lib/PayPal.inc.php * * The method skeletons below need to be filled in with * real data so that the tests will run correctly. Replace * all EXPECTED_VAL and PARAM strings with real data. * * Created with PHPUnit_Skeleton on 2005-08-09 */ class PayPalTest extends PHPUnit_Framework_TestCase { var $PayPal; function setUp() { require dirname(__FILE__) . '/_config.inc.php'; require_once '../lib/PayPal.inc.php'; $this->PayPal = new PayPal(); // Defaults for purchasing classified postings. $this->PayPal->setButtonDefaults('web_accept', array( 'business' => 'paypal@example.com', 'item_name' => 'Test Button', 'no_shipping' => '1', 'no_note' => '1', 'currency_code' => 'USD', )); } function tearDown() { unset($this->PayPal); } function test_setbuttondefaults() { $result = $this->PayPal->setButtonDefaults('web_accept', array( 'item_name' => 'Test Button', 'no_shipping' => '1', 'no_note' => '1', 'currency_code' => 'USD', )); $this->assertTrue($result); } function test_newbutton() { $result = $this->PayPal->newButton('web_accept', 'testitem', array( 'item_name' => 'Test Item', 'amount' => 1.23, 'custom' => 'customdata' )); $this->assertTrue($result); } function test_getlink() { $this->PayPal->newButton('web_accept', 'testitem', array( 'item_name' => 'Test Item', 'amount' => 1.23, 'custom' => 'customdata' )); $result = $this->PayPal->getlink('testitem'); //$this->assertTrue(preg_match('/customdata/', $result)); $this->assertSame(1, preg_match('/customdata/', $result)); } function test_printbutton() { $this->PayPal->newButton('web_accept', 'testitem', array( 'item_name' => 'Test Item', 'amount' => 1.23, 'custom' => 'customdata' )); ob_start(); $this->PayPal->printbutton('testitem'); $result = ob_get_clean(); //$this->assertTrue(preg_match('/customdata/', $result)); $this->assertSame(1, preg_match('/customdata/', $result)); } function test_setparam() { $this->PayPal->setparam(array('business' => 'business@example.com')); } function test_getparam() { $this->PayPal->setparam(array('business' => 'business@example.com')); $result = $this->PayPal->getparam('business'); $this->assertEquals('business@example.com', $result); } // function test_incomingipnrequest() // { // $result = $this->PayPal->incomingipnrequest(); // } // // function test_processipn() // { // $result = $this->PayPal->processipn(); // } // // function test_verifiedipn() // { // $result = $this->PayPal->verifiedipn(); // } }