HttpTest.php
2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Test\Unit;
require_once dirname(__DIR__) . '/Setup.php';
use Test\Setup;
use Braintree;
class HttpTest extends Setup
{
public function testMalformedNoSsl()
{
try {
Braintree\Configuration::environment('development');
$this->setExpectedException('Braintree\Exception\Connection', null, 3);
$http = new Braintree\Http(Braintree\Configuration::$global);
$http->_doUrlRequest('get', '/a_malformed_url');
} catch (Braintree\Exception $e) {
throw $e;
}
}
public function testMalformedUrlUsingSsl()
{
try {
Braintree\Configuration::environment('sandbox');
$this->setExpectedException('Braintree\Exception\SSLCertificate', null, 3);
$http = new Braintree\Http(Braintree\Configuration::$global);
$http->_doUrlRequest('get', '/a_malformed_url_using_ssl');
} catch (Braintree\Exception $e) {
Braintree\Configuration::environment('development');
throw $e;
}
Braintree\Configuration::environment('development');
}
public function testSSLVersionError()
{
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 testGoodRequest()
{
Braintree\Configuration::environment('development');
$http = new Braintree\Http(Braintree\Configuration::$global);
$http->_doUrlRequest('get', 'http://example.com');
}
}