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);
 }
 /**
  * Integration test to verify that the Donate transaction works as expected when all necessary data is present.
  */
 function testDoTransactionDonateXclick()
 {
     $init = $this->getDonorTestData();
     TestingPaypalLegacyAdapter::$fakeGlobals = array('XclickCountries' => array($init['country']));
     $gateway = $this->getFreshGatewayObject($init);
     $ret = $gateway->doPayment();
     parse_str(parse_url($ret->getRedirect(), PHP_URL_QUERY), $res);
     $expected = array('amount' => $init['amount'], 'currency_code' => $init['currency_code'], 'country' => $init['country'], 'business' => '*****@*****.**', 'cmd' => '_xclick', 'item_name' => 'Donation to the Wikimedia Foundation', 'item_number' => 'DONATE', 'no_note' => '1', 'custom' => $gateway->getData_Unstaged_Escaped('contribution_tracking_id'), 'cancel_return' => 'https://example.com/tryAgain.php/en', 'return' => 'https://example.org/wiki/Thank_You/en?country=US', 'no_shipping' => '1');
     $this->assertEquals($expected, $res, 'Paypal "DonateXclick" transaction not constructing the expected redirect URL');
 }