PHP 7.4.33
Preview: HttpTest.php Size: 5.63 KB
/home/godevadmin/www/admin/braintree/final/braintree2/tests/integration/HttpTest.php

<?php
namespace Test\Integration;

require_once dirname(__DIR__) . '/Setup.php';

use Test\Setup;
use Braintree;

class HttpTest extends Setup
{
    public function testProductionSSL()
    {
        try {
            Braintree\Configuration::environment('production');
            $this->setExpectedException('Braintree\Exception\Authentication');
            $http = new Braintree\Http(Braintree\Configuration::$global);
            $http->get('/');
        } catch (Braintree\Exception $e) {
            Braintree\Configuration::environment('development');
            throw $e;
        }
        Braintree\Configuration::environment('development');
    }

    public function testSandboxSSL()
    {
        try {
            Braintree\Configuration::environment('sandbox');
            $this->setExpectedException('Braintree\Exception\Authentication');
            $http = new Braintree\Http(Braintree\Configuration::$global);
            $http->get('/');
        } catch (Braintree\Exception $e) {
            Braintree\Configuration::environment('development');
            throw $e;
        }
        Braintree\Configuration::environment('development');
    }

    public function testSandboxSSLWithExplicitVersionSet()
    {
        try {
            Braintree\Configuration::environment('sandbox');
            Braintree\Configuration::sslVersion(6);
            $this->setExpectedException('Braintree\Exception\Authentication');
            $http = new Braintree\Http(Braintree\Configuration::$global);
            $http->get('/');
        } catch (Braintree\Exception $e) {
            Braintree\Configuration::environment('development');
            Braintree\Configuration::sslVersion(null);
            throw $e;
        }
        Braintree\Configuration::environment('development');
        Braintree\Configuration::sslVersion(null);
    }

    public function testSandboxSSLFailsWithIncompatibleSSLVersion()
    {
        try {
            Braintree\Configuration::environment('sandbox');
            Braintree\Configuration::sslVersion(3);
            $this->setExpectedException('Braintree\Exception\SSLCertificate', null, 35);
            $http = new Braintree\Http(Braintree\Configuration::$global);
            $http->get('/');
        } catch (Braintree\Exception $e) {
            Braintree\Configuration::environment('development');
            Braintree\Configuration::sslVersion(null);
            throw $e;
        }
        Braintree\Configuration::environment('development');
        Braintree\Configuration::sslVersion(null);
    }

    public function testSslError()
    {
        try {
            Braintree\Configuration::environment('sandbox');
            $this->setExpectedException('Braintree\Exception\SSLCertificate', null, 3);
            $http = new Braintree\Http(Braintree\Configuration::$global);
            $http->_doUrlRequest('get', '/malformed_url');
        } catch (Braintree\Exception $e) {
            Braintree\Configuration::environment('development');
            throw $e;
        }
        Braintree\Configuration::environment('development');
    }

    public function testAcceptGzipEncodingSetFalse()
    {
        $originalGzipEncoding = Braintree\Configuration::acceptGzipEncoding();
        Braintree\Configuration::acceptGzipEncoding(false);
        try {
            $result = Braintree\Customer::create([
                'firstName' => 'Mike',
                'lastName' => 'Jones',
                'company' => 'Jones Co.',
                'email' => '[email protected]',
                'phone' => '419.555.1234',
                'fax' => '419.555.1235',
                'website' => 'http://example.com'
                ]);
            $this->assertEquals(true, $result->success);
            $customer = $result->customer;
            $this->assertEquals('Mike', $customer->firstName);
        } catch(Braintree\Exception $e) {
            Braintree\Configuration::acceptGzipEncoding($originalGzipEncoding);
            throw $e;
        }
        Braintree\Configuration::acceptGzipEncoding($originalGzipEncoding);
    }

    public function testAcceptGzipEncodingSetToTrue()
    {
        $originalGzipEncoding = Braintree\Configuration::acceptGzipEncoding();
        Braintree\Configuration::acceptGzipEncoding(true);
        try {
            $result = Braintree\Customer::create([
                'firstName' => 'Mike',
                'lastName' => 'Jones',
                'company' => 'Jones Co.',
                'email' => '[email protected]',
                'phone' => '419.555.1234',
                'fax' => '419.555.1235',
                'website' => 'http://example.com'
                ]);
            $this->assertEquals(true, $result->success);
            $customer = $result->customer;
            $this->assertEquals('Mike', $customer->firstName);
        } catch(Braintree\Exception $e) {
            Braintree\Configuration::acceptGzipEncoding($originalGzipEncoding);
            throw $e;
        }
        Braintree\Configuration::acceptGzipEncoding($originalGzipEncoding);
    }

    public function testAuthorizationWithConfig()
    {
        $config = new Braintree\Configuration([
            'environment' => 'development',
            'merchant_id' => 'integration_merchant_id',
            'publicKey' => 'badPublicKey',
            'privateKey' => 'badPrivateKey'
        ]);

        $http = new Braintree\Http($config);
        $result = $http->_doUrlRequest('GET', $config->baseUrl() . '/merchants/integration_merchant_id/customers');
        $this->assertEquals(401, $result['status']);
    }
}

Directory Contents

Dirs: 2 × Files: 34

Name Size Perms Modified Actions
Error DIR
- drwxrwxr-x 2023-11-07 19:59:44
Edit Download
Result DIR
- drwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.97 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
12.84 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
7.04 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
56.07 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
11.20 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.84 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
7.68 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
62.86 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.22 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
3.09 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
1.93 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
5.09 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
5.63 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
4.13 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
6.01 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
29.95 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
10.17 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
3.35 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
13.75 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.60 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
67.92 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
11.34 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
4.77 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
3.51 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.49 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
17.89 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
50.99 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
2.92 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
5.40 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
65.59 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
173.21 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
12.51 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
4.28 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download
7.06 KB lrwxrwxr-x 2023-11-07 19:59:44
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).