public function testBackClickPayPalToGC()
 {
     $options = $this->getDonorTestData('US');
     $options['payment_method'] = 'paypal';
     $options['ffname'] = 'paypal';
     $paypalRequest = $this->setUpRequest($options);
     $gateway = new TestingPaypalLegacyAdapter();
     $gateway->do_transaction('Donate');
     $paymentForms = $paypalRequest->getSessionData('PaymentForms');
     //check to see that we have a numAttempt and form set in the session
     $this->assertEquals('paypal', $paymentForms[0], "Paypal didn't load its form.");
     $this->assertEquals('1', $paypalRequest->getSessionData('numAttempt'), "We failed to record the initial paypal attempt in the session");
     //now, get GC.
     $options['payment_method'] = 'cc';
     unset($options['ffname']);
     $this->setUpRequest($options, $paypalRequest->getSessionArray());
     $gateway = new TestingGlobalCollectAdapter();
     $response = $gateway->do_transaction('INSERT_ORDERWITHPAYMENT');
     $this->assertEmpty($response->getErrors());
     $errors = '';
     if (array_key_exists(LogLevel::ERROR, $this->testLogger->messages)) {
         foreach ($this->testLogger->messages[LogLevel::ERROR] as $msg) {
             $errors .= "{$msg}\n";
         }
     }
     $this->assertEmpty($errors, "The gateway error log had the following message(s):\n" . $errors);
 }
 /**
  * Tests that two API requests don't send the same order ID and merchant
  * reference.  This was the case when users doubleclicked and we were
  * using the last 5 digits of time in seconds as a suffix.  We want to see
  * what happens when a 2nd request comes in while the 1st is still waiting
  * for a CURL response, so here we fake that situation by having CURL throw
  * an exception during the 1st response.
  */
 public function testNoDupeOrderId()
 {
     $this->setUpRequest(array('action' => 'donate', 'amount' => '3.00', 'card_type' => 'amex', 'city' => 'Hollywood', 'contribution_tracking_id' => '22901382', 'country' => 'US', 'currency_code' => 'USD', 'email' => '*****@*****.**', 'fname' => 'Fakety', 'format' => 'json', 'gateway' => 'globalcollect', 'language' => 'en', 'lname' => 'Fake', 'payment_method' => 'cc', 'referrer' => 'http://en.wikipedia.org/wiki/Main_Page', 'state' => 'MA', 'street' => '99 Fake St', 'utm_campaign' => 'C14_en5C_dec_dsk_FR', 'utm_medium' => 'sitenotice', 'utm_source' => 'B14_120921_5C_lg_fnt_sans.no-LP.cc', 'zip' => '90210'));
     $gateway = new TestingGlobalCollectAdapter(array('api_request' => 'true'));
     $gateway->setDummyGatewayResponseCode('Exception');
     try {
         $gateway->do_transaction('INSERT_ORDERWITHPAYMENT');
     } catch (Exception $e) {
         // totally expected this
     }
     $first = $gateway->curled[0];
     //simulate another request coming in before we get anything back from GC
     $anotherGateway = new TestingGlobalCollectAdapter(array('api_request' => 'true'));
     $anotherGateway->do_transaction('INSERT_ORDERWITHPAYMENT');
     $second = $anotherGateway->curled[0];
     $this->assertFalse($first == $second, 'Two calls to the api did the same thing');
 }
 public function testResetOnRecurringSwitch()
 {
     // Donor initiates a non-recurring donation
     $init = $this->getDonorTestData();
     $init['payment_method'] = 'cc';
     $firstRequest = $this->setUpRequest($init);
     $gateway = new TestingGlobalCollectAdapter();
     $gateway->do_transaction('Donate');
     $donorData = $firstRequest->getSessionData('Donor');
     $this->assertEquals('', $donorData['recurring'], 'Test setup failed.');
     $oneTimeOrderId = $gateway->getData_Unstaged_Escaped('order_id');
     // Then they go back and decide they want to make a recurring donation
     $init['recurring'] = '1';
     $secondRequest = $this->setUpRequest($init, $firstRequest->getSessionArray());
     $gateway = new TestingGlobalCollectAdapter();
     $gateway->do_transaction('Donate');
     $donorData = $secondRequest->getSessionData('Donor');
     $this->assertEquals('1', $donorData['recurring'], 'Test setup failed.');
     $recurOrderId = $gateway->getData_Unstaged_Escaped('order_id');
     $this->assertNotEquals($oneTimeOrderId, $recurOrderId, 'Order ID was not regenerated on recurring switch!');
 }