function setUp()
 {
     parent::setUp();
     $runnable = self::get_runnable();
     if (!isset($runnable)) {
         $canrun = true;
         if (defined('DPSPOST_USERNAME_TEST') && defined('DPSPOST_PASSWORD_TEST') && defined('DPSPAY_USERID_TEST') && defined('DPSPAY_KEY_TEST')) {
             $canrun &= DPSAdapter::get_pxpost_username() === DPSPOST_USERNAME_TEST;
             $canrun &= DPSAdapter::get_pxpost_password() === DPSPOST_PASSWORD_TEST;
             $canrun &= DPSAdapter::get_pxpay_userid() === DPSPAY_USERID_TEST;
             $canrun &= DPSAdapter::get_pxpay_key() === DPSPAY_KEY_TEST;
         } else {
             if (!defined('DPSPOST_USERNAME_TEST')) {
                 $this->markTestSkipped("Can't run test without setting up DPSPOST_USERNAME_TEST the Unit Testing");
             } else {
                 if (!defined('DPSPOST_PASSWORD_TEST')) {
                     $this->markTestSkipped("Can't run test without setting up DPSPOST_PASSWORD_TEST the Unit Testing");
                 } else {
                     if (!defined('DPSPAY_USERID_TEST')) {
                         $this->markTestSkipped("Can't run test without setting up DPSPAY_USERID_TEST the Unit Testing");
                     } else {
                         if (!defined('DPSPAY_KEY_TEST')) {
                             $this->markTestSkipped("Can't run test without setting up DPSPAY_KEY_TEST the Unit Testing");
                         }
                     }
                 }
             }
             $canrun = false;
         }
         if (!$canrun) {
             self::set_runnable(false);
         } else {
             $canrun &= DPSAdapter::postConnect();
             if (!$canrun) {
                 self::set_runnable(false);
                 $this->markTestSkipped("Can't run test without successfully test the connection to dps getway");
             } else {
                 self::set_runnable(true);
             }
         }
     }
 }
 function testPurchaseFailure()
 {
     $origUser = DPSAdapter::get_pxpost_username();
     $origPass = DPSAdapter::get_pxpost_password();
     $purchase = $this->createAPayment('NZD', '1.00');
     $purchase->purchase(self::get_wrong_cc_data());
     $this->assertEquals($purchase->Status, 'Failure');
     $this->assertContains('declined', $purchase->Message);
     $purchase->purchase(self::get_expired_cc_data());
     $this->assertEquals($purchase->Status, 'Failure');
     $this->assertContains('Card Expired', $purchase->Message);
     DPSAdapter::set_pxpost_account(DPSAdapter::get_pxpost_username(), 'wrongpass');
     $purchase->purchase(self::get_right_cc_data());
     $this->assertEquals($purchase->Status, 'Failure');
     $this->assertContains('The transaction was Declined', $purchase->Message);
     DPSAdapter::set_pxpost_account($origUser, $origPass);
 }