This repository was archived by the owner on Jan 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 144
Curl options can now be set in the adapter class #126
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6f71a58
Curl options can now be set in the adapter class
6949086
updated CurlAdapter and tests
fce2981
Port and Curl settings can be changed, along with URI for working wit…
e52091f
Merge remote-tracking branch 'upstream/master'
5c71d6a
Removed var dumps in example
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
|
|
||
| require __DIR__ . '/../vendor/autoload.php'; | ||
|
|
||
| //When running bitpay on your local server | ||
| $network = new Bitpay\Network\Customnet("alex.bp", 8088, true); | ||
|
|
||
| //Customize the curl options | ||
| $curl_options = array( | ||
| CURLOPT_SSL_VERIFYPEER => false, | ||
| CURLOPT_SSL_VERIFYHOST => false, | ||
| ); | ||
|
|
||
| // If nothing is passed into the CurlAdapter | ||
| // then default values are used | ||
| $adapter = new Bitpay\Client\Adapter\CurlAdapter($curl_options); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
| /** | ||
| * @license Copyright 2011-2014 BitPay Inc., MIT License | ||
| * see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE | ||
| */ | ||
|
|
||
| namespace Bitpay\Network; | ||
|
|
||
| /** | ||
| * | ||
| * @package Bitcore | ||
| */ | ||
| class Customnet implements NetworkInterface | ||
| { | ||
| protected $host_url; | ||
|
|
||
| protected $host_port; | ||
|
|
||
| public $isPortRequiredInUrl; | ||
|
|
||
| public function __construct($url, $port, $isPortRequiredInUrl = false) | ||
| { | ||
| $this->host_url = $url; | ||
| $this->host_port = $port; | ||
| $this->isPortRequiredInUrl = $isPortRequiredInUrl; | ||
| } | ||
|
|
||
| public function getName() | ||
| { | ||
| return 'Custom Network'; | ||
| } | ||
|
|
||
| public function getAddressVersion() | ||
| { | ||
| return 0x00; | ||
| } | ||
|
|
||
| public function getApiHost() | ||
| { | ||
| return $this->host_url; | ||
| } | ||
|
|
||
| public function getApiPort() | ||
| { | ||
| return $this->host_port; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,9 @@ public function getApiHost() | |
| { | ||
| return 'bitpay.com'; | ||
| } | ||
|
|
||
| public function getApiPort() | ||
| { | ||
| return 443; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,4 +26,9 @@ public function getApiHost() | |
| { | ||
| return 'test.bitpay.com'; | ||
| } | ||
|
|
||
| public function getApiPort() | ||
| { | ||
| return 443; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| <?php | ||
| /** | ||
| * @license Copyright 2011-2014 BitPay Inc., MIT License | ||
| * see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE | ||
| */ | ||
|
|
||
| namespace Bitpay\Client\Adapter; | ||
|
|
||
| use Bitpay\Client\Request; | ||
|
|
||
| class CurlAdapterTest extends \PHPUnit_Framework_TestCase | ||
| { | ||
| protected $request; | ||
|
|
||
| public function setUp() | ||
| { | ||
| $this->request = new Request(); | ||
| } | ||
|
|
||
| public function testConstruct() | ||
| { | ||
| $adapter = new CurlAdapter(); | ||
| $this->assertNotNull($adapter->getCurlOptions()); | ||
| } | ||
|
|
||
| public function testGetCurlOptions() | ||
| { | ||
| $adapter = new CurlAdapter(); | ||
| $this->assertEquals(array(), $adapter->getCurlOptions()); | ||
| } | ||
|
|
||
| public function testSendRequestWithException() | ||
| { | ||
| $http = $this->getMock('HttpRequest'); | ||
| $this->setExpectedException('Exception'); | ||
|
|
||
| $curl_options = array( | ||
| CURLOPT_URL => "www.example.com", | ||
| CURLOPT_SSL_VERIFYPEER => 1, | ||
| CURLOPT_SSL_VERIFYHOST => 2, | ||
| ); | ||
|
|
||
| $adapter = new CurlAdapter($curl_options); | ||
| $response = $adapter->sendRequest($this->request); | ||
| } | ||
|
|
||
| public function testSendRequestWithoutException() | ||
| { | ||
| $http = $this->getMock('HttpRequest'); | ||
|
|
||
| $curl_options = array( | ||
| CURLOPT_URL => "www.bitpay.com", | ||
| CURLOPT_SSL_VERIFYPEER => 1, | ||
| CURLOPT_SSL_VERIFYHOST => 2, | ||
| ); | ||
|
|
||
| $adapter = new CurlAdapter($curl_options); | ||
| $response = $adapter->sendRequest($this->request); | ||
| $this->assertNotNull($response); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc block comments