Skip to content

Commit

Permalink
Actually add the proxy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccue committed Nov 30, 2014
1 parent e0e8554 commit 6d026ea
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/Proxy/HTTP.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

class RequestsTest_Proxy_HTTP extends PHPUnit_Framework_TestCase {
public function testConnectWithString() {
$options = array(
'proxy' => '127.0.0.1:8080'
);
$response = Requests::get(httpbin('/get'), array(), $options);
$this->assertEquals('http', $response->headers['x-requests-proxied']);

$data = json_decode($response->body, true);
$this->assertEquals('http', $data['headers']['X-Requests-Proxy']);
}

public function testConnectWithArray() {
$options = array(
'proxy' => array('127.0.0.1:8080')
);
$response = Requests::get(httpbin('/get'), array(), $options);
$this->assertEquals('http', $response->headers['x-requests-proxied']);

$data = json_decode($response->body, true);
$this->assertEquals('http', $data['headers']['X-Requests-Proxy']);
}

/**
* @expectedException Requests_Exception
*/
public function testConnectInvalidParameters() {
$options = array(
'proxy' => array('127.0.0.1:8080', 'testuser', 'password', 'something')
);
$response = Requests::get(httpbin('/get'), array(), $options);
}

public function testConnectWithInstance() {
$options = array(
'proxy' => '127.0.0.1:8080'
);
$response = Requests::get(httpbin('/get'), array(), $options);
$this->assertEquals('http', $response->headers['x-requests-proxied']);

$data = json_decode($response->body, true);
$this->assertEquals('http', $data['headers']['X-Requests-Proxy']);
}
}

0 comments on commit 6d026ea

Please sign in to comment.