GatewayTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Test\Unit;
  3. require_once dirname(__DIR__) . '/Setup.php';
  4. use Test\Setup;
  5. use Braintree;
  6. class GatewayTest extends Setup
  7. {
  8. public function setup()
  9. {
  10. Braintree\Configuration::reset();
  11. }
  12. public function teardown()
  13. {
  14. Braintree\Configuration::environment('development');
  15. Braintree\Configuration::merchantId('integration_merchant_id');
  16. Braintree\Configuration::publicKey('integration_public_key');
  17. Braintree\Configuration::privateKey('integration_private_key');
  18. }
  19. /**
  20. * @expectedException Braintree\Exception\Configuration
  21. * @expectedExceptionMessage needs to be set (or accessToken needs to be passed to Braintree\Gateway).
  22. */
  23. public function testConfigGetsAssertedValid()
  24. {
  25. Braintree\Configuration::environment('development');
  26. //Braintree\Configuration::merchantId('integration_merchant_id');
  27. Braintree\Configuration::publicKey('integration_public_key');
  28. Braintree\Configuration::privateKey('integration_private_key');
  29. $gateway = new Braintree\Gateway(Braintree\Configuration::$global);
  30. $gateway->addOn();
  31. }
  32. public function testConstructWithArrayOfCredentials()
  33. {
  34. $gateway = new Braintree\Gateway([
  35. 'environment' => 'sandbox',
  36. 'merchantId' => 'sandbox_merchant_id',
  37. 'publicKey' => 'sandbox_public_key',
  38. 'privateKey' => 'sandbox_private_key'
  39. ]);
  40. $this->assertEquals('sandbox', $gateway->config->getEnvironment());
  41. $this->assertEquals('sandbox_merchant_id', $gateway->config->getMerchantId());
  42. }
  43. }