<commit_before><?php
/**
 * @license Copyright 2011-2014 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
{

    public function testConstruct()
    {
        $bitpay = new \Bitpay\Bitpay(
            array(
                'bitpay' => array(
                    'network' => 'testnet',
                )
            )
        );
    }

    public function testGetContainer()
    {
        $bitpay = new \Bitpay\Bitpay();
        $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $bitpay->getContainer());
    }

    public function testGet()
    {
        $bitpay = new \Bitpay\Bitpay();
        $this->assertInstanceOf('Bitpay\Network\Livenet', $bitpay->get('network'));
    }

    /**
     * @expectedException Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
     */
    public function testGetInvalidService()
    {
        $bitpay = new \Bitpay\Bitpay();
        $bitpay->get('coins');
    }

    public function testConfigAbleToPersistAndLoadKeys()
    {
        $root   = vfsStream::setup('tmp');
        $bitpay = new \Bitpay\Bitpay(
            array(
                'bitpay' => array(
                    'network'     => 'testnet',
                    'private_key' => vfsStream::url('tmp/key.pri'),
                    'public_key'  => vfsStream::url('tmp/key.pub'),
                    'key_storage' => 'Bitpay\Storage\FilesystemStorage',
                )
            )
        );

        $pri = new \Bitpay\PrivateKey(vfsStream::url('tmp/key.pri'));
        $pri->generate();
        $pub = new \Bitpay\PublicKey(vfsStream::url('tmp/key.pub'));
        $pub->setPrivateKey($pri)->generate();

        /**
         * Save keys to the filesystem
         */
        $storage = $bitpay->get('key_storage');<commit_msg>Encrypted file storage is default<commit_after><?php
/**
 * @license Copyright 2011-2014 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
{

    public function testConstruct()
    {
        $bitpay = new \Bitpay\Bitpay(
            array(
                'bitpay' => array(
                    'network' => 'testnet',
                )
            )
        );
    }

    public function testGetContainer()
    {
        $bitpay = new \Bitpay\Bitpay();
        $this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerInterface', $bitpay->getContainer());
    }

    public function testGet()
    {
        $bitpay = new \Bitpay\Bitpay();
        $this->assertInstanceOf('Bitpay\Network\Livenet', $bitpay->get('network'));
    }

    /**
     * @expectedException Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
     */
    public function testGetInvalidService()
    {
        $bitpay = new \Bitpay\Bitpay();
        $bitpay->get('coins');
    }

    public function testConfigAbleToPersistAndLoadKeys()
    {
        $root   = vfsStream::setup('tmp');
        $bitpay = new \Bitpay\Bitpay(
            array(
                'bitpay' => array(
                    'network'     => 'testnet',
                    'private_key' => vfsStream::url('tmp/key.pri'),
                    'public_key'  => vfsStream::url('tmp/key.pub'),
                )
            )
        );

        $pri = new \Bitpay\PrivateKey(vfsStream::url('tmp/key.pri'));
        $pri->generate();
        $pub = new \Bitpay\PublicKey(vfsStream::url('tmp/key.pub'));
        $pub->setPrivateKey($pri)->generate();

        /**
         * Save keys to the filesystem
         */
        $storage = $bitpay->get('key_storage');
{'fraction_non_alphanumeric': 0.14300599114352697, 'fraction_numerical': 0.004167752018754884, 'mean_word_length': 2.004694835680751, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5296196', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1105, 'n_words': 177}