php-bitpay-client/tests/Bitpay/BitpayTest.php
kakaska 84324e9f9c Merge branch 'master' into 3.0.x
# Conflicts:
#	.travis.yml
#	README.md
#	VERSION
#	composer.json
#	src/Bitpay/Client/Client.php
#	src/Bitpay/Client/ClientInterface.php
#	src/Bitpay/Client/Request.php
#	src/Bitpay/Client/Response.php
#	src/Bitpay/Config/Configuration.php
#	src/Bitpay/Currency.php
#	src/Bitpay/DependencyInjection/services.xml
#	src/Bitpay/Invoice.php
#	src/Bitpay/InvoiceInterface.php
#	src/Bitpay/Item.php
#	src/Bitpay/Network/Testnet.php
#	src/Bitpay/PrivateKey.php
#	src/Bitpay/Storage/EncryptedFilesystemStorage.php
#	src/Bitpay/Util/Util.php
#	tests/Bitpay/BitpayTest.php
#	tests/Bitpay/Client/Adapter/CurlAdapterTest.php
#	tests/Bitpay/Client/ClientTest.php
#	tests/Bitpay/Client/RequestTest.php
#	tests/Bitpay/Crypto/McryptExtensionTest.php
#	tests/Bitpay/ItemTest.php
#	tests/Bitpay/Math/BcEngineTest.php
#	tests/Bitpay/Network/LivenetTest.php
#	tests/Bitpay/Network/NetworkAwareTest.php
#	tests/Bitpay/Network/TestnetTest.php
#	tests/Bitpay/Storage/EncryptedFilesystemStorageTest.php
#	tests/DataFixtures/invoices/5NxFkXcJbCSivtQRJa4kHP.json
2019-02-19 13:40:58 +01:00

88 lines
2.4 KiB
PHP

<?php
/**
* @license Copyright 2011-2015 BitPay Inc., MIT License
* see https://github.com/bitpay/php-bitpay-client/blob/master/LICENSE
*/
namespace Bitpay;
use org\bovigo\vfs\vfsStream;
class BitpayTest extends \PHPUnit_Framework_TestCase
{
private $temp_path_pri;
private $temp_path_pub;
private $temp_path_root;
public function setUp()
{
$this->temp_path_root = 'tmp';
$this->temp_path_pri = $this->temp_path_root . '/key.pri';
$this->temp_path_pub = $this->temp_path_root . '/key.pub';
}
public function testConstruct()
{
$bitpay = new \Bitpay\Bitpay(
array(
'bitpay' => array()
)
);
}
public function testGetContainer()
{
$bitpay = new \Bitpay\Bitpay();
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $bitpay->getContainer());
}
public function testGet()
{
$bitpay = new \Bitpay\Bitpay();
$this->assertInstanceOf('Bitpay\Client\Adapter\CurlAdapter', $bitpay->get('adapter'));
}
/**
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
*/
public function testGetInvalidService()
{
$bitpay = new \Bitpay\Bitpay();
$bitpay->get('coins');
}
public function testConfigAbleToPersistAndLoadKeys()
{
$root = vfsStream::setup($this->temp_path_root);
$bitpay = new \Bitpay\Bitpay(
array(
'bitpay' => array(
'private_key' => vfsStream::url($this->temp_path_pri),
'public_key' => vfsStream::url($this->temp_path_pub),
)
)
);
$pri = new \Bitpay\PrivateKey(vfsStream::url($this->temp_path_pri));
$pri->generate();
$pub = new \Bitpay\PublicKey(vfsStream::url($this->temp_path_pub));
$pub->setPrivateKey($pri)->generate();
/**
* Save keys to the filesystem
*/
$storage = $bitpay->get('key_storage');
$storage->persist($pri);
$storage->persist($pub);
/**
* This will load the keys, if you have not already persisted them, than
* this WILL throw an Exception since this will load the keys from the
* storage class
*/
$pri = $bitpay->get('private_key');
$pub = $bitpay->get('public_key');
}
}